audk/MdeModulePkg/Core/Dxe
Ard Biesheuvel 3f2ae009ec MdeModulePkg/DxeCore: deal with allocations spanning several memmap entries
When attempting to perform page allocations using AllocateAddress, we
fail to check whether the entire region is free before splitting the
region. This may lead to memory being leaked further into the routine,
when it turns out that one of the memory map entries intersected by the
region is already occupied. In this case, prior conversions are not rolled
back.

For instance, starting from this situation

0x000040000000-0x00004007ffff [ConventionalMemory ]
0x000040080000-0x00004009ffff [Boot Data          ]
0x0000400a0000-0x000047ffffff [ConventionalMemory ]

a failed EfiLoaderData allocation @ 0x40000000 that covers the BootData
region will fail, but leave the first part of the allocation converted,
so we end up with

0x000040000000-0x00004007ffff [Loader Data        ]
0x000040080000-0x00004009ffff [Boot Data          ]
0x0000400a0000-0x000047ffffff [ConventionalMemory ]

even though the AllocatePages() call returned an error.

So let's check beforehand that AllocateAddress allocations are covered
by a single memory map entry, so that it either succeeds or fails
completely, rather than leaking allocations.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Reviewed-by: Star Zeng <star.zeng@intel.com>
2017-03-17 18:50:55 +00:00
..
Dispatcher MdeModulePkg: Use EfiEventEmptyFunction from UefiLib 2017-01-20 15:51:18 +08:00
DxeMain MdeModulePkg/DxeCore: Add UEFI image protection. 2017-02-22 14:07:04 +08:00
Event MdeModulePkg: Use EfiEventEmptyFunction from UefiLib 2017-01-20 15:51:18 +08:00
FwVol MdeModulePkg/Core: Fix typos in comments 2016-10-27 09:11:17 +08:00
FwVolBlock MdeModulePkg DxeCore: Show error message on unaligned FvImage issue 2016-11-17 09:27:11 +08:00
Gcd MdeModulePkg/DxeCore:Clear RT attribute on SetCapabilities. 2017-01-12 15:58:13 +08:00
Hand MdeModulePkg/Core: Fix typos in comments 2016-10-27 09:11:17 +08:00
Image MdeModulePkg: Refine casting expression result to bigger size 2017-03-06 14:33:20 +08:00
Library Update the copyright notice format 2010-04-24 09:49:11 +00:00
Mem MdeModulePkg/DxeCore: deal with allocations spanning several memmap entries 2017-03-17 18:50:55 +00:00
Misc MdeModulePkg/DxeCore: Fix coding style issues 2017-03-07 21:47:25 +08:00
SectionExtraction MdeModulePkg: Fix typos in comments and variables 2016-07-11 10:29:48 +08:00
DxeCore.uni MdeModulePkg: Convert all .uni files to utf-8 2015-12-15 04:56:23 +00:00
DxeCoreExtra.uni MdeModulePkg: Convert all .uni files to utf-8 2015-12-15 04:56:23 +00:00
DxeMain.h MdeModulePkg/DxeCore: switch to MdePkg allocation granularity macros 2017-03-06 11:29:20 +01:00
DxeMain.inf MdeModulePkg/DxeCore: implement memory protection policy 2017-02-28 15:01:10 +00:00