audk/MdeModulePkg
Michael Kubacki 1a258c7703 MdeModulePkg/ReportStatusCodeRouter: Revert end pointer on out of resources
REF:https://bugzilla.tianocore.org/show_bug.cgi?id=2665

ReportDispatcher() is called by a software module to report a status code.
The interface is generic and can be called frequently throughout the boot
under various conditions. A certain set of conditions can cause the
currently implemented algorithm for resource exhaustion to fail. A sample
scenario:

1. ReportStatusCode() is called at a TPL higher than one of the registered
   status code listeners making the call to the listener deferred until
   TPL is lowered.
2. Additional calls to ReportStatusCode() occur, so the data buffer
   continues to expand.
3. A call to ReportStatusCode() is made from within a memory allocation
   call (e.g. CoreAllocatePoolPages ()) which is protected from re-
   entrancy with mPoolMemoryLock. This will cause the ReallocatePool()
   call in ReportDispatcher() to fail. Because the end pointer was already
   moved to account for the data size, the end pointer is now moved
   beyond the buffer and invalid.

This commit saves the original end pointer value into a local variable
called "FailSafeEndPointer" which tracks a safe end pointer to revert to
in the case the allocated buffer size (CallbackEntry->EndPointer -
CallbackEntry->StatusCodeDataBuffer) is still not large enough for the
data.

Cc: Hao A Wu <hao.a.wu@intel.com>
Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Kun Qin <Kun.Qin@microsoft.com>
Cc: Liming Gao <liming.gao@intel.com>
Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
Reviewed-by: Dandan Bi <dandan.bi@intel.com>
2020-04-21 02:20:51 +00:00
..
Application MdeModulePkg/SmiHandlerProfileInfo: Overflowed Array Index 2020-04-08 05:22:27 +00:00
Bus MdeModulePkg/NonDiscoverablePciDeviceDxe: use standard PCI_MAX_BAR macro 2020-04-16 19:53:46 +00:00
Core MdeModulePkg/DxeCore: merge properties table routines into MAT handling 2020-04-07 08:15:46 +00:00
Include MdeModulePkg: Remove gEfiFormBrowserExProtocolGuid Protocol Guid 2020-03-30 01:13:49 +00:00
Library MdeModulePkg/BrotliCustomDecompressLib: Make brotli a submodule 2020-04-16 01:58:38 +00:00
Logo MdeModulePkg: Replace BSD License with BSD+Patent License 2019-04-09 10:58:08 -07:00
Test MdeModulePkg: Add DxeResetSystemLib unit test 2020-02-07 19:18:53 +00:00
Universal MdeModulePkg/ReportStatusCodeRouter: Revert end pointer on out of resources 2020-04-21 02:20:51 +00:00
MdeModulePkg.ci.yaml MdeModulePkg/RegularExpressionDxe: Make oniguruma a submodule in edk2. 2020-04-13 01:26:12 +00:00
MdeModulePkg.dec MdeModulePkg/BrotliCustomDecompressLib: Make brotli a submodule 2020-04-16 01:58:38 +00:00
MdeModulePkg.dsc MdeModulePkg: Use LockBoxNullLib for RISC-V 2020-04-03 17:09:12 +00:00
MdeModulePkg.uni MdeModulePkg: disable properties table generation but retain the code 2020-04-07 08:15:46 +00:00
MdeModulePkgExtra.uni MdeModulePkg: Replace BSD License with BSD+Patent License 2019-04-09 10:58:08 -07:00