* [PATCH v2] UefiCpuPkg/PiSmmCpuDxeSmm: Add check to avoid NULL ptr dereference
@ 2016-12-20 2:22 Hao Wu
2016-12-20 2:35 ` Yao, Jiewen
0 siblings, 1 reply; 3+ messages in thread
From: Hao Wu @ 2016-12-20 2:22 UTC (permalink / raw)
To: edk2-devel; +Cc: Hao Wu, Jiewen Yao, Jeff Fan, Michael Kinney
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Jeff Fan <jeff.fan@intel.com>
Cc: Michael Kinney <michael.d.kinney@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Hao Wu <hao.a.wu@intel.com>
---
UefiCpuPkg/PiSmmCpuDxeSmm/SmmCpuMemoryManagement.c | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/SmmCpuMemoryManagement.c b/UefiCpuPkg/PiSmmCpuDxeSmm/SmmCpuMemoryManagement.c
index f4716f3..d967255 100644
--- a/UefiCpuPkg/PiSmmCpuDxeSmm/SmmCpuMemoryManagement.c
+++ b/UefiCpuPkg/PiSmmCpuDxeSmm/SmmCpuMemoryManagement.c
@@ -1011,6 +1011,10 @@ GetUefiMemoryMap (
}
} while (Status == EFI_BUFFER_TOO_SMALL);
+ if (MemoryMap == NULL) {
+ return ;
+ }
+
SortMemoryMap (MemoryMap, UefiMemoryMapSize, mUefiDescriptorSize);
MergeMemoryMapForNotPresentEntry (MemoryMap, &UefiMemoryMapSize, mUefiDescriptorSize);
@@ -1080,6 +1084,13 @@ IsSmmCommBufferForbiddenAddress (
UINTN MemoryMapEntryCount;
UINTN Index;
+ DEBUG ((DEBUG_INFO, "IsSmmCommBufferForbiddenAddress\n"));
+
+ if (mUefiMemoryMap == NULL) {
+ DEBUG ((DEBUG_INFO, "UefiMemoryMap - NULL\n"));
+ return FALSE;
+ }
+
MemoryMap = mUefiMemoryMap;
MemoryMapEntryCount = mUefiMemoryMapSize/mUefiDescriptorSize;
for (Index = 0; Index < MemoryMapEntryCount; Index++) {
--
1.9.5.msysgit.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v2] UefiCpuPkg/PiSmmCpuDxeSmm: Add check to avoid NULL ptr dereference
2016-12-20 2:22 [PATCH v2] UefiCpuPkg/PiSmmCpuDxeSmm: Add check to avoid NULL ptr dereference Hao Wu
@ 2016-12-20 2:35 ` Yao, Jiewen
2016-12-20 2:38 ` Wu, Hao A
0 siblings, 1 reply; 3+ messages in thread
From: Yao, Jiewen @ 2016-12-20 2:35 UTC (permalink / raw)
To: Wu, Hao A, edk2-devel@lists.01.org; +Cc: Fan, Jeff, Kinney, Michael D
Thanks.
This function will be called in SMM exception handlers. The exception info will be displayed later.
There is no need to add debug message here. Please remove it.
With that change, reviewed-by: Jiewen.yao@intel.com
> -----Original Message-----
> From: Wu, Hao A
> Sent: Tuesday, December 20, 2016 10:22 AM
> To: edk2-devel@lists.01.org
> Cc: Wu, Hao A <hao.a.wu@intel.com>; Yao, Jiewen <jiewen.yao@intel.com>; Fan,
> Jeff <jeff.fan@intel.com>; Kinney, Michael D <michael.d.kinney@intel.com>
> Subject: [PATCH v2] UefiCpuPkg/PiSmmCpuDxeSmm: Add check to avoid NULL
> ptr dereference
>
> Cc: Jiewen Yao <jiewen.yao@intel.com>
> Cc: Jeff Fan <jeff.fan@intel.com>
> Cc: Michael Kinney <michael.d.kinney@intel.com>
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Hao Wu <hao.a.wu@intel.com>
> ---
> UefiCpuPkg/PiSmmCpuDxeSmm/SmmCpuMemoryManagement.c | 11
> +++++++++++
> 1 file changed, 11 insertions(+)
>
> diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/SmmCpuMemoryManagement.c
> b/UefiCpuPkg/PiSmmCpuDxeSmm/SmmCpuMemoryManagement.c
> index f4716f3..d967255 100644
> --- a/UefiCpuPkg/PiSmmCpuDxeSmm/SmmCpuMemoryManagement.c
> +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/SmmCpuMemoryManagement.c
> @@ -1011,6 +1011,10 @@ GetUefiMemoryMap (
> }
> } while (Status == EFI_BUFFER_TOO_SMALL);
>
> + if (MemoryMap == NULL) {
> + return ;
> + }
> +
> SortMemoryMap (MemoryMap, UefiMemoryMapSize, mUefiDescriptorSize);
> MergeMemoryMapForNotPresentEntry (MemoryMap,
> &UefiMemoryMapSize, mUefiDescriptorSize);
>
> @@ -1080,6 +1084,13 @@ IsSmmCommBufferForbiddenAddress (
> UINTN MemoryMapEntryCount;
> UINTN Index;
>
> + DEBUG ((DEBUG_INFO, "IsSmmCommBufferForbiddenAddress\n"));
> +
> + if (mUefiMemoryMap == NULL) {
> + DEBUG ((DEBUG_INFO, "UefiMemoryMap - NULL\n"));
> + return FALSE;
> + }
> +
> MemoryMap = mUefiMemoryMap;
> MemoryMapEntryCount = mUefiMemoryMapSize/mUefiDescriptorSize;
> for (Index = 0; Index < MemoryMapEntryCount; Index++) {
> --
> 1.9.5.msysgit.0
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v2] UefiCpuPkg/PiSmmCpuDxeSmm: Add check to avoid NULL ptr dereference
2016-12-20 2:35 ` Yao, Jiewen
@ 2016-12-20 2:38 ` Wu, Hao A
0 siblings, 0 replies; 3+ messages in thread
From: Wu, Hao A @ 2016-12-20 2:38 UTC (permalink / raw)
To: Yao, Jiewen, edk2-devel@lists.01.org; +Cc: Fan, Jeff, Kinney, Michael D
Got it. I will remove those debug messages before check-in.
Best Regards,
Hao Wu
> -----Original Message-----
> From: Yao, Jiewen
> Sent: Tuesday, December 20, 2016 10:35 AM
> To: Wu, Hao A; edk2-devel@lists.01.org
> Cc: Fan, Jeff; Kinney, Michael D
> Subject: RE: [PATCH v2] UefiCpuPkg/PiSmmCpuDxeSmm: Add check to avoid
> NULL ptr dereference
>
> Thanks.
>
> This function will be called in SMM exception handlers. The exception info will
> be displayed later.
> There is no need to add debug message here. Please remove it.
>
> With that change, reviewed-by: Jiewen.yao@intel.com
>
> > -----Original Message-----
> > From: Wu, Hao A
> > Sent: Tuesday, December 20, 2016 10:22 AM
> > To: edk2-devel@lists.01.org
> > Cc: Wu, Hao A <hao.a.wu@intel.com>; Yao, Jiewen <jiewen.yao@intel.com>;
> Fan,
> > Jeff <jeff.fan@intel.com>; Kinney, Michael D <michael.d.kinney@intel.com>
> > Subject: [PATCH v2] UefiCpuPkg/PiSmmCpuDxeSmm: Add check to avoid
> NULL
> > ptr dereference
> >
> > Cc: Jiewen Yao <jiewen.yao@intel.com>
> > Cc: Jeff Fan <jeff.fan@intel.com>
> > Cc: Michael Kinney <michael.d.kinney@intel.com>
> > Contributed-under: TianoCore Contribution Agreement 1.0
> > Signed-off-by: Hao Wu <hao.a.wu@intel.com>
> > ---
> > UefiCpuPkg/PiSmmCpuDxeSmm/SmmCpuMemoryManagement.c | 11
> > +++++++++++
> > 1 file changed, 11 insertions(+)
> >
> > diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/SmmCpuMemoryManagement.c
> > b/UefiCpuPkg/PiSmmCpuDxeSmm/SmmCpuMemoryManagement.c
> > index f4716f3..d967255 100644
> > --- a/UefiCpuPkg/PiSmmCpuDxeSmm/SmmCpuMemoryManagement.c
> > +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/SmmCpuMemoryManagement.c
> > @@ -1011,6 +1011,10 @@ GetUefiMemoryMap (
> > }
> > } while (Status == EFI_BUFFER_TOO_SMALL);
> >
> > + if (MemoryMap == NULL) {
> > + return ;
> > + }
> > +
> > SortMemoryMap (MemoryMap, UefiMemoryMapSize,
> mUefiDescriptorSize);
> > MergeMemoryMapForNotPresentEntry (MemoryMap,
> > &UefiMemoryMapSize, mUefiDescriptorSize);
> >
> > @@ -1080,6 +1084,13 @@ IsSmmCommBufferForbiddenAddress (
> > UINTN MemoryMapEntryCount;
> > UINTN Index;
> >
> > + DEBUG ((DEBUG_INFO, "IsSmmCommBufferForbiddenAddress\n"));
> > +
> > + if (mUefiMemoryMap == NULL) {
> > + DEBUG ((DEBUG_INFO, "UefiMemoryMap - NULL\n"));
> > + return FALSE;
> > + }
> > +
> > MemoryMap = mUefiMemoryMap;
> > MemoryMapEntryCount = mUefiMemoryMapSize/mUefiDescriptorSize;
> > for (Index = 0; Index < MemoryMapEntryCount; Index++) {
> > --
> > 1.9.5.msysgit.0
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2016-12-20 2:38 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-12-20 2:22 [PATCH v2] UefiCpuPkg/PiSmmCpuDxeSmm: Add check to avoid NULL ptr dereference Hao Wu
2016-12-20 2:35 ` Yao, Jiewen
2016-12-20 2:38 ` Wu, Hao A
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox