Skip to content

Commit

Permalink
Increase Temp Buffer Size in FillMemoryMap() Routine (#213)
Browse files Browse the repository at this point in the history
## Description

Platforms with many differences between the EFI and GCD memory maps can
overflow the temp buffer allocated at the start of FillInMemoryMap().
This PR updates the size of the temp buffer to be quadruple the size of
the input EFI memory map to accommodate extra entries. At the end of the
routine, the contents of the temp buffer are copied into a new buffer
which is strictly the required size and the temp buffer is freed.

- [x] Impacts functionality?
- [ ] Impacts security?
- [ ] Breaking change?
- [ ] Includes tests?
- [ ] Includes documentation?

## How This Was Tested

Booting to shell

## Integration Instructions

N/A
  • Loading branch information
TaylorBeebe authored Dec 16, 2022
1 parent 3772cbb commit ce33fcf
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions MdeModulePkg/Core/Dxe/Misc/MemoryProtectionSupport.c
Original file line number Diff line number Diff line change
Expand Up @@ -1279,8 +1279,8 @@ FillInMemoryMap (

NewMemoryMapStart = NULL;

// Double the size of the memory map for the worst case of every entry being non-contiguous
NewMemoryMapStart = AllocatePool ((*MemoryMapSize * 2) + (*DescriptorSize * 2));
// Quadruple the size of the input memory map to accomodate extra entries
NewMemoryMapStart = AllocatePool (*MemoryMapSize * 4);

if (NewMemoryMapStart == NULL) {
return EFI_OUT_OF_RESOURCES;
Expand Down

0 comments on commit ce33fcf

Please # to comment.