public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [PATCH v2 03/11] ShellPkg: acpiview: FADT: Validate global pointer before use
@ 2019-08-19  8:25 Krzysztof Koch
  2019-08-19  8:53 ` [edk2-devel] " Alexei Fedorov
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Krzysztof Koch @ 2019-08-19  8:25 UTC (permalink / raw)
  To: devel; +Cc: jaben.carsey, ray.ni, zhichao.gao, Sami.Mujawar, Matteo.Carlini,
	nd

Check if global pointers have been successfully updated before they
are used for further table parsing.

Signed-off-by: Krzysztof Koch <krzysztof.koch@arm.com>
---

Changes can be seen at: https://github.com/KrzysztofKoch1/edk2/tree/612_add_pointer_validation_v2

Notes:
    v1:
    - Test against NULL pointers [Krzysztof]

    v2:
    - Do not require FadtMinorRevision and X_DsdtAddress pointers to be
      valid in order to process the remaining ACPI tables [Zhichao]

 ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Fadt/FadtParser.c | 19 ++++++++++---------
 1 file changed, 10 insertions(+), 9 deletions(-)

diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Fadt/FadtParser.c b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Fadt/FadtParser.c
index e40c9ef8ee4b3285faf8c6edf3cb6236ee367397..6859c4824c2866fd3eb9a789a8dfc950724b27ca 100644
--- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Fadt/FadtParser.c
+++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Fadt/FadtParser.c
@@ -204,9 +204,11 @@ ParseAcpiFadt (
     );
 
   if (Trace) {
-    Print (L"\nSummary:\n");
-    PrintFieldName (2, L"FADT Version");
-    Print (L"%d.%d\n",  *AcpiHdrInfo.Revision, *FadtMinorRevision);
+    if (FadtMinorRevision != NULL) {
+      Print (L"\nSummary:\n");
+      PrintFieldName (2, L"FADT Version");
+      Print (L"%d.%d\n",  *AcpiHdrInfo.Revision, *FadtMinorRevision);
+    }
 
     if (*GetAcpiXsdtHeaderInfo ()->OemTableId != *AcpiHdrInfo.OemTableId) {
       IncrementErrorCount ();
@@ -214,21 +216,20 @@ ParseAcpiFadt (
     }
   }
 
-  // If X_DSDT is not zero then use X_DSDT and ignore DSDT,
-  // else use DSDT.
-  if (*X_DsdtAddress != 0) {
+  // If X_DSDT is valid then use X_DSDT and ignore DSDT, else use DSDT.
+  if ((X_DsdtAddress != NULL) && (*X_DsdtAddress != 0)) {
     DsdtPtr = (UINT8*)(UINTN)(*X_DsdtAddress);
-  } else if (*DsdtAddress != 0) {
+  } else if ((DsdtAddress != NULL) && (*DsdtAddress != 0)) {
     DsdtPtr = (UINT8*)(UINTN)(*DsdtAddress);
   } else {
-    // Both DSDT and X_DSDT cannot be zero.
+    // Both DSDT and X_DSDT cannot be invalid.
 #if defined (MDE_CPU_ARM) || defined (MDE_CPU_AARCH64)
     if (Trace) {
       // The DSDT Table is mandatory for ARM systems
       // as the CPU information MUST be presented in
       // the DSDT.
       IncrementErrorCount ();
-      Print (L"ERROR: Both X_DSDT and DSDT are NULL.\n");
+      Print (L"ERROR: Both X_DSDT and DSDT are invalid.\n");
     }
 #endif
     return;
--
'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)'



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

* Re: [edk2-devel] [PATCH v2 03/11] ShellPkg: acpiview: FADT: Validate global pointer before use
  2019-08-19  8:25 [PATCH v2 03/11] ShellPkg: acpiview: FADT: Validate global pointer before use Krzysztof Koch
@ 2019-08-19  8:53 ` Alexei Fedorov
  2019-08-20  9:49 ` Sami Mujawar
  2019-08-21  1:50 ` Gao, Zhichao
  2 siblings, 0 replies; 4+ messages in thread
From: Alexei Fedorov @ 2019-08-19  8:53 UTC (permalink / raw)
  To: Krzysztof Koch, devel

[-- Attachment #1: Type: text/plain, Size: 54 bytes --]

Reviewed-by: Alexei Fedorov <Alexei.Fedorov@arm.com>

[-- Attachment #2: Type: text/html, Size: 60 bytes --]

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

* Re: [PATCH v2 03/11] ShellPkg: acpiview: FADT: Validate global pointer before use
  2019-08-19  8:25 [PATCH v2 03/11] ShellPkg: acpiview: FADT: Validate global pointer before use Krzysztof Koch
  2019-08-19  8:53 ` [edk2-devel] " Alexei Fedorov
@ 2019-08-20  9:49 ` Sami Mujawar
  2019-08-21  1:50 ` Gao, Zhichao
  2 siblings, 0 replies; 4+ messages in thread
From: Sami Mujawar @ 2019-08-20  9:49 UTC (permalink / raw)
  To: Krzysztof Koch, devel@edk2.groups.io
  Cc: jaben.carsey@intel.com, ray.ni@intel.com, zhichao.gao@intel.com,
	Matteo Carlini, nd

Reviewed-by: Sami Mujawar <sami.mujawar@arm.com>

Regards,

Sami Mujawar

-----Original Message-----
From: Krzysztof Koch <krzysztof.koch@arm.com> 
Sent: 19 August 2019 09:25 AM
To: devel@edk2.groups.io
Cc: jaben.carsey@intel.com; ray.ni@intel.com; zhichao.gao@intel.com; Sami Mujawar <Sami.Mujawar@arm.com>; Matteo Carlini <Matteo.Carlini@arm.com>; nd <nd@arm.com>
Subject: [PATCH v2 03/11] ShellPkg: acpiview: FADT: Validate global pointer before use

Check if global pointers have been successfully updated before they are used for further table parsing.

Signed-off-by: Krzysztof Koch <krzysztof.koch@arm.com>
---

Changes can be seen at: https://github.com/KrzysztofKoch1/edk2/tree/612_add_pointer_validation_v2

Notes:
    v1:
    - Test against NULL pointers [Krzysztof]

    v2:
    - Do not require FadtMinorRevision and X_DsdtAddress pointers to be
      valid in order to process the remaining ACPI tables [Zhichao]

 ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Fadt/FadtParser.c | 19 ++++++++++---------
 1 file changed, 10 insertions(+), 9 deletions(-)

diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Fadt/FadtParser.c b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Fadt/FadtParser.c
index e40c9ef8ee4b3285faf8c6edf3cb6236ee367397..6859c4824c2866fd3eb9a789a8dfc950724b27ca 100644
--- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Fadt/FadtParser.c
+++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Fadt/FadtPars
+++ er.c
@@ -204,9 +204,11 @@ ParseAcpiFadt (
     );
 
   if (Trace) {
-    Print (L"\nSummary:\n");
-    PrintFieldName (2, L"FADT Version");
-    Print (L"%d.%d\n",  *AcpiHdrInfo.Revision, *FadtMinorRevision);
+    if (FadtMinorRevision != NULL) {
+      Print (L"\nSummary:\n");
+      PrintFieldName (2, L"FADT Version");
+      Print (L"%d.%d\n",  *AcpiHdrInfo.Revision, *FadtMinorRevision);
+    }
 
     if (*GetAcpiXsdtHeaderInfo ()->OemTableId != *AcpiHdrInfo.OemTableId) {
       IncrementErrorCount ();
@@ -214,21 +216,20 @@ ParseAcpiFadt (
     }
   }
 
-  // If X_DSDT is not zero then use X_DSDT and ignore DSDT,
-  // else use DSDT.
-  if (*X_DsdtAddress != 0) {
+  // If X_DSDT is valid then use X_DSDT and ignore DSDT, else use DSDT.
+  if ((X_DsdtAddress != NULL) && (*X_DsdtAddress != 0)) {
     DsdtPtr = (UINT8*)(UINTN)(*X_DsdtAddress);
-  } else if (*DsdtAddress != 0) {
+  } else if ((DsdtAddress != NULL) && (*DsdtAddress != 0)) {
     DsdtPtr = (UINT8*)(UINTN)(*DsdtAddress);
   } else {
-    // Both DSDT and X_DSDT cannot be zero.
+    // Both DSDT and X_DSDT cannot be invalid.
 #if defined (MDE_CPU_ARM) || defined (MDE_CPU_AARCH64)
     if (Trace) {
       // The DSDT Table is mandatory for ARM systems
       // as the CPU information MUST be presented in
       // the DSDT.
       IncrementErrorCount ();
-      Print (L"ERROR: Both X_DSDT and DSDT are NULL.\n");
+      Print (L"ERROR: Both X_DSDT and DSDT are invalid.\n");
     }
 #endif
     return;
--
'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)'



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

* Re: [PATCH v2 03/11] ShellPkg: acpiview: FADT: Validate global pointer before use
  2019-08-19  8:25 [PATCH v2 03/11] ShellPkg: acpiview: FADT: Validate global pointer before use Krzysztof Koch
  2019-08-19  8:53 ` [edk2-devel] " Alexei Fedorov
  2019-08-20  9:49 ` Sami Mujawar
@ 2019-08-21  1:50 ` Gao, Zhichao
  2 siblings, 0 replies; 4+ messages in thread
From: Gao, Zhichao @ 2019-08-21  1:50 UTC (permalink / raw)
  To: Krzysztof Koch, devel@edk2.groups.io
  Cc: Carsey, Jaben, Ni, Ray, Sami.Mujawar@arm.com,
	Matteo.Carlini@arm.com, nd@arm.com

Reviewed-by: Zhichao Gao <zhichao.gao@intel.com>

Thanks,
Zhichao

> -----Original Message-----
> From: Krzysztof Koch [mailto:krzysztof.koch@arm.com]
> Sent: Monday, August 19, 2019 4:25 PM
> To: devel@edk2.groups.io
> Cc: Carsey, Jaben <jaben.carsey@intel.com>; Ni, Ray <ray.ni@intel.com>;
> Gao, Zhichao <zhichao.gao@intel.com>; Sami.Mujawar@arm.com;
> Matteo.Carlini@arm.com; nd@arm.com
> Subject: [PATCH v2 03/11] ShellPkg: acpiview: FADT: Validate global pointer
> before use
> 
> Check if global pointers have been successfully updated before they are
> used for further table parsing.
> 
> Signed-off-by: Krzysztof Koch <krzysztof.koch@arm.com>
> ---
> 
> Changes can be seen at:
> https://github.com/KrzysztofKoch1/edk2/tree/612_add_pointer_validation_
> v2
> 
> Notes:
>     v1:
>     - Test against NULL pointers [Krzysztof]
> 
>     v2:
>     - Do not require FadtMinorRevision and X_DsdtAddress pointers to be
>       valid in order to process the remaining ACPI tables [Zhichao]
> 
>  ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Fadt/FadtParser.c
> | 19 ++++++++++---------
>  1 file changed, 10 insertions(+), 9 deletions(-)
> 
> diff --git
> a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Fadt/FadtParser.
> c
> b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Fadt/FadtParser.
> c
> index
> e40c9ef8ee4b3285faf8c6edf3cb6236ee367397..6859c4824c2866fd3eb9a789a8
> dfc950724b27ca 100644
> ---
> a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Fadt/FadtParser.
> c
> +++
> b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Fadt/FadtPars
> +++ er.c
> @@ -204,9 +204,11 @@ ParseAcpiFadt (
>      );
> 
>    if (Trace) {
> -    Print (L"\nSummary:\n");
> -    PrintFieldName (2, L"FADT Version");
> -    Print (L"%d.%d\n",  *AcpiHdrInfo.Revision, *FadtMinorRevision);
> +    if (FadtMinorRevision != NULL) {
> +      Print (L"\nSummary:\n");
> +      PrintFieldName (2, L"FADT Version");
> +      Print (L"%d.%d\n",  *AcpiHdrInfo.Revision, *FadtMinorRevision);
> +    }
> 
>      if (*GetAcpiXsdtHeaderInfo ()->OemTableId != *AcpiHdrInfo.OemTableId)
> {
>        IncrementErrorCount ();
> @@ -214,21 +216,20 @@ ParseAcpiFadt (
>      }
>    }
> 
> -  // If X_DSDT is not zero then use X_DSDT and ignore DSDT,
> -  // else use DSDT.
> -  if (*X_DsdtAddress != 0) {
> +  // If X_DSDT is valid then use X_DSDT and ignore DSDT, else use DSDT.
> +  if ((X_DsdtAddress != NULL) && (*X_DsdtAddress != 0)) {
>      DsdtPtr = (UINT8*)(UINTN)(*X_DsdtAddress);
> -  } else if (*DsdtAddress != 0) {
> +  } else if ((DsdtAddress != NULL) && (*DsdtAddress != 0)) {
>      DsdtPtr = (UINT8*)(UINTN)(*DsdtAddress);
>    } else {
> -    // Both DSDT and X_DSDT cannot be zero.
> +    // Both DSDT and X_DSDT cannot be invalid.
>  #if defined (MDE_CPU_ARM) || defined (MDE_CPU_AARCH64)
>      if (Trace) {
>        // The DSDT Table is mandatory for ARM systems
>        // as the CPU information MUST be presented in
>        // the DSDT.
>        IncrementErrorCount ();
> -      Print (L"ERROR: Both X_DSDT and DSDT are NULL.\n");
> +      Print (L"ERROR: Both X_DSDT and DSDT are invalid.\n");
>      }
>  #endif
>      return;
> --
> 'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)'
> 


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

end of thread, other threads:[~2019-08-21  1:50 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-08-19  8:25 [PATCH v2 03/11] ShellPkg: acpiview: FADT: Validate global pointer before use Krzysztof Koch
2019-08-19  8:53 ` [edk2-devel] " Alexei Fedorov
2019-08-20  9:49 ` Sami Mujawar
2019-08-21  1:50 ` Gao, Zhichao

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