From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from EUR05-VI1-obe.outbound.protection.outlook.com (EUR05-VI1-obe.outbound.protection.outlook.com [40.107.21.80]) by mx.groups.io with SMTP id smtpd.web12.9143.1579518865162700628 for ; Mon, 20 Jan 2020 03:14:25 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@armh.onmicrosoft.com header.s=selector2-armh-onmicrosoft-com header.b=CnjQVZIC; spf=pass (domain: arm.com, ip: 40.107.21.80, mailfrom: krzysztof.koch@arm.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=3u0JgC2XyF16nPB9dJYmF9LmwZ0IPoaPQWb+Y4Juk5k=; b=CnjQVZICQ43elqep3P8SfYCB61mSKyzukKFuJinTa2SN778dxYIzva1jCRiygGKqR7pz3nGGTTab+4212EaoFs7Jw8cacAjrAz5hIernIEOkvio6aS8q7ACxzl8xPa0m9BmdmzK6W/WB6BsMoLxQPr99KQ6bfwbDfEKjeeDYrvc= Received: from DB6PR0802CA0033.eurprd08.prod.outlook.com (2603:10a6:4:a3::19) by AM0PR08MB4403.eurprd08.prod.outlook.com (2603:10a6:208:141::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2644.20; Mon, 20 Jan 2020 11:14:22 +0000 Received: from VE1EUR03FT014.eop-EUR03.prod.protection.outlook.com (2a01:111:f400:7e09::200) by DB6PR0802CA0033.outlook.office365.com (2603:10a6:4:a3::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2644.20 via Frontend Transport; Mon, 20 Jan 2020 11:14:22 +0000 Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; edk2.groups.io; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;edk2.groups.io; dmarc=bestguesspass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 63.35.35.123 as permitted sender) receiver=protection.outlook.com; client-ip=63.35.35.123; helo=64aa7808-outbound-1.mta.getcheckrecipient.com; Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by VE1EUR03FT014.mail.protection.outlook.com (10.152.19.38) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2644.23 via Frontend Transport; Mon, 20 Jan 2020 11:14:21 +0000 Received: ("Tessian outbound 121a58c8f9bf:v40"); Mon, 20 Jan 2020 11:14:21 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: b6d1f01de9b69ad1 X-CR-MTA-TID: 64aa7808 Received: from a50f40eb3028.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 7A4B2899-5BFC-4EB4-BB87-6A3DD55DF901.1; Mon, 20 Jan 2020 11:14:16 +0000 Received: from EUR01-VE1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id a50f40eb3028.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Mon, 20 Jan 2020 11:14:16 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=KFI4IQiRLOFCUVty4FPC/2YSqOocVI2vfOUWJmYJeeMqHo18YWe0h+vjc5ShaOXFEAWzZ9gPyYP/jIrEZQDd1T5y4+SB/l9y2aaXvd71oBqyBJKdkAznv3+LzDi6ftATTEpAqsevBPkfI87AZ+BfAK6GqcRyoBeNYSEa7VYZAU2rgDXldH2Djqdb2Zd5d2mMaIUsRtqwKrLA36XOnaySLBkka6BBumUWg8lK5SeiBteaZENkCnAr7vKqHfDFnQ20rHLs6/BBh9AsYznSiB7BiQ5rzL0GRh54CsSd86XKgtlbdU+OdI0T7d0Y295KA6T63eGb3pJqVGpncNmFJWFlnw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=3u0JgC2XyF16nPB9dJYmF9LmwZ0IPoaPQWb+Y4Juk5k=; b=VMtbxxWfT03eojS384uf6LO0PwYbpoi2K6Dla4quGSSmtW0XNtcJiLebV0rzYkbLooPYG4A+aBWeSZbO93dQAavj19gSiNRbSfEZpDoME/KeSl+r7bIPtb2MvM9sVKv9VDjAZUG9Md8QL0epmv3XsjmzhSVHY1Z1TzJxIeGzggXu4wSOa/3ZWIfo46XlHyxH3fDbznTLQwVx9ESsVt+iFPHQ8OV1spk+5eoP5+564eS3gwNWh/B3HpOTsipNA8xN5hS7y9q5w9WvllZB6S3woIbsLRGjn3jf/y5r5QI/e3lE5AYzueSKg5hmftA56jrhxvfbDkcYggraxJSLGSwgEA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 40.67.248.234) smtp.rcpttodomain=edk2.groups.io smtp.mailfrom=arm.com; dmarc=bestguesspass action=none header.from=arm.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=3u0JgC2XyF16nPB9dJYmF9LmwZ0IPoaPQWb+Y4Juk5k=; b=CnjQVZICQ43elqep3P8SfYCB61mSKyzukKFuJinTa2SN778dxYIzva1jCRiygGKqR7pz3nGGTTab+4212EaoFs7Jw8cacAjrAz5hIernIEOkvio6aS8q7ACxzl8xPa0m9BmdmzK6W/WB6BsMoLxQPr99KQ6bfwbDfEKjeeDYrvc= Received: from DB6PR0801CA0059.eurprd08.prod.outlook.com (2603:10a6:4:2b::27) by VI1PR08MB3149.eurprd08.prod.outlook.com (2603:10a6:803:41::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2644.22; Mon, 20 Jan 2020 11:14:14 +0000 Received: from VE1EUR03FT041.eop-EUR03.prod.protection.outlook.com (2a01:111:f400:7e09::209) by DB6PR0801CA0059.outlook.office365.com (2603:10a6:4:2b::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2644.19 via Frontend Transport; Mon, 20 Jan 2020 11:14:14 +0000 Authentication-Results-Original: spf=pass (sender IP is 40.67.248.234) smtp.mailfrom=arm.com; edk2.groups.io; dkim=none (message not signed) header.d=none;edk2.groups.io; dmarc=bestguesspass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 40.67.248.234 as permitted sender) receiver=protection.outlook.com; client-ip=40.67.248.234; helo=nebula.arm.com; Received: from nebula.arm.com (40.67.248.234) by VE1EUR03FT041.mail.protection.outlook.com (10.152.19.163) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.2644.23 via Frontend Transport; Mon, 20 Jan 2020 11:14:14 +0000 Received: from AZ-NEU-EX04.Arm.com (10.251.24.32) by AZ-NEU-EX04.Arm.com (10.251.24.32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1415.2; Mon, 20 Jan 2020 11:14:05 +0000 Received: from E119924.Arm.com (10.37.9.56) by mail.arm.com (10.251.24.32) with Microsoft SMTP Server id 15.1.1415.2 via Frontend Transport; Mon, 20 Jan 2020 11:14:05 +0000 From: "Krzysztof Koch" To: CC: , , , , Subject: [PATCH v3 03/11] ShellPkg: acpiview: FADT: Validate global pointer before use Date: Mon, 20 Jan 2020 11:13:43 +0000 Message-ID: <20200120111351.29184-4-krzysztof.koch@arm.com> X-Mailer: git-send-email 2.16.2.windows.1 In-Reply-To: <20200120111351.29184-1-krzysztof.koch@arm.com> References: <20200120111351.29184-1-krzysztof.koch@arm.com> MIME-Version: 1.0 X-EOPAttributedMessage: 1 X-MS-Office365-Filtering-HT: Tenant X-Forefront-Antispam-Report-Untrusted: CIP:40.67.248.234;IPV:;CTRY:IE;EFV:NLI;SFV:NSPM;SFS:(10009020)(4636009)(396003)(39860400002)(346002)(376002)(136003)(189003)(199004)(44832011)(81156014)(2616005)(8676002)(81166006)(6666004)(54906003)(26005)(6916009)(15650500001)(356004)(86362001)(1076003)(8936002)(70586007)(70206006)(426003)(4326008)(2906002)(316002)(7696005)(36756003)(5660300002)(336012)(186003)(478600001);DIR:OUT;SFP:1101;SCL:1;SRVR:VI1PR08MB3149;H:nebula.arm.com;FPR:;SPF:Pass;LANG:en;PTR:InfoDomainNonexistent;MX:1;A:1; X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 750f90f3-3f12-4bde-5721-08d79d99e6a1 X-MS-TrafficTypeDiagnostic: VI1PR08MB3149:|AM0PR08MB4403: X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: True X-MS-Oob-TLC-OOBClassifiers: OLM:8882;OLM:8882; X-Forefront-PRVS: 0288CD37D9 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: nZpCW+stuEHAbDk30h5E7K9VN9Yee2k9qF9/sCUtS0j0zpCVJOsLOF6QKZLfS0cfpcNWZYQrYh+NR0m4w7Vkcr144dQXNUsPjfuLfM32ct77zcRJnVFHKabFG6aPLDBtjo0zpXR4vDoXAkmQbBL4pvLwgY/TLSMCNyjtKcYgT5GnwJvbX7M7a0tmHpOc5jK75PkdLndNI0W8tJmcQYSxX6CszA/or7UDLDveBaQvVT4CVspST7X7tP37cmB1Q5WSnJPE0tVJn1Qay5AyOd+j6kGcWsF3K7dwfajkY2ZMHsTf/nXIVfn9LbrlBibGCgDxz75EACvTmaU97uFxaSyedPN2jIYaJMsCthX4CRhtYT2tfnSW+6yUvhdcQkg5k1s6wmRm6D/8aWERd7dHV9K73m1hzMTA8q+EFkwKVrX4grc+QygZNQPcwrrGbBaqOdlD X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR08MB3149 Original-Authentication-Results: spf=pass (sender IP is 40.67.248.234) smtp.mailfrom=arm.com; edk2.groups.io; dkim=none (message not signed) header.d=none;edk2.groups.io; dmarc=bestguesspass action=none header.from=arm.com; Return-Path: Krzysztof.Koch@arm.com X-MS-Exchange-Transport-CrossTenantHeadersStripped: VE1EUR03FT014.eop-EUR03.prod.protection.outlook.com X-Forefront-Antispam-Report: CIP:63.35.35.123;IPV:CAL;SCL:-1;CTRY:IE;EFV:NLI;SFV:NSPM;SFS:(10009020)(4636009)(396003)(39860400002)(136003)(346002)(376002)(199004)(189003)(336012)(26826003)(54906003)(8936002)(81166006)(81156014)(478600001)(15650500001)(26005)(2616005)(186003)(8676002)(4326008)(5660300002)(316002)(2906002)(36906005)(426003)(6916009)(44832011)(70206006)(1076003)(70586007)(6666004)(7696005)(86362001)(36756003);DIR:OUT;SFP:1101;SCL:1;SRVR:AM0PR08MB4403;H:64aa7808-outbound-1.mta.getcheckrecipient.com;FPR:;SPF:Pass;LANG:en;PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com;A:1;MX:1; X-MS-Office365-Filtering-Correlation-Id-Prvs: 6cef91a2-f3ee-4c10-4ff7-08d79d99e1e6 X-Forefront-PRVS: 0288CD37D9 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: VPgaHmoMxoDvOCRU9UNOwrUxkeMnR2Z13vGNzSAdCr8lPoQSJt0LND2ExAvubXjli/OXo65x+cesgNmsjKrn1zfUuxecLet5SYAkjqx5HXsBjUX6XIgnFuIhcflhxwCIhWBvtxjmNB+0OvCXvcDlUICFG++E/yR6avDyeaILpoEGeuoY6tzlQZB540RYxT2XTgCJjnu8n6MzfCqmOZohez0iSxulSPS2LUX7AYe4Q2Cu9mVJfmo8iWC7Y2GxqkTEa3jeVCoH2bsVyQSn3Fx8ARssHNhU08fJI+xUsKlDFeQKqgXYlg2/gHgKVjW/fHvPKG8O0Yp5wDNX+vyDYF5yRWpTXDxaAI2gtggVSgo9X8anpMo0SR51UU7SHj3x7R9Av48KNfH0pCh7MallzGfKL1Qox6bbUjj4Tcp13no7BAu/78pOrP6H5a5udoXU/5Ak X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Jan 2020 11:14:21.9994 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 750f90f3-3f12-4bde-5721-08d79d99e6a1 X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d;Ip=[63.35.35.123];Helo=[64aa7808-outbound-1.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR08MB4403 Content-Type: text/plain Check if global pointers have been successfully updated before they are used for further table parsing. Signed-off-by: Krzysztof Koch --- 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)'