Branch: refs/heads/master Home: https://github.com/tianocore/edk2 Commit: 2d69507a4dde02f1abf20c7eb3a43d1d3ef6b98f https://github.com/tianocore/edk2/commit/2d69507a4dde02f1abf20c7eb3a43d1d3ef6b98f Author: Oliver Smith-Denny <o...@microsoft.com> Date: 2025-07-09 (Wed, 09 Jul 2025)
Changed paths: M MdeModulePkg/Core/Dxe/DxeMain.h M MdeModulePkg/Core/Dxe/DxeMain.inf M MdeModulePkg/Core/Dxe/Mem/Page.c M MdeModulePkg/Core/Dxe/Misc/MemoryProtection.c Log Message: ----------- MdeModulePkg: Leak Memory if Not RW on FreePages Currently, if the DebugClearMemory bit is set in the PcdDebugPropertyMask, CoreConvertPagesEx will attempt to write a pattern to the pages being freed. However, it does not check that the page is writeable, which will cause a page fault if not. Furthermore, if NX protections are not enabled, the core does not ensure that any freed pages are RW, which is the state expected when they are allocated next. If they are not RW, the allocating driver will crash trying to use them. This patch updates the page freeing code to query the memory attributes protocol, if present, for the attributes. If this call fails or the attributes are not RW at a minimum, the core leaks the memory (returning success to the caller). If the memory attribute protocol is not present (either because a platform doesn't produce it or it is before the protocol has been produced, the core continues with freeing memory. This is either before the CPU Arch protocol is available (so drivers can't change memory attributes) or otherwise matches existing behavior. This was deemed the best approach to let memory that can't be guaranteed to be RW leak instead of letting a driver crash when allocating it. It was deemed less brittle to simply leak the memory instead of attempting to change the attributes. Signed-off-by: Oliver Smith-Denny <o...@microsoft.com> To unsubscribe from these emails, change your notification settings at https://github.com/tianocore/edk2/settings/notifications _______________________________________________ edk2-commits mailing list edk2-commits@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/edk2-commits