public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [PATCH] MdeModulePkg/PiSmmCore: fix mem alloc issues in heap guard
@ 2018-03-13  8:34 Jian J Wang
  2018-03-13  8:36 ` Yao, Jiewen
  0 siblings, 1 reply; 2+ messages in thread
From: Jian J Wang @ 2018-03-13  8:34 UTC (permalink / raw)
  To: edk2-devel; +Cc: Star Zeng, Eric Dong, Jiewen Yao

This patch fixes the same issues in Heap Guard in DXE core, which is fixed
in another patch.

Cc: Star Zeng <star.zeng@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jian J Wang <jian.j.wang@intel.com>
---
 MdeModulePkg/Core/PiSmmCore/HeapGuard.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/MdeModulePkg/Core/PiSmmCore/HeapGuard.c b/MdeModulePkg/Core/PiSmmCore/HeapGuard.c
index aa9c25d102..923af93de2 100644
--- a/MdeModulePkg/Core/PiSmmCore/HeapGuard.c
+++ b/MdeModulePkg/Core/PiSmmCore/HeapGuard.c
@@ -251,8 +251,8 @@ FindGuardedMemoryMap (
   //
   // Adjust current map table depth according to the address to access
   //
-  while (mMapLevel < GUARDED_HEAP_MAP_TABLE_DEPTH
-         &&
+  while (AllocMapUnit &&
+         mMapLevel < GUARDED_HEAP_MAP_TABLE_DEPTH &&
          RShiftU64 (
            Address,
            mLevelShift[GUARDED_HEAP_MAP_TABLE_DEPTH - mMapLevel - 1]
@@ -887,6 +887,10 @@ AdjustMemoryS (
   }
 
   Target = Start + Size - SizeRequested;
+  ASSERT (Target >= Start);
+  if (Target == 0) {
+    return 0;
+  }
 
   if (!IsGuardPage (Start + Size)) {
     // No Guard at tail to share. One more page is needed.
-- 
2.16.2.windows.1



^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] MdeModulePkg/PiSmmCore: fix mem alloc issues in heap guard
  2018-03-13  8:34 [PATCH] MdeModulePkg/PiSmmCore: fix mem alloc issues in heap guard Jian J Wang
@ 2018-03-13  8:36 ` Yao, Jiewen
  0 siblings, 0 replies; 2+ messages in thread
From: Yao, Jiewen @ 2018-03-13  8:36 UTC (permalink / raw)
  To: Wang, Jian J, edk2-devel@lists.01.org; +Cc: Zeng, Star, Dong, Eric

Reviewed-by: Jiewen.yao@intelc.om

> -----Original Message-----
> From: Wang, Jian J
> Sent: Tuesday, March 13, 2018 4:34 PM
> To: edk2-devel@lists.01.org
> Cc: Zeng, Star <star.zeng@intel.com>; Dong, Eric <eric.dong@intel.com>; Yao,
> Jiewen <jiewen.yao@intel.com>
> Subject: [PATCH] MdeModulePkg/PiSmmCore: fix mem alloc issues in heap guard
> 
> This patch fixes the same issues in Heap Guard in DXE core, which is fixed
> in another patch.
> 
> Cc: Star Zeng <star.zeng@intel.com>
> Cc: Eric Dong <eric.dong@intel.com>
> Cc: Jiewen Yao <jiewen.yao@intel.com>
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Jian J Wang <jian.j.wang@intel.com>
> ---
>  MdeModulePkg/Core/PiSmmCore/HeapGuard.c | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/MdeModulePkg/Core/PiSmmCore/HeapGuard.c
> b/MdeModulePkg/Core/PiSmmCore/HeapGuard.c
> index aa9c25d102..923af93de2 100644
> --- a/MdeModulePkg/Core/PiSmmCore/HeapGuard.c
> +++ b/MdeModulePkg/Core/PiSmmCore/HeapGuard.c
> @@ -251,8 +251,8 @@ FindGuardedMemoryMap (
>    //
>    // Adjust current map table depth according to the address to access
>    //
> -  while (mMapLevel < GUARDED_HEAP_MAP_TABLE_DEPTH
> -         &&
> +  while (AllocMapUnit &&
> +         mMapLevel < GUARDED_HEAP_MAP_TABLE_DEPTH &&
>           RShiftU64 (
>             Address,
>             mLevelShift[GUARDED_HEAP_MAP_TABLE_DEPTH - mMapLevel -
> 1]
> @@ -887,6 +887,10 @@ AdjustMemoryS (
>    }
> 
>    Target = Start + Size - SizeRequested;
> +  ASSERT (Target >= Start);
> +  if (Target == 0) {
> +    return 0;
> +  }
> 
>    if (!IsGuardPage (Start + Size)) {
>      // No Guard at tail to share. One more page is needed.
> --
> 2.16.2.windows.1



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-03-13  8:29 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-03-13  8:34 [PATCH] MdeModulePkg/PiSmmCore: fix mem alloc issues in heap guard Jian J Wang
2018-03-13  8:36 ` Yao, Jiewen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox