summaryrefslogtreecommitdiff
path: root/SourceLevelDebugPkg/Library/DebugAgent/SmmDebugAgent/SmmDebugAgentLib.h
diff options
context:
space:
mode:
authorOliver Smith-Denny <osde@microsoft.com>2025-06-16 15:30:03 -0700
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>2025-07-09 00:59:56 +0000
commit2d69507a4dde02f1abf20c7eb3a43d1d3ef6b98f (patch)
tree6155f8700720fe1c341080ef7fbd9aea7fa98d26 /SourceLevelDebugPkg/Library/DebugAgent/SmmDebugAgent/SmmDebugAgentLib.h
parent0425158a94d7b55c4670cdefe107a4ad9f6c7476 (diff)
downloadedk2-master.zip
edk2-master.tar.gz
edk2-master.tar.bz2
MdeModulePkg: Leak Memory if Not RW on FreePagesHEADmaster
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 <osde@microsoft.com>
Diffstat (limited to 'SourceLevelDebugPkg/Library/DebugAgent/SmmDebugAgent/SmmDebugAgentLib.h')
0 files changed, 0 insertions, 0 deletions