audk/MdeModulePkg/Core/Dxe
Laszlo Ersek 47343af304 MdeModulePkg/Core/Dxe: limit FwVol encapsulation section recursion
The DXE Core sets up a protocol notify function in its entry point, for
instances of the Firmware Volume Block2 Protocol:

  DxeMain()           [DxeMain/DxeMain.c]
    FwVolDriverInit() [FwVol/FwVol.c]

Assume that a 3rd party UEFI driver or application installs an FVB
instance, with crafted contents. The notification function runs:

  NotifyFwVolBlock() [FwVol/FwVol.c]

installing an instance of the Firmware Volume 2 Protocol on the handle.

(Alternatively, assume that a 3rd party application calls
gDS->ProcessFirmwareVolume(), which may also produce a Firmware Volume 2
Protocol instance.)

The EFI_FIRMWARE_VOLUME2_PROTOCOL.ReadSection() member performs "a
depth-first, left-to-right search algorithm through all sections found in
the specified file" (quoting the PI spec), as follows:

  FvReadFileSection()   [FwVol/FwVolRead.c]
    GetSection()        [SectionExtraction/CoreSectionExtraction.c]
      FindChildNode()   [SectionExtraction/CoreSectionExtraction.c]
        FindChildNode() // recursive call

FindChildNode() is called recursively for encapsulation sections.

Currently this recursion is not limited. Introduce a new PCD
(fixed-at-build, or patchable-in-module), and make FindChildNode() track
the section nesting depth against that PCD.

Cc: Dandan Bi <dandan.bi@intel.com>
Cc: Hao A Wu <hao.a.wu@intel.com>
Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Cc: Philippe Mathieu-Daudé <philmd@redhat.com>
Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=1743
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Message-Id: <20201119105340.16225-3-lersek@redhat.com>
2020-11-21 01:40:53 +00:00
..
Dispatcher MdeModulePkg DxeCore: Fix typo in function name 2019-10-17 09:09:02 +08:00
DxeMain MdeModulePkg/Core/Dxe: log memory base and length, after lib ctors again 2020-11-06 20:37:22 +00:00
Event MdeModulePkg: document workaround for EFI_RUNTIME_EVENT_ENTRY PI spec bug 2019-10-09 09:40:09 +02:00
FwVol MdeModulePkg/Core: Support standalone MM in FV2 protocol GetNextFile(). 2020-10-29 05:29:42 +00:00
FwVolBlock MdeModulePkg: Replace BSD License with BSD+Patent License 2019-04-09 10:58:08 -07:00
Gcd MdeModulePkg/Gcd: Check memory allocation when initializing memory 2020-11-05 03:37:37 +00:00
Hand MdeModulePkg: Make retval in UninstallMultipleProtocol follow Spec 2020-02-19 14:43:25 +00:00
Image MdeModulePkg/DxeCore: defer PE/COFF emulator registration to StartImage 2020-03-04 09:26:45 +00:00
Library MdeModulePkg: Replace BSD License with BSD+Patent License 2019-04-09 10:58:08 -07:00
Mem MdeModulePkg/Core/Dxe: expose SP and CRYPTO capabilities in UEFI memmap 2020-10-10 04:04:50 +00:00
Misc MdeModulePkg: Add New Memory Attributes 2020-07-15 14:58:25 +00:00
SectionExtraction MdeModulePkg/Core/Dxe: limit FwVol encapsulation section recursion 2020-11-21 01:40:53 +00:00
DxeCore.uni MdeModulePkg: Replace BSD License with BSD+Patent License 2019-04-09 10:58:08 -07:00
DxeCoreExtra.uni MdeModulePkg: Replace BSD License with BSD+Patent License 2019-04-09 10:58:08 -07:00
DxeMain.h MdeModulePkg/DxeCore: merge properties table routines into MAT handling 2020-04-07 08:15:46 +00:00
DxeMain.inf MdeModulePkg/Core/Dxe: limit FwVol encapsulation section recursion 2020-11-21 01:40:53 +00:00