public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Wang, Jian J" <jian.j.wang@intel.com>
To: devel@edk2.groups.io
Cc: Dandan Bi <dandan.bi@intel.com>,
	Liming Gao <liming.gao@intel.com>, Ray Ni <ray.ni@intel.com>,
	Hao A Wu <hao.a.wu@intel.com>,
	Sean Brogan <sean.brogan@microsoft.com>
Subject: [PATCH 2/2] MdeModulePkg/Core/Dxe: free page 0 after disabling NULL pointer detection
Date: Wed,  6 Nov 2019 21:13:33 +0800	[thread overview]
Message-ID: <20191106131333.4684-3-jian.j.wang@intel.com> (raw)
In-Reply-To: <20191106131333.4684-1-jian.j.wang@intel.com>

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@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Cc: Hao A Wu <hao.a.wu@intel.com>
Cc: Sean Brogan <sean.brogan@microsoft.com>
Signed-off-by: Jian J Wang <jian.j.wang@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


  parent reply	other threads:[~2019-11-06 13:13 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-06 13:13 [PATCH 0/2] Reserve page 0 for NULL pointer detection Wang, Jian J
2019-11-06 13:13 ` [PATCH 1/2] MdeModulePkg/DxeIplPeim: reserve " Wang, Jian J
2019-11-06 13:13 ` Wang, Jian J [this message]
2019-11-07  2:10 ` [PATCH 0/2] Reserve " Ni, Ray
2019-11-09  3:03   ` Wang, Jian J

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20191106131333.4684-3-jian.j.wang@intel.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox