* [PATCH 0/2] Avoid possible NULL ptr dereference @ 2018-07-30 5:37 Hao Wu 2018-07-30 5:37 ` [PATCH 1/2] MdePkg/SmmMemLib: " Hao Wu ` (2 more replies) 0 siblings, 3 replies; 5+ messages in thread From: Hao Wu @ 2018-07-30 5:37 UTC (permalink / raw) To: edk2-devel; +Cc: Hao Wu, Jiewen Yao Cc: Jiewen Yao <jiewen.yao@intel.com> Hao Wu (2): MdePkg/SmmMemLib: Avoid possible NULL ptr dereference UefiCpuPkg/PiSmmCpuDxeSmm: Avoid possible NULL ptr dereference MdePkg/Library/SmmMemLib/SmmMemLib.c | 2 +- UefiCpuPkg/PiSmmCpuDxeSmm/SmmCpuMemoryManagement.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) -- 2.12.0.windows.1 ^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 1/2] MdePkg/SmmMemLib: Avoid possible NULL ptr dereference 2018-07-30 5:37 [PATCH 0/2] Avoid possible NULL ptr dereference Hao Wu @ 2018-07-30 5:37 ` Hao Wu 2018-07-30 5:37 ` [PATCH 2/2] UefiCpuPkg/PiSmmCpuDxeSmm: " Hao Wu 2018-07-30 7:25 ` [PATCH 0/2] " Yao, Jiewen 2 siblings, 0 replies; 5+ messages in thread From: Hao Wu @ 2018-07-30 5:37 UTC (permalink / raw) To: edk2-devel; +Cc: Hao Wu, Jiewen Yao Within function SmmMemLibInternalGetUefiMemoryAttributesTable(), add a check to avoid possible null pointer dereference. Cc: Jiewen Yao <jiewen.yao@intel.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Hao Wu <hao.a.wu@intel.com> --- MdePkg/Library/SmmMemLib/SmmMemLib.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MdePkg/Library/SmmMemLib/SmmMemLib.c b/MdePkg/Library/SmmMemLib/SmmMemLib.c index 3409ddf87c..3e458417de 100644 --- a/MdePkg/Library/SmmMemLib/SmmMemLib.c +++ b/MdePkg/Library/SmmMemLib/SmmMemLib.c @@ -439,7 +439,7 @@ SmmMemLibInternalGetUefiMemoryAttributesTable ( UINTN MemoryAttributesTableSize; Status = EfiGetSystemConfigurationTable (&gEfiMemoryAttributesTableGuid, (VOID **)&MemoryAttributesTable); - if (!EFI_ERROR (Status)) { + if (!(EFI_ERROR (Status) || (MemoryAttributesTable == NULL))) { MemoryAttributesTableSize = sizeof(EFI_MEMORY_ATTRIBUTES_TABLE) + MemoryAttributesTable->DescriptorSize * MemoryAttributesTable->NumberOfEntries; mSmmMemLibMemoryAttributesTable = AllocateCopyPool (MemoryAttributesTableSize, MemoryAttributesTable); ASSERT (mSmmMemLibMemoryAttributesTable != NULL); -- 2.12.0.windows.1 ^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 2/2] UefiCpuPkg/PiSmmCpuDxeSmm: Avoid possible NULL ptr dereference 2018-07-30 5:37 [PATCH 0/2] Avoid possible NULL ptr dereference Hao Wu 2018-07-30 5:37 ` [PATCH 1/2] MdePkg/SmmMemLib: " Hao Wu @ 2018-07-30 5:37 ` Hao Wu 2018-07-30 7:25 ` [PATCH 0/2] " Yao, Jiewen 2 siblings, 0 replies; 5+ messages in thread From: Hao Wu @ 2018-07-30 5:37 UTC (permalink / raw) To: edk2-devel; +Cc: Hao Wu, Jiewen Yao Within function GetUefiMemoryAttributesTable(), add a check to avoid possible null pointer dereference. Cc: Jiewen Yao <jiewen.yao@intel.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Hao Wu <hao.a.wu@intel.com> --- UefiCpuPkg/PiSmmCpuDxeSmm/SmmCpuMemoryManagement.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/SmmCpuMemoryManagement.c b/UefiCpuPkg/PiSmmCpuDxeSmm/SmmCpuMemoryManagement.c index 7d99f23426..bae2423de8 100644 --- a/UefiCpuPkg/PiSmmCpuDxeSmm/SmmCpuMemoryManagement.c +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/SmmCpuMemoryManagement.c @@ -1098,7 +1098,7 @@ GetUefiMemoryAttributesTable ( UINTN MemoryAttributesTableSize; Status = EfiGetSystemConfigurationTable (&gEfiMemoryAttributesTableGuid, (VOID **)&MemoryAttributesTable); - if (!EFI_ERROR (Status)) { + if (!(EFI_ERROR (Status) || (MemoryAttributesTable == NULL))) { MemoryAttributesTableSize = sizeof(EFI_MEMORY_ATTRIBUTES_TABLE) + MemoryAttributesTable->DescriptorSize * MemoryAttributesTable->NumberOfEntries; mUefiMemoryAttributesTable = AllocateCopyPool (MemoryAttributesTableSize, MemoryAttributesTable); ASSERT (mUefiMemoryAttributesTable != NULL); -- 2.12.0.windows.1 ^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 0/2] Avoid possible NULL ptr dereference 2018-07-30 5:37 [PATCH 0/2] Avoid possible NULL ptr dereference Hao Wu 2018-07-30 5:37 ` [PATCH 1/2] MdePkg/SmmMemLib: " Hao Wu 2018-07-30 5:37 ` [PATCH 2/2] UefiCpuPkg/PiSmmCpuDxeSmm: " Hao Wu @ 2018-07-30 7:25 ` Yao, Jiewen 2018-07-30 7:25 ` Wu, Hao A 2 siblings, 1 reply; 5+ messages in thread From: Yao, Jiewen @ 2018-07-30 7:25 UTC (permalink / raw) To: Wu, Hao A, edk2-devel@lists.01.org; +Cc: Yao, Jiewen Seems good. It might be better to use "if (!EFI_ERROR (Status) && (MemoryAttributesTable != NULL)) {" Reviewed-by: Jiewen.yao@intel.com > -----Original Message----- > From: Wu, Hao A > Sent: Monday, July 30, 2018 1:37 PM > To: edk2-devel@lists.01.org > Cc: Wu, Hao A <hao.a.wu@intel.com>; Yao, Jiewen <jiewen.yao@intel.com> > Subject: [PATCH 0/2] Avoid possible NULL ptr dereference > > Cc: Jiewen Yao <jiewen.yao@intel.com> > > Hao Wu (2): > MdePkg/SmmMemLib: Avoid possible NULL ptr dereference > UefiCpuPkg/PiSmmCpuDxeSmm: Avoid possible NULL ptr dereference > > MdePkg/Library/SmmMemLib/SmmMemLib.c | 2 +- > UefiCpuPkg/PiSmmCpuDxeSmm/SmmCpuMemoryManagement.c | 2 +- > 2 files changed, 2 insertions(+), 2 deletions(-) > > -- > 2.12.0.windows.1 ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 0/2] Avoid possible NULL ptr dereference 2018-07-30 7:25 ` [PATCH 0/2] " Yao, Jiewen @ 2018-07-30 7:25 ` Wu, Hao A 0 siblings, 0 replies; 5+ messages in thread From: Wu, Hao A @ 2018-07-30 7:25 UTC (permalink / raw) To: Yao, Jiewen, edk2-devel@lists.01.org > -----Original Message----- > From: Yao, Jiewen > Sent: Monday, July 30, 2018 3:25 PM > To: Wu, Hao A; edk2-devel@lists.01.org > Cc: Yao, Jiewen > Subject: RE: [PATCH 0/2] Avoid possible NULL ptr dereference > > Seems good. > > It might be better to use "if (!EFI_ERROR (Status) && > (MemoryAttributesTable != NULL)) {" Yes. I will update the it when pushing the patch. Best Regards, Hao Wu > > Reviewed-by: Jiewen.yao@intel.com > > > > -----Original Message----- > > From: Wu, Hao A > > Sent: Monday, July 30, 2018 1:37 PM > > To: edk2-devel@lists.01.org > > Cc: Wu, Hao A <hao.a.wu@intel.com>; Yao, Jiewen <jiewen.yao@intel.com> > > Subject: [PATCH 0/2] Avoid possible NULL ptr dereference > > > > Cc: Jiewen Yao <jiewen.yao@intel.com> > > > > Hao Wu (2): > > MdePkg/SmmMemLib: Avoid possible NULL ptr dereference > > UefiCpuPkg/PiSmmCpuDxeSmm: Avoid possible NULL ptr dereference > > > > MdePkg/Library/SmmMemLib/SmmMemLib.c | 2 +- > > UefiCpuPkg/PiSmmCpuDxeSmm/SmmCpuMemoryManagement.c | 2 +- > > 2 files changed, 2 insertions(+), 2 deletions(-) > > > > -- > > 2.12.0.windows.1 ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2018-07-30 7:25 UTC | newest] Thread overview: 5+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2018-07-30 5:37 [PATCH 0/2] Avoid possible NULL ptr dereference Hao Wu 2018-07-30 5:37 ` [PATCH 1/2] MdePkg/SmmMemLib: " Hao Wu 2018-07-30 5:37 ` [PATCH 2/2] UefiCpuPkg/PiSmmCpuDxeSmm: " Hao Wu 2018-07-30 7:25 ` [PATCH 0/2] " Yao, Jiewen 2018-07-30 7:25 ` 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