[edk2-devel] [PATCH 2/2] MdeModulePkg/Core/Dxe: free page 0 after disabling NULL pointer detection

Wang, Jian J jian.j.wang at intel.com
Wed Nov 6 13:13:33 UTC 2019


To solve access issue reported by BZ1885, page 0 will be allocated to
avoid misuses if NULL pointer detection is enabled. It should be better
to be freed after EndOfDxe if BIT7 of PcdNullPointerDetectionPropertyMask
is set, because NULL pointer detection is no longer available after
EndOfDxe and there will be no access conflict.

Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=1885
Cc: Dandan Bi <dandan.bi at intel.com>
Cc: Liming Gao <liming.gao at intel.com>
Cc: Ray Ni <ray.ni at intel.com>
Cc: Hao A Wu <hao.a.wu at intel.com>
Cc: Sean Brogan <sean.brogan at microsoft.com>
Signed-off-by: Jian J Wang <jian.j.wang at intel.com>
---
 MdeModulePkg/Core/Dxe/Misc/MemoryProtection.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/MdeModulePkg/Core/Dxe/Misc/MemoryProtection.c b/MdeModulePkg/Core/Dxe/Misc/MemoryProtection.c
index 7a24bd0781..47edf86dfb 100644
--- a/MdeModulePkg/Core/Dxe/Misc/MemoryProtection.c
+++ b/MdeModulePkg/Core/Dxe/Misc/MemoryProtection.c
@@ -1094,6 +1094,11 @@ DisableNullDetectionAtTheEndOfDxe (
             );
   ASSERT_EFI_ERROR (Status);
 
+  //
+  // Page 0 might have be allocated to avoid misuses. Free it here anyway.
+  //
+  CoreFreePages (0, 1);
+
   CoreCloseEvent (Event);
   DEBUG ((DEBUG_INFO, "DisableNullDetectionAtTheEndOfDxe(): end\r\n"));
 
-- 
2.17.1.windows.2


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#50062): https://edk2.groups.io/g/devel/message/50062
Mute This Topic: https://groups.io/mt/44036075/1813853
Group Owner: devel+owner at edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [edk2-devel-archive at redhat.com]
-=-=-=-=-=-=-=-=-=-=-=-




More information about the edk2-devel-archive mailing list