public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [PATCH] IntelFsp2Pkg: Fixed potentially NULL pointer accessing
@ 2018-10-26  7:25 Chasel, Chiu
  2018-10-26 14:23 ` Yao, Jiewen
  0 siblings, 1 reply; 3+ messages in thread
From: Chasel, Chiu @ 2018-10-26  7:25 UTC (permalink / raw)
  To: edk2-devel; +Cc: Jiewen Yao, Desimone Nathaniel L, Chasel Chiu

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1280

When copying IDT table in SecMain, the pointer might be
NULL so added the check to fix it.

Test: Verified on internal platform and boots successfully.

Cc: Jiewen Yao <Jiewen.yao@intel.com>
Cc: Desimone Nathaniel L <nathaniel.l.desimone@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Chasel Chiu <chasel.chiu@intel.com>
---
 IntelFsp2Pkg/FspSecCore/SecMain.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/IntelFsp2Pkg/FspSecCore/SecMain.c b/IntelFsp2Pkg/FspSecCore/SecMain.c
index f319c68cc5..aed8893ff0 100644
--- a/IntelFsp2Pkg/FspSecCore/SecMain.c
+++ b/IntelFsp2Pkg/FspSecCore/SecMain.c
@@ -113,8 +113,14 @@ SecStartup (
       // ERROR: IDT table size from boot loader is larger than FSP can support, DeadLoop here!
       //
       CpuDeadLoop();
+    } else if (IdtDescriptor.Base == 0)  {
+      //
+      // ERROR: IDT table Base should not be zero, DeadLoop here!
+      //
+      CpuDeadLoop();
+    } else {
+      CopyMem ((VOID *) (UINTN) &IdtTableInStack.IdtTable, (VOID *) IdtDescriptor.Base, IdtSize);
     }
-    CopyMem ((VOID *) (UINTN) &IdtTableInStack.IdtTable, (VOID *) IdtDescriptor.Base, IdtSize);
   }
   IdtDescriptor.Base  = (UINTN) &IdtTableInStack.IdtTable;
   IdtDescriptor.Limit = (UINT16)(IdtSize - 1);
-- 
2.13.3.windows.1



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

* Re: [PATCH] IntelFsp2Pkg: Fixed potentially NULL pointer accessing
  2018-10-26  7:25 [PATCH] IntelFsp2Pkg: Fixed potentially NULL pointer accessing Chasel, Chiu
@ 2018-10-26 14:23 ` Yao, Jiewen
  2018-10-29  1:11   ` Chiu, Chasel
  0 siblings, 1 reply; 3+ messages in thread
From: Yao, Jiewen @ 2018-10-26 14:23 UTC (permalink / raw)
  To: Chiu, Chasel, edk2-devel@lists.01.org

Hi Chasel
Can we change "  if ((IdtDescriptor.Base == 0) && (IdtDescriptor.Limit == 0xFFFF)) {" to "  if (IdtDescriptor.Base == 0) {" ?

That can simplify the logic.

Thank you
Yao Jiewen

> -----Original Message-----
> From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of
> Chasel, Chiu
> Sent: Friday, October 26, 2018 3:25 PM
> To: edk2-devel@lists.01.org
> Cc: Yao, Jiewen <jiewen.yao@intel.com>
> Subject: [edk2] [PATCH] IntelFsp2Pkg: Fixed potentially NULL pointer
> accessing
> 
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1280
> 
> When copying IDT table in SecMain, the pointer might be
> NULL so added the check to fix it.
> 
> Test: Verified on internal platform and boots successfully.
> 
> Cc: Jiewen Yao <Jiewen.yao@intel.com>
> Cc: Desimone Nathaniel L <nathaniel.l.desimone@intel.com>
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Chasel Chiu <chasel.chiu@intel.com>
> ---
>  IntelFsp2Pkg/FspSecCore/SecMain.c | 8 +++++++-
>  1 file changed, 7 insertions(+), 1 deletion(-)
> 
> diff --git a/IntelFsp2Pkg/FspSecCore/SecMain.c
> b/IntelFsp2Pkg/FspSecCore/SecMain.c
> index f319c68cc5..aed8893ff0 100644
> --- a/IntelFsp2Pkg/FspSecCore/SecMain.c
> +++ b/IntelFsp2Pkg/FspSecCore/SecMain.c
> @@ -113,8 +113,14 @@ SecStartup (
>        // ERROR: IDT table size from boot loader is larger than FSP can
> support, DeadLoop here!
>        //
>        CpuDeadLoop();
> +    } else if (IdtDescriptor.Base == 0)  {
> +      //
> +      // ERROR: IDT table Base should not be zero, DeadLoop here!
> +      //
> +      CpuDeadLoop();
> +    } else {
> +      CopyMem ((VOID *) (UINTN) &IdtTableInStack.IdtTable, (VOID *)
> IdtDescriptor.Base, IdtSize);
>      }
> -    CopyMem ((VOID *) (UINTN) &IdtTableInStack.IdtTable, (VOID *)
> IdtDescriptor.Base, IdtSize);
>    }
>    IdtDescriptor.Base  = (UINTN) &IdtTableInStack.IdtTable;
>    IdtDescriptor.Limit = (UINT16)(IdtSize - 1);
> --
> 2.13.3.windows.1
> 
> _______________________________________________
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel


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

* Re: [PATCH] IntelFsp2Pkg: Fixed potentially NULL pointer accessing
  2018-10-26 14:23 ` Yao, Jiewen
@ 2018-10-29  1:11   ` Chiu, Chasel
  0 siblings, 0 replies; 3+ messages in thread
From: Chiu, Chasel @ 2018-10-29  1:11 UTC (permalink / raw)
  To: Yao, Jiewen, edk2-devel@lists.01.org


Yes. We can do that. I will send patch V2 soon.

Thanks!
Chasel


-----Original Message-----
From: Yao, Jiewen 
Sent: Friday, October 26, 2018 10:24 PM
To: Chiu, Chasel <chasel.chiu@intel.com>; edk2-devel@lists.01.org
Subject: RE: [edk2] [PATCH] IntelFsp2Pkg: Fixed potentially NULL pointer accessing

Hi Chasel
Can we change "  if ((IdtDescriptor.Base == 0) && (IdtDescriptor.Limit == 0xFFFF)) {" to "  if (IdtDescriptor.Base == 0) {" ?

That can simplify the logic.

Thank you
Yao Jiewen

> -----Original Message-----
> From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of 
> Chasel, Chiu
> Sent: Friday, October 26, 2018 3:25 PM
> To: edk2-devel@lists.01.org
> Cc: Yao, Jiewen <jiewen.yao@intel.com>
> Subject: [edk2] [PATCH] IntelFsp2Pkg: Fixed potentially NULL pointer 
> accessing
> 
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1280
> 
> When copying IDT table in SecMain, the pointer might be NULL so added 
> the check to fix it.
> 
> Test: Verified on internal platform and boots successfully.
> 
> Cc: Jiewen Yao <Jiewen.yao@intel.com>
> Cc: Desimone Nathaniel L <nathaniel.l.desimone@intel.com>
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Chasel Chiu <chasel.chiu@intel.com>
> ---
>  IntelFsp2Pkg/FspSecCore/SecMain.c | 8 +++++++-
>  1 file changed, 7 insertions(+), 1 deletion(-)
> 
> diff --git a/IntelFsp2Pkg/FspSecCore/SecMain.c
> b/IntelFsp2Pkg/FspSecCore/SecMain.c
> index f319c68cc5..aed8893ff0 100644
> --- a/IntelFsp2Pkg/FspSecCore/SecMain.c
> +++ b/IntelFsp2Pkg/FspSecCore/SecMain.c
> @@ -113,8 +113,14 @@ SecStartup (
>        // ERROR: IDT table size from boot loader is larger than FSP 
> can support, DeadLoop here!
>        //
>        CpuDeadLoop();
> +    } else if (IdtDescriptor.Base == 0)  {
> +      //
> +      // ERROR: IDT table Base should not be zero, DeadLoop here!
> +      //
> +      CpuDeadLoop();
> +    } else {
> +      CopyMem ((VOID *) (UINTN) &IdtTableInStack.IdtTable, (VOID *)
> IdtDescriptor.Base, IdtSize);
>      }
> -    CopyMem ((VOID *) (UINTN) &IdtTableInStack.IdtTable, (VOID *)
> IdtDescriptor.Base, IdtSize);
>    }
>    IdtDescriptor.Base  = (UINTN) &IdtTableInStack.IdtTable;
>    IdtDescriptor.Limit = (UINT16)(IdtSize - 1);
> --
> 2.13.3.windows.1
> 
> _______________________________________________
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel


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

end of thread, other threads:[~2018-10-29  1:11 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-10-26  7:25 [PATCH] IntelFsp2Pkg: Fixed potentially NULL pointer accessing Chasel, Chiu
2018-10-26 14:23 ` Yao, Jiewen
2018-10-29  1:11   ` Chiu, Chasel

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