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=nGnlzzkc; spf=pass (domain: arm.com, ip: 40.107.2.77, mailfrom: krzysztof.koch@arm.com) Received: from EUR02-VE1-obe.outbound.protection.outlook.com (EUR02-VE1-obe.outbound.protection.outlook.com [40.107.2.77]) by groups.io with SMTP; Thu, 15 Aug 2019 06:11:53 -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=jtyku9voDYV1hI8bcELUB9agfFb1SDE1DC5fLERk9p4=; b=nGnlzzkcpXZj68aEDd0iz8g1bcCehaz3+eM2PvhdIb8D+hUTlUTowdJmbQ/m9o8KuCJgBPc58EyJy4Dy7yREmJai7SZfeageRxUghiTLHJYjkV1076CCYXOLI2YV3IKO66JxHQVzAaPzEXzShuFIvItX+p/I6o5uJdXMVwkwwrI= Received: from VI1PR08CA0240.eurprd08.prod.outlook.com (2603:10a6:802:15::49) by HE1PR0801MB1850.eurprd08.prod.outlook.com (2603:10a6:3:86::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2157.21; Thu, 15 Aug 2019 13:11:48 +0000 Received: from AM5EUR03FT063.eop-EUR03.prod.protection.outlook.com (2a01:111:f400:7e08::204) by VI1PR08CA0240.outlook.office365.com (2603:10a6:802:15::49) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2157.18 via Frontend Transport; Thu, 15 Aug 2019 13:11:48 +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 AM5EUR03FT063.mail.protection.outlook.com (10.152.16.226) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2178.16 via Frontend Transport; Thu, 15 Aug 2019 13:11:46 +0000 Received: ("Tessian outbound 578a71fe5eaa:v26"); Thu, 15 Aug 2019 13:11:46 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 6c1cc06f189ac37b X-CR-MTA-TID: 64aa7808 Received: from 0fcc14642e66.1 (cr-mta-lb-1.cr-mta-net [104.47.10.53]) by 64aa7808-outbound-1.mta.getcheckrecipient.com id AC427455-89D1-4622-8F42-D77E89A0FD90.1; Thu, 15 Aug 2019 13:11:40 +0000 Received: from EUR03-DB5-obe.outbound.protection.outlook.com (mail-db5eur03lp2053.outbound.protection.outlook.com [104.47.10.53]) by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 0fcc14642e66.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384); Thu, 15 Aug 2019 13:11:40 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Rbhp7Tg0DDN15b09SlkriBVkDwSOk6cThRlHCzQ1OxdSFeObESQMhTmqPyB0va73W5U2qMrP88jLd9P52DR4/WyjIxwu97BnDg5oPB1WKPdn+BLCnSaBokG8WdzJQezVIcXv/75cD5GUBY1QomFnFTmBTul0Mvx8oUdcwH9ADp4tYYLURjd49xsFHIZMFfWgDgPSv8KV5LDtqiVdPjbEPm+M8TEVn13otBlVH84sEKt99Cp7mdcZ9fooXhDNWaEjM4Iv+UmhSTTJVcNPUq/VKoErXIaLyDlcedyX24YY6puzlBCr0eDIPHGOVKKxZjx9TyAQuUm6E8Qf2PyseYqLuA== 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=jtyku9voDYV1hI8bcELUB9agfFb1SDE1DC5fLERk9p4=; b=le5rOLgQLOELPnO0/fOQTpDOCibbtHy5e0cdQnwZBUy0w4iOV2mSMJerAxn+U/UZMA55QpfAimRk+hl9F+VpBvViVhRmPai/fKIv+kPgQmrbQBR+TUPZq7mZFUVdyX2DaRoHnjTsYplgXsUhNlp/CYCbZwc3RXQfFvTOz0oB21qeYaBa9+VP7j7GoJuCnM+Dfcmz89aZORmE6EuYzWIFZabjSX9u30uViZpPFO9RbaU9aT7rg/X5stnJzzU0TKZiyeTytZjwvCTcd5zqZkuB7PZ5V7UbXzLrUBDFnjGM3Sl86VdgoX0L9tF801DzaSlIelvMt+hNNqB/rlecCvITNA== 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=jtyku9voDYV1hI8bcELUB9agfFb1SDE1DC5fLERk9p4=; b=nGnlzzkcpXZj68aEDd0iz8g1bcCehaz3+eM2PvhdIb8D+hUTlUTowdJmbQ/m9o8KuCJgBPc58EyJy4Dy7yREmJai7SZfeageRxUghiTLHJYjkV1076CCYXOLI2YV3IKO66JxHQVzAaPzEXzShuFIvItX+p/I6o5uJdXMVwkwwrI= Received: from VI1PR08CA0230.eurprd08.prod.outlook.com (10.170.234.167) by VI1PR0802MB2608.eurprd08.prod.outlook.com (10.172.255.150) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2157.18; Thu, 15 Aug 2019 13:11:37 +0000 Received: from DB5EUR03FT043.eop-EUR03.prod.protection.outlook.com (2a01:111:f400:7e0a::206) by VI1PR08CA0230.outlook.office365.com (2603:10a6:802:15::39) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.2157.16 via Frontend Transport; Thu, 15 Aug 2019 13:11: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 DB5EUR03FT043.mail.protection.outlook.com (10.152.20.236) 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:11:35 +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; Thu, 15 Aug 2019 13:11:33 +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:32 +0000 From: "Krzysztof Koch" To: CC: , , , , , Subject: [PATCH v1 01/11] ShellPkg: acpiview: Set ItemPtr to NULL for unprocessed table fields Date: Thu, 15 Aug 2019 14:11:11 +0100 Message-ID: <20190815131121.52644-2-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)(376002)(346002)(136003)(396003)(2980300002)(189003)(199004)(426003)(70586007)(8676002)(478600001)(81156014)(6916009)(53416004)(70206006)(186003)(48376002)(4326008)(305945005)(126002)(486006)(44832011)(63370400001)(1076003)(6666004)(16586007)(356004)(76176011)(336012)(7696005)(81166006)(51416003)(63350400001)(54906003)(86362001)(316002)(2616005)(446003)(476003)(2351001)(14444005)(26005)(11346002)(47776003)(2906002)(50226002)(5660300002)(36756003)(53936002)(8936002)(50466002);DIR:OUT;SFP:1101;SCL:1;SRVR:VI1PR0802MB2608;H:nebula.arm.com;FPR:;SPF:TempError;LANG:en;PTR:InfoDomainNonexistent;MX:1;A:1; X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 3a953f0b-245a-4be0-150e-08d721821ff8 X-Microsoft-Antispam-Untrusted: BCL:0;PCL:0;RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600148)(711020)(4605104)(1401327)(2017052603328);SRVR:VI1PR0802MB2608; X-MS-TrafficTypeDiagnostic: VI1PR0802MB2608:|HE1PR0801MB1850: X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true X-MS-Oob-TLC-OOBClassifiers: OLM:9508;OLM:9508; X-Forefront-PRVS: 01304918F3 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Message-Info-Original: DY5M7tFiUWP96sIqIAgIoL5feDcdchQZPGehQQ9KzCTQR6rLqzU3EioNUb2s7fXYiocARwYF7x4T5T/8qFz1CcmIaikm5jc/nz/3C/CrvlR/SkcuI7xG4kW9yEk+wYkvVgeZKR5zgPUgx2YloW07xm+40eDH8XYodGtkul/pdtBlVyktZegfuax8wM/5SRkIv2c0tNRUkIdO7iA0K5fYNia4Ukvv4jZfSV0xpTpwR6aGfNNyyQZxk5GrtzGh9B3maKnHU6E9T88zcfH5iUukcRquMx1mOYZbzTosiqrlAr34pCjrq1grsOFEyZMkYibuFU9D6yU13iSbwin4FJULz40zr/2OuR44SoYyw8UiQB/ZEGRnblWaVvZiweUx4uvXIkP9SMebEDWd2VpEcv6VnFpqgGkKH0LHszTTRjq4AqE= X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0802MB2608 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: AM5EUR03FT063.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)(39860400002)(396003)(346002)(376002)(2980300002)(189003)(199004)(63370400001)(305945005)(2351001)(50466002)(1076003)(7696005)(51416003)(81166006)(8676002)(48376002)(81156014)(76176011)(36756003)(70206006)(54906003)(2906002)(53416004)(63350400001)(70586007)(446003)(86362001)(5660300002)(44832011)(47776003)(336012)(478600001)(14444005)(22756006)(4326008)(186003)(76130400001)(316002)(50226002)(6916009)(486006)(126002)(476003)(26005)(2616005)(8936002)(36906005)(16586007)(426003)(11346002)(26826003)(6666004);DIR:OUT;SFP:1101;SCL:1;SRVR:HE1PR0801MB1850;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: ebd4b0b8-9688-47d1-302b-08d721821984 X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600148)(710020)(711020)(4605104)(1401327)(2017052603328);SRVR:HE1PR0801MB1850; NoDisclaimer: True X-Forefront-PRVS: 01304918F3 X-Microsoft-Antispam-Message-Info: ND9Zoe9sYdqKLq8AWN+/r9sx8T/ZoWJbYV6qAp4Ma1nW302fShzunv/PDpFNXshv7lBSuEMz+PONv23V/kGOpr/4rwRltmx5eL3bNJIhi2WMUL2HgbSTiWr0M7u7qwfR6V5qYINbUwNji8v+tlTycAJ1yQZx7Rywms0FrsoL8BIjjoCck2kOdmOMNbYQnZNYS8wjAtIGsVaKB+5pg07gy3781gTRVmzEx4r6ZyOnsj/tuy6yu5F2GOOhhpL0mdOBmejxzuS0ArQyexewDY3vXnr5l+ln/J5m6uulUpnKIa3dkiCZ5w02jZhfmNvkc0kuwqLAOF8H5d94EH/Vbr+bbzG/wFJhduVYtLxM4KxCyBG1nGVuZGDvU7Bi4dCHwsZ3MaZcHHKxcqxlrMVS4FMe5RBh9eD8Mk/wuS0r5HzlSnU= X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Aug 2019 13:11:46.1291 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 3a953f0b-245a-4be0-150e-08d721821ff8 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: HE1PR0801MB1850 Content-Type: text/plain For fields outside the buffer length provided, reset any pointers, which were supposed to be updated by a ParseAcpi() function call to NULL. This way one can easily validate if a pointer was successfully updated. The ParseAcpi() function parses the given ACPI table buffer by a number of bytes which is a minimum of the buffer length and the length described by ACPI_PARSER array. If the buffer length is shorter than the array describing how to process the ACPI structure, then it is possible that the ItemPtr inside ACPI_PARSER may not get updated or initialized. This can lead to an error if the value pointed to by ItemPtr is later used to control the parsing logic. A typical example would be a 'number of elements' field in an ACPI structure header which defines how many substructures of a given type are present in the structure body. If the 'number of elements' field is not parsed, this could result in a dangling pointer which could cause a problem later. Signed-off-by: Krzysztof Koch --- Notes: v1: - Set ItemPtr to NULL for unprocessed table fields [Krzysztof] ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.c b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.c index 2d6ff80e299eebe7853061d3db89332197c0dc0e..1ede12859721db75d17fd0bfc14dc9e9c0d573aa 100644 --- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.c +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.c @@ -502,8 +502,15 @@ ParseAcpi ( for (Index = 0; Index < ParserItems; Index++) { if ((Offset + Parser[Index].Length) > Length) { + + // For fields outside the buffer length provided, reset any pointers + // which were supposed to be updated by this function call + if (Parser[Index].ItemPtr != NULL) { + *Parser[Index].ItemPtr = NULL; + } + // We don't parse past the end of the max length specified - break; + continue; } if (GetConsistencyChecking () && -- 'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)'