public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Krzysztof Koch" <krzysztof.koch@arm.com>
To: <devel@edk2.groups.io>
Cc: <ray.ni@intel.com>, <zhichao.gao@intel.com>,
	<Sami.Mujawar@arm.com>, <Matteo.Carlini@arm.com>, <nd@arm.com>
Subject: [PATCH v3 03/11] ShellPkg: acpiview: FADT: Validate global pointer before use
Date: Mon, 20 Jan 2020 11:13:43 +0000	[thread overview]
Message-ID: <20200120111351.29184-4-krzysztof.koch@arm.com> (raw)
In-Reply-To: <20200120111351.29184-1-krzysztof.koch@arm.com>

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>
---

Notes:
    v3:
    - Rebase on latest master [Krzysztof]

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

    v1:
    - Test against NULL pointers [Krzysztof]

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

diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Fadt/FadtParser.c b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Fadt/FadtParser.c
index 5b8cc174f16afb3d4feb6a518952e60c6564ee34..37cbd8be287944656afcd609a3dd080440d5cfef 100644
--- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Fadt/FadtParser.c
+++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Fadt/FadtParser.c
@@ -1,7 +1,7 @@
 /** @file
   FADT table parser
 
-  Copyright (c) 2016 - 2019, ARM Limited. All rights reserved.
+  Copyright (c) 2016 - 2020, ARM Limited. All rights reserved.
   SPDX-License-Identifier: BSD-2-Clause-Patent
 
   @par Reference(s):
@@ -230,9 +230,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 ();
@@ -294,21 +296,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)'



  parent reply	other threads:[~2020-01-20 11:14 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-20 11:13 [PATCH v3 00/11] Test against invalid pointers in acpiview Krzysztof Koch
2020-01-20 11:13 ` [PATCH v3 01/11] ShellPkg: acpiview: Set ItemPtr to NULL for unprocessed table fields Krzysztof Koch
2020-01-20 11:13 ` [PATCH v3 02/11] ShellPkg: acpiview: RSDP: Validate global pointer before use Krzysztof Koch
2020-01-20 11:13 ` Krzysztof Koch [this message]
2020-01-20 11:13 ` [PATCH v3 04/11] ShellPkg: acpiview: SLIT: " Krzysztof Koch
2020-01-20 11:13 ` [PATCH v3 05/11] ShellPkg: acpiview: SLIT: Validate System Locality count Krzysztof Koch
2020-01-20 11:13 ` [PATCH v3 06/11] ShellPkg: acpiview: SRAT: Validate global pointers before use Krzysztof Koch
2020-01-20 11:13 ` [PATCH v3 07/11] ShellPkg: acpiview: MADT: " Krzysztof Koch
2020-01-20 11:13 ` [PATCH v3 08/11] ShellPkg: acpiview: PPTT: " Krzysztof Koch
2020-01-20 11:13 ` [PATCH v3 09/11] ShellPkg: acpiview: IORT: " Krzysztof Koch
2020-01-20 11:13 ` [PATCH v3 10/11] ShellPkg: acpiview: GTDT: " Krzysztof Koch
2020-01-20 11:13 ` [PATCH v3 11/11] ShellPkg: acpiview: DBG2: " Krzysztof Koch
2020-02-03 15:36 ` [PATCH v3 00/11] Test against invalid pointers in acpiview Gao, Zhichao

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200120111351.29184-4-krzysztof.koch@arm.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox