From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: mx.groups.io; dkim=pass header.i=@armh.onmicrosoft.com header.s=selector2-armh-onmicrosoft-com header.b=XbYZehuZ; spf=pass (domain: arm.com, ip: 40.107.7.88, mailfrom: krzysztof.koch@arm.com) Received: from EUR04-HE1-obe.outbound.protection.outlook.com (EUR04-HE1-obe.outbound.protection.outlook.com [40.107.7.88]) by groups.io with SMTP; Thu, 15 Aug 2019 06:12:52 -0700 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=VqAlIC/1IGwx1cXcc2S/FLOVaPQ1PkoTiWlhhHcFiW4=; b=XbYZehuZYTnUPO0dpHVgdhao2c1Y76+K0Y112645znjsSp/BQuG8pJEAW0d+GiIJp4vBEtq5YasAO3YzEfUGrtDP+wrPIzk22KYB7FeEN9WNR4CndIhoFRqF0Gk3bkjoHTMKuh6/16313FQcL8WNbWW2peUSy970fu2YeO//N4Y= Received: from AM6PR08CA0007.eurprd08.prod.outlook.com (2603:10a6:20b:b2::19) by AM0PR08MB4947.eurprd08.prod.outlook.com (2603:10a6:208:158::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2157.14; Thu, 15 Aug 2019 13:12:47 +0000 Received: from DB5EUR03FT063.eop-EUR03.prod.protection.outlook.com (2a01:111:f400:7e0a::201) by AM6PR08CA0007.outlook.office365.com (2603:10a6:20b:b2::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.2178.16 via Frontend Transport; Thu, 15 Aug 2019 13:12:47 +0000 Authentication-Results: spf=temperror (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=temperror action=none header.from=arm.com; Received-SPF: TempError (protection.outlook.com: error in processing during lookup of arm.com: DNS Timeout) Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by DB5EUR03FT063.mail.protection.outlook.com (10.152.20.209) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.2178.16 via Frontend Transport; Thu, 15 Aug 2019 13:12:46 +0000 Received: ("Tessian outbound 578a71fe5eaa:v26"); Thu, 15 Aug 2019 13:12:46 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 9baf9d9fb2501d66 X-CR-MTA-TID: 64aa7808 Received: from 93fe70c3e9ba.1 (cr-mta-lb-1.cr-mta-net [104.47.14.50]) by 64aa7808-outbound-1.mta.getcheckrecipient.com id DBA61EFC-CCE9-4664-A343-29D0751C469E.1; Thu, 15 Aug 2019 13:12:40 +0000 Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-vi1eur04lp2050.outbound.protection.outlook.com [104.47.14.50]) by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 93fe70c3e9ba.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Thu, 15 Aug 2019 13:12:40 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bTh9ecbwO6EFF/ZzLBQvb7HvQ3ShXjPevbQoiNSTxk+xfGh2H7YkFr7fFdheTMa6B26OUs/teF8UoxcGgV3zU8gbc0sv0VkQFzSkqOdoHKqv00hn4xjDMbvr82qbO1etZmUO7y/wkT6c0BdcIdhqT/fjblIW9hABVzS2Q0c4TKzVj+BslJK+fxMhO+RQ+ZD/MpL//2QJy6v7Urq6+ZcStAZ/+c0+QiUs7Ir6O4GKQIoeEMbY85mou1sByVyW4VODs6d3n2UW8xYcSg4Ak6eYmBLW5HHR0e2uVpzULcG9WQX/Yzd8dQF+UEid3gChu9T6R/HZrLHf+SL10XpNJICX6g== 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=VqAlIC/1IGwx1cXcc2S/FLOVaPQ1PkoTiWlhhHcFiW4=; b=Zntp/LhsrXjq+u4onNCkBr4lon9AQ2Q7C1kKKCyclkluqgrgbD91mx9UB1E0gTX6iiK97o5lgj5Mhigyf2b/q161FtJzXVzKj9IQGeZhAn/BmcrrUXYQqKmthAg/JU6bLkLs/Ydd5OpK7iasv/f9TlswgGs8NS+tr8kpM3B+Lf7uws1/VoSvt2617sNcPb7CrhjYkxgR7e69cU7oaMIESJOS4qoCfqdJopQsnfZeD75qoXf8gT6h2kzPHqfLVFq6OUYI0RI1o/Fh22hAmAlwJ3G/LrIS0yKn8YOjWLjXq067iaLdy8EL9gE9rD61/uxpLM49Oh9aCCok2vifDfhUkg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=temperror (sender ip is 40.67.248.234) smtp.rcpttodomain=edk2.groups.io smtp.mailfrom=arm.com; dmarc=temperror 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=VqAlIC/1IGwx1cXcc2S/FLOVaPQ1PkoTiWlhhHcFiW4=; b=XbYZehuZYTnUPO0dpHVgdhao2c1Y76+K0Y112645znjsSp/BQuG8pJEAW0d+GiIJp4vBEtq5YasAO3YzEfUGrtDP+wrPIzk22KYB7FeEN9WNR4CndIhoFRqF0Gk3bkjoHTMKuh6/16313FQcL8WNbWW2peUSy970fu2YeO//N4Y= Received: from HE1PR0802CA0024.eurprd08.prod.outlook.com (10.172.123.162) by AM5PR0802MB2596.eurprd08.prod.outlook.com (10.175.41.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2157.20; Thu, 15 Aug 2019 13:12:38 +0000 Received: from DB5EUR03FT027.eop-EUR03.prod.protection.outlook.com (2a01:111:f400:7e0a::204) by HE1PR0802CA0024.outlook.office365.com (2603:10a6:3:bd::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.2157.15 via Frontend Transport; Thu, 15 Aug 2019 13:12:37 +0000 Authentication-Results-Original: spf=temperror (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=temperror action=none header.from=arm.com; Received-SPF: TempError (protection.outlook.com: error in processing during lookup of arm.com: DNS Timeout) Received: from nebula.arm.com (40.67.248.234) by DB5EUR03FT027.mail.protection.outlook.com (10.152.20.121) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.20.2178.16 via Frontend Transport; Thu, 15 Aug 2019 13:12:36 +0000 Received: from AZ-NEU-EX04.Arm.com (10.251.24.32) by AZ-NEU-EX03.Arm.com (10.251.24.31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1415.2; Thu, 15 Aug 2019 13:11:37 +0000 Received: from E119924.Arm.com (10.1.199.124) by mail.arm.com (10.251.24.32) with Microsoft SMTP Server id 15.1.1415.2 via Frontend Transport; Thu, 15 Aug 2019 13:11:37 +0000 From: "Krzysztof Koch" To: CC: , , , , , Subject: [PATCH v1 10/11] ShellPkg: acpiview: GTDT: Validate global pointers before use Date: Thu, 15 Aug 2019 14:11:20 +0100 Message-ID: <20190815131121.52644-11-krzysztof.koch@arm.com> X-Mailer: git-send-email 2.16.2.windows.1 In-Reply-To: <20190815131121.52644-1-krzysztof.koch@arm.com> References: <20190815131121.52644-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:NLI;CTRY:IE;EFV:NLI;SFV:NSPM;SFS:(10009020)(4636009)(39860400002)(346002)(396003)(376002)(136003)(2980300002)(199004)(189003)(54906003)(336012)(53936002)(81156014)(476003)(186003)(36756003)(126002)(2616005)(426003)(81166006)(76176011)(486006)(446003)(63370400001)(47776003)(7696005)(11346002)(26005)(15650500001)(5660300002)(8676002)(1076003)(51416003)(2906002)(305945005)(70206006)(8936002)(4326008)(478600001)(6916009)(53416004)(316002)(86362001)(70586007)(63350400001)(44832011)(50466002)(48376002)(6666004)(50226002)(2351001)(16586007)(356004);DIR:OUT;SFP:1101;SCL:1;SRVR:AM5PR0802MB2596;H:nebula.arm.com;FPR:;SPF:TempError;LANG:en;PTR:InfoDomainNonexistent;A:1;MX:1; X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 91b729d4-03b0-4329-5060-08d7218243ec X-Microsoft-Antispam-Untrusted: BCL:0;PCL:0;RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600148)(711020)(4605104)(1401327)(2017052603328);SRVR:AM5PR0802MB2596; X-MS-TrafficTypeDiagnostic: AM5PR0802MB2596:|AM0PR08MB4947: X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true X-MS-Oob-TLC-OOBClassifiers: OLM:6108;OLM:6108; X-Forefront-PRVS: 01304918F3 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Message-Info-Original: eiotX4n8zG/9nUS8NoGUdZtU/5YlJACEj+VdAoKfX75c/7UR0KuUvowxd070Uu5OGDpJ/m7NEM4e2Mv1zMYJtRCd66D7Lu59SaTk7bac7+9DGlUbSuAqMS05Rxq7WmNGiQF0rBSKf6EsszkX64KY0e8dypSyExt7oeGgqgwebmQX8ZX3Ew7+jAtCbJqa/JEzbybDquGSBHXgbUM5ZQvtgVCWVZmAsgKP7I6XpPsOHjAnKZr4oSHYg/AlDdkb2jBN6+9v2mGgBIUhF+Dzepf+ErlWft9syMFRRF4TmR0DBVpQqlhE5P4dtNw0ZVfqq/vtlw5vPIDDe0yvFS6xdNb/+AET0+1DUWebIOqqdm+bAbv3uDaHXWBnoqaYmXMtYiUrz92gyX24dOCaxyg2yf1ttLnAP4XnHJL4hqpWdKgekp4= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM5PR0802MB2596 Original-Authentication-Results: spf=temperror (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=temperror action=none header.from=arm.com; Return-Path: Krzysztof.Koch@arm.com X-MS-Exchange-Transport-CrossTenantHeadersStripped: DB5EUR03FT063.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)(136003)(346002)(396003)(376002)(39860400002)(2980300002)(189003)(199004)(76130400001)(486006)(476003)(186003)(446003)(305945005)(63370400001)(8676002)(126002)(26005)(1076003)(426003)(4326008)(26826003)(47776003)(336012)(16586007)(53416004)(44832011)(2616005)(11346002)(63350400001)(22756006)(51416003)(7696005)(76176011)(81156014)(478600001)(2351001)(316002)(8936002)(50466002)(81166006)(15650500001)(70586007)(70206006)(2906002)(6916009)(36756003)(86362001)(5660300002)(6666004)(48376002)(54906003)(50226002);DIR:OUT;SFP:1101;SCL:1;SRVR:AM0PR08MB4947;H:64aa7808-outbound-1.mta.getcheckrecipient.com;FPR:;SPF:TempError;LANG:en;PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com;MX:1;A:1; X-MS-Office365-Filtering-Correlation-Id-Prvs: 88960715-134a-481a-ae26-08d721823df2 X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600148)(710020)(711020)(4605104)(1401327)(2017052603328);SRVR:AM0PR08MB4947; NoDisclaimer: True X-Forefront-PRVS: 01304918F3 X-Microsoft-Antispam-Message-Info: FGtgADxbmMexDUSpsou43gTM7nJENMEmvtvjjUOju1Ad2iUniJBUG3Nj/UZV+7c2wKkeoxeY49p/oPCBSEnPxGZATUpo2oCyddpqiN8eNS+C6Y7+6LZnczBb/c9dVz/PiHDidJQRAUIGJwRvOnv8xfauaN1H7sfX821DnGS8SivxNy9GOewbDnfjuh4eWDUfx+pQyHj1FTS2yiDjY3ucQ6yacpNX/+pPXxNs1XnFc7WbeX42fwBEStXp4jCDLwWnSPFh7W258RRUu8bagDbkWRjx9M1dn59LQIZu1U2iuEKCnYCt0n7KGCcmKWegOgljY/ymyWHJptSfhWN0gqmgrdAjKwJoie8/mzzuybs92vr0/rI3xFAca2887Td/fenpxb7jeb+1h5fiSpEn5Jyucwojpl6bn+Bc4PzPoKPmyJE= X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Aug 2019 13:12:46.4519 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 91b729d4-03b0-4329-5060-08d7218243ec 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: AM0PR08MB4947 Content-Type: text/plain Check if global (in the scope of the GTDT parser) pointers have been successfully updated before they are used for further table parsing. Signed-off-by: Krzysztof Koch --- Notes: v1: - Test against NULL pointers [Krzysztof] ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Gtdt/GtdtParser.c | 37 ++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Gtdt/GtdtParser.c b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Gtdt/GtdtParser.c index 57174e14c80072f12b90e1996ebe8f0002d0c404..699a55b549ec3fa61bbd156898821055dc019199 100644 --- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Gtdt/GtdtParser.c +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Gtdt/GtdtParser.c @@ -189,6 +189,18 @@ DumpGTBlock ( PARSER_PARAMS (GtBlockParser) ); + // Check if the values used to control the parsing logic have been + // successfully read. + if ((GtBlockTimerCount == NULL) || + (GtBlockTimerOffset == NULL)) { + IncrementErrorCount (); + Print ( + L"ERROR: Insufficient GT Block Structure length. Length = %d.\n", + Length + ); + return; + } + Offset = *GtBlockTimerOffset; Index = 0; @@ -272,6 +284,18 @@ ParseAcpiGtdt ( PARSER_PARAMS (GtdtParser) ); + // Check if the values used to control the parsing logic have been + // successfully read. + if ((GtdtPlatformTimerCount == NULL) || + (GtdtPlatformTimerOffset == NULL)) { + IncrementErrorCount (); + Print ( + L"ERROR: Insufficient table length. AcpiTableLength = %d.\n", + AcpiTableLength + ); + return; + } + TimerPtr = Ptr + *GtdtPlatformTimerOffset; Offset = *GtdtPlatformTimerOffset; Index = 0; @@ -290,6 +314,19 @@ ParseAcpiGtdt ( PARSER_PARAMS (GtPlatformTimerHeaderParser) ); + // Check if the values used to control the parsing logic have been + // successfully read. + if ((PlatformTimerType == NULL) || + (PlatformTimerLength == NULL)) { + IncrementErrorCount (); + Print ( + L"ERROR: Insufficient remaining table buffer length to read the " \ + L"Platform Timer Structure header. Length = %d.\n", + AcpiTableLength - Offset + ); + return; + } + // Make sure the Platform Timer is inside the table. if ((Offset + *PlatformTimerLength) > AcpiTableLength) { IncrementErrorCount (); -- 'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)'