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" <devel@edk2.groups.io>,
	"kuqin12@gmail.com" <kuqin12@gmail.com>
Cc: "Yao, Jiewen" <jiewen.yao@intel.com>,
	"Dong, Eric" <eric.dong@intel.com>, "Ni, Ray" <ray.ni@intel.com>,
	"Gao, Liming" <gaoliming@byosoft.com.cn>
Subject: Re: [edk2-devel] [PATCH v1 1/1] MdeModulePkg: PiSmmCore: Inspect memory guarded with pool headers
Date: Fri, 22 Apr 2022 05:47:08 +0000	[thread overview]
Message-ID: <CO1PR11MB494573A77A6E2ED7E7AFF9E8B6F79@CO1PR11MB4945.namprd11.prod.outlook.com> (raw)
In-Reply-To: <20220316035954.1146-2-kuqin12@gmail.com>

It looks good to me. Thanks for fixing it.

Reviewed-by: Jian J Wang <jian.j.wang@intel.com>

Regards,
Jian

> -----Original Message-----
> From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Kun Qin
> Sent: Wednesday, March 16, 2022 12:00 PM
> To: devel@edk2.groups.io
> Cc: Yao, Jiewen <jiewen.yao@intel.com>; Dong, Eric <eric.dong@intel.com>; Ni,
> Ray <ray.ni@intel.com>; Wang, Jian J <jian.j.wang@intel.com>; Gao, Liming
> <gaoliming@byosoft.com.cn>
> Subject: [edk2-devel] [PATCH v1 1/1] MdeModulePkg: PiSmmCore: Inspect
> memory guarded with pool headers
> 
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3488
> 
> Current free pool routine from PiSmmCore will inspect memory guard status
> for target buffer without considering pool headers. This could lead to
> `IsMemoryGuarded` function to return incorrect results.
> 
> In that sense, allocating a 0 sized pool could cause an allocated buffer
> directly points into a guard page, which is legal. However, trying to
> free this pool will cause the routine changed in this commit to read XP
> pages, which leads to page fault.
> 
> This change will inspect memory guarded with pool headers. This can avoid
> errors when a pool content happens to be on a page boundary.
> 
> Cc: Jiewen Yao <jiewen.yao@intel.com>
> Cc: Eric Dong <eric.dong@intel.com>
> Cc: Ray Ni <ray.ni@intel.com>
> Cc: Jian J Wang <jian.j.wang@intel.com>
> Cc: Liming Gao <gaoliming@byosoft.com.cn>
> 
> Signed-off-by: Kun Qin <kuqin12@gmail.com>
> ---
>  MdeModulePkg/Core/PiSmmCore/Pool.c | 10 +++++-----
>  1 file changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/MdeModulePkg/Core/PiSmmCore/Pool.c
> b/MdeModulePkg/Core/PiSmmCore/Pool.c
> index 96ebe811c669..e1ff40a8ea55 100644
> --- a/MdeModulePkg/Core/PiSmmCore/Pool.c
> +++ b/MdeModulePkg/Core/PiSmmCore/Pool.c
> @@ -382,11 +382,6 @@ SmmInternalFreePool (
>      return EFI_INVALID_PARAMETER;
>    }
> 
> -  MemoryGuarded = IsHeapGuardEnabled () &&
> -                  IsMemoryGuarded ((EFI_PHYSICAL_ADDRESS)(UINTN)Buffer);
> -  HasPoolTail = !(MemoryGuarded &&
> -                  ((PcdGet8 (PcdHeapGuardPropertyMask) & BIT7) == 0));
> -
>    FreePoolHdr = (FREE_POOL_HEADER *)((POOL_HEADER *)Buffer - 1);
>    ASSERT (FreePoolHdr->Header.Signature == POOL_HEAD_SIGNATURE);
>    ASSERT (!FreePoolHdr->Header.Available);
> @@ -394,6 +389,11 @@ SmmInternalFreePool (
>      return EFI_INVALID_PARAMETER;
>    }
> 
> +  MemoryGuarded = IsHeapGuardEnabled () &&
> +                  IsMemoryGuarded ((EFI_PHYSICAL_ADDRESS)(UINTN)FreePoolHdr);
> +  HasPoolTail = !(MemoryGuarded &&
> +                  ((PcdGet8 (PcdHeapGuardPropertyMask) & BIT7) == 0));
> +
>    if (HasPoolTail) {
>      PoolTail = HEAD_TO_TAIL (&FreePoolHdr->Header);
>      ASSERT (PoolTail->Signature == POOL_TAIL_SIGNATURE);
> --
> 2.35.1.windows.2
> 
> 
> 
> 
> 


      parent reply	other threads:[~2022-04-22  5:47 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-16  3:59 [PATCH v1 0/1] SMM memory management: Inspect memory guarded with pool headers Kun Qin
2022-03-16  3:59 ` [PATCH v1 1/1] MdeModulePkg: PiSmmCore: " Kun Qin
2022-03-18  1:20   ` 回复: [edk2-devel] " gaoliming
2022-03-28 21:57     ` Kun Qin
2022-04-21 20:50       ` Kun Qin
2022-04-22  5:47   ` Wang, Jian J [this message]

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=CO1PR11MB494573A77A6E2ED7E7AFF9E8B6F79@CO1PR11MB4945.namprd11.prod.outlook.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