From nobody Mon Apr 29 03:39:50 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+45722+1787277+3901457@groups.io; arc=fail (BodyHash is different from the expected one) Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 156587471880869.99756582672342; Thu, 15 Aug 2019 06:11:58 -0700 (PDT) Return-Path: X-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 X-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 X-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 Received-SPF: pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+45722+1787277+3901457@groups.io; helo=web01.groups.io; Received-SPF: TempError (protection.outlook.com: error in processing during lookup of arm.com: DNS Timeout) X-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 X-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 X-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 X-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 X-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 X-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) X-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 X-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 X-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: [edk2-devel] [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> 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-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; X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM5EUR03FT063.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: ebd4b0b8-9688-47d1-302b-08d721821984 NoDisclaimer: True 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 Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,krzysztof.koch@arm.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1565874714; bh=6+2vxbdJ7SNhNo27STl+d7kJFWoIW5e9VAseeKm6CVk=; h=CC:Content-Type:Date:From:Reply-To:Subject:To; b=b5aSufHMDculT07Seo4Bm3fjEJwWxODmgd83p5Jxu9Do0tnDA47Eat+Hd8/aZaA2abL cB026uJwRxwULvJ3QprE4X5peWGa+My44j8FQ8UoW8old2Y/hMIIIQBNEyjRbA4LohkmE fDe11VvM1+sJTjek6N/U66rh9t8iqSbi97w= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 Reviewed-by: Sami Mujawar --- 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/Sh= ellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.c index 2d6ff80e299eebe7853061d3db89332197c0dc0e..1ede12859721db75d17fd0bfc14= dc9e9c0d573aa 100644 --- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.c +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.c @@ -502,8 +502,15 @@ ParseAcpi ( =20 for (Index =3D 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 !=3D NULL) { + *Parser[Index].ItemPtr =3D NULL; + } + // We don't parse past the end of the max length specified - break; + continue; } =20 if (GetConsistencyChecking () && -- 'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)' -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#45722): https://edk2.groups.io/g/devel/message/45722 Mute This Topic: https://groups.io/mt/32886563/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Mon Apr 29 03:39:50 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+45726+1787277+3901457@groups.io; arc=fail (BodyHash is different from the expected one) Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1565876320702726.9276734220965; Thu, 15 Aug 2019 06:38:40 -0700 (PDT) Return-Path: X-Received: from EUR04-HE1-obe.outbound.protection.outlook.com (EUR04-HE1-obe.outbound.protection.outlook.com [40.107.7.49]) by groups.io with SMTP; Thu, 15 Aug 2019 06:11:54 -0700 X-Received: from DB7PR08CA0031.eurprd08.prod.outlook.com (2603:10a6:5:16::44) by DB6PR0802MB2599.eurprd08.prod.outlook.com (2603:10a6:4:a2::16) 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:11:50 +0000 X-Received: from AM5EUR03FT053.eop-EUR03.prod.protection.outlook.com (2a01:111:f400:7e08::207) by DB7PR08CA0031.outlook.office365.com (2603:10a6:5:16::44) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.2157.18 via Frontend Transport; Thu, 15 Aug 2019 13:11:50 +0000 Received-SPF: pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+45726+1787277+3901457@groups.io; helo=web01.groups.io; Received-SPF: TempError (protection.outlook.com: error in processing during lookup of arm.com: DNS Timeout) X-Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by AM5EUR03FT053.mail.protection.outlook.com (10.152.16.210) 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:11:48 +0000 X-Received: ("Tessian outbound 1e6e633a5b56:v26"); Thu, 15 Aug 2019 13:11:46 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: b5bd2c6f38513bbc X-CR-MTA-TID: 64aa7808 X-Received: from 691c85c9e73e.1 (cr-mta-lb-1.cr-mta-net [104.47.14.50]) by 64aa7808-outbound-1.mta.getcheckrecipient.com id A6A84E9E-EFFB-44E1-A78B-98A3B455B874.1; Thu, 15 Aug 2019 13:11:40 +0000 X-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 691c85c9e73e.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=KPiCROoWrrYUhzsJhaYkFaz3+wQDtzQ8c7YubAmOobk/+SSSjU2OFL3k4kuXw/T5Cg0cgEl7SLaObqJ+8AYKYP5bangpQboVRugcM0ZsBs3AGVzbZXqeH6dw8XRyVT3Jo+gYaGO/yHzTPAAhgGq1k+3EODz7IrdoaWK+ImPFXNnNvg4wl9zAtA6VH2kvbuPwg9m4JYB4ynVqO4hOIhSbNCH9WMMiiwHFk0tFfEeB1EhCKPXOQ5FzgXjd6nP6iitDqQvdnkwXLZRnLrJRWWq/iFpEP2eKwvsYaEcZJjhNeQ3xvwbVPdJ2DZtv1Q+DjDYbDoyjgHByg79UvhfzjnQ4cw== 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=PTlIEPVRlSJQ83SrGgCJEc6F/muKRPVr3Hq2SlBc/d0=; b=TgxnVyqcPmdOVA3OpxtU0+iaQ+4pAtRTDw/NMPVDWlS4hQ06N7ysNu8vYLt4h5sW6lOWNuyi0yCfXC/oh6OoFGZ981CPHTXm7SK6+mNEIOM2JSGfH5VbtHZNflgJgGCqmhqfn1RK4xvQ/VVORlAeu4XID9jprxRLcouAIYnPpJHOsjP+r6eDrHUEtDNZaLt/chUXHAvDIqZp7FfbAC4Ajyukx+7wlyLtorW3UL3EQZ5mxIo5Jz8CG+eizd4tD3oaIDVbZ5Z0sz4zrtENmu2rTkqY9RMAhJjoeavwOHjJJZEK8yrAR+mIE2Kbesr2IGO0kRPcu8T2grDpLuKPYtTUxA== 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 X-Received: from AM6PR08CA0043.eurprd08.prod.outlook.com (2603:10a6:20b:c0::31) by AM6PR08MB4949.eurprd08.prod.outlook.com (2603:10a6:20b:ee::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2178.16; Thu, 15 Aug 2019 13:11:37 +0000 X-Received: from DB5EUR03FT007.eop-EUR03.prod.protection.outlook.com (2a01:111:f400:7e0a::202) by AM6PR08CA0043.outlook.office365.com (2603:10a6:20b:c0::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.2157.18 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) X-Received: from nebula.arm.com (40.67.248.234) by DB5EUR03FT007.mail.protection.outlook.com (10.152.20.148) 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:36 +0000 X-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:34 +0000 X-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:33 +0000 From: "Krzysztof Koch" To: CC: , , , , , Subject: [edk2-devel] [PATCH v1 02/11] ShellPkg: acpiview: RSDP: Validate global pointer before use Date: Thu, 15 Aug 2019 14:11:12 +0100 Message-ID: <20190815131121.52644-3-krzysztof.koch@arm.com> 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)(376002)(39860400002)(346002)(396003)(136003)(2980300002)(199004)(189003)(6666004)(16586007)(356004)(316002)(76176011)(54906003)(63350400001)(63370400001)(426003)(11346002)(70206006)(70586007)(446003)(186003)(7696005)(336012)(51416003)(26005)(6916009)(305945005)(8676002)(486006)(44832011)(476003)(2616005)(126002)(2351001)(50466002)(4326008)(478600001)(81156014)(81166006)(15650500001)(48376002)(5660300002)(50226002)(47776003)(2906002)(8936002)(36756003)(53416004)(53936002)(86362001)(1076003);DIR:OUT;SFP:1101;SCL:1;SRVR:AM6PR08MB4949;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: 969cdeaf-a2a7-4f8f-707b-08d72182214e X-Microsoft-Antispam-Untrusted: BCL:0;PCL:0;RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600148)(711020)(4605104)(1401327)(2017052603328);SRVR:AM6PR08MB4949; X-MS-TrafficTypeDiagnostic: AM6PR08MB4949:|DB6PR0802MB2599: X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true X-MS-Oob-TLC-OOBClassifiers: OLM:6790;OLM:6790; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Message-Info-Original: C11Gn/g/A5kdyvhBbwDY/ux/eltwZyCCHwkZ1D7nkOTYDeKnFzzw8k+URHXVa3McIJX8Je5NxmRy9FUToOGSshv/wIPV7UPtA+zLBTkw/Kzf1T2PpZPOrZtbC0tW1zHjtHt2bdTK/LKzFJWv/KG4MnwSKIVfgzASnbEZHYSefClWlVehQqM4TER66SkXp7wRy7xUUvZg+UrdLKVfPjiM1/zSL18n7LvRf14HUidnjWMlxt6Ai3kQALL0z7dou39HYmhrUSAhDSRn1hBex0E3XnLoTlAmhKmvmppyPHLqyr4F7LinZdng8DBuCThjFKFc64FEeCQJNr2jUqb5spNJJk3yk/SQrDOQgC/ZVma/NgQnh3F6+QUGG2d4/Q7gden8SEVLIXpAwu8FHAfxok/dwh+c6IA4zzaMU4iaX4zUqx0= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB4949 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; X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM5EUR03FT053.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: 7724d3c1-f952-4936-769a-08d721821a05 NoDisclaimer: True X-Microsoft-Antispam-Message-Info: dSqUvj6QbJnEqLXRfmVJOO2pZWrH42JkGSj9i6iaJPJI4xyQAo26cTSRwvnSXbm4mTY8u4Oxz/T8FrZKD71yJoI5HQEPeRmhsThSdwrZ1/6dlsgZLL8d3Hvg02RpK8TqIBnS2ZGwHba3qR1qbbUAGThn3+6Yv/CPmBhhhE8FEKX4DFIuCvmpl9FmrVgaHTNBM+GGvkD8TVp3dmsOGR72DR9kJu+ejK82pPTzVHuCCfdawPPuI7v5LIxJeWx2CSAq71JmzIl09zyG1W2v/zTKOUmf3e/3SE3Zr6mxVJa4rf+MToCHX3aTKUb6lukuLOnDRjHOIT0vlcsHtsQttvBMJ3COVjiZ1XKj6yT9THyFiAdOchLpDuSN5bK9dzAyYquzJHNPo4JeMu2rVBGzCbW8pw6NEdkozvnCuoIvISv/m/U= X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Aug 2019 13:11:48.3707 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 969cdeaf-a2a7-4f8f-707b-08d72182214e 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: DB6PR0802MB2599 Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,krzysztof.koch@arm.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1565876320; bh=OTkJjECmAGXzXEPtXLwpLzPIbJQNooDiQ6XAPDX8lWw=; h=CC:Content-Type:Date:From:Reply-To:Subject:To; b=GJGiGlRlePIvh8hJB4qNiG0ljE8N2vp/rWD/d694L+lejerRlBrwEYatab23rI3Eqbd 7JWDSEZjSRdaEl/4ft/HkWhWGHA+5QpoNBMr6uYZPt22maURrFb38ZNnpcKU93/+UNQYm q/qpy+qeV4CwIMHgt8u1m9XQ3qFTgMxfPBY= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Check if XsdtAddress pointer has been successfully updated before it is used for further table parsing. Signed-off-by: Krzysztof Koch Reviewed-by: Sami Mujawar --- Notes: v1: - Test against NULL pointers [Krzysztof] ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Rsdp/RsdpParser.c | 1= 2 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Rsdp/Rsdp= Parser.c b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Rsdp/RsdpPa= rser.c index 5a5c4b50c12e6eb0aa0efb1765df7e123f614da3..f4a8732a7db7c437031f2a3d2f2= 66b80eff17b4b 100644 --- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Rsdp/RsdpParser.c +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Rsdp/RsdpParser.c @@ -138,6 +138,18 @@ ParseAcpiRsdp ( PARSER_PARAMS (RsdpParser) ); =20 + // Check if the values used to control the parsing logic have been + // successfully read. + if (XsdtAddress =3D=3D NULL) { + IncrementErrorCount (); + Print ( + L"ERROR: Insufficient table length. AcpiTableLength =3D %d." \ + L"RSDP parsing aborted.\n", + AcpiTableLength + ); + return; + } + // This code currently supports parsing of XSDT table only // and does not parse the RSDT table. Platforms provide the // RSDT to enable compatibility with ACPI 1.0 operating systems. -- 'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)' -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#45726): https://edk2.groups.io/g/devel/message/45726 Mute This Topic: https://groups.io/mt/32886568/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Mon Apr 29 03:39:50 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+45724+1787277+3901457@groups.io; arc=fail (BodyHash is different from the expected one) Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1565874722484231.17607260137902; Thu, 15 Aug 2019 06:12:02 -0700 (PDT) Return-Path: X-Received: from EUR03-AM5-obe.outbound.protection.outlook.com (EUR03-AM5-obe.outbound.protection.outlook.com [40.107.3.75]) by groups.io with SMTP; Thu, 15 Aug 2019 06:11:58 -0700 X-Received: from AM6PR08CA0011.eurprd08.prod.outlook.com (2603:10a6:20b:b2::23) by DB8PR08MB4956.eurprd08.prod.outlook.com (2603:10a6:10:e0::25) 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:53 +0000 X-Received: from DB5EUR03FT063.eop-EUR03.prod.protection.outlook.com (2a01:111:f400:7e0a::206) by AM6PR08CA0011.outlook.office365.com (2603:10a6:20b:b2::23) 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:11:53 +0000 Received-SPF: pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+45724+1787277+3901457@groups.io; helo=web01.groups.io; Received-SPF: TempError (protection.outlook.com: error in processing during lookup of arm.com: DNS Timeout) X-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:11:51 +0000 X-Received: ("Tessian outbound 578a71fe5eaa:v26"); Thu, 15 Aug 2019 13:11:46 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 0bd8637e47ef5715 X-CR-MTA-TID: 64aa7808 X-Received: from 14c8611bf911.1 (cr-mta-lb-1.cr-mta-net [104.47.0.58]) by 64aa7808-outbound-1.mta.getcheckrecipient.com id 4CB743D6-172A-4522-984A-F03D44D2CC4F.1; Thu, 15 Aug 2019 13:11:40 +0000 X-Received: from EUR01-HE1-obe.outbound.protection.outlook.com (mail-he1eur01lp2058.outbound.protection.outlook.com [104.47.0.58]) by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 14c8611bf911.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=hrVlOoac1zyU1rVS1a/Ki8zxbWIhyF69NXfWFx3Tstqz6vBwCIDo7/TvFzMi7x3MiNTyHs5re67zvYMZUKdV4IBm3PEjZTeqYHcwZduvbbTgvsvqlHsmFukteMV4k7Rs/5fn+MNUEwYb44AK4Uup2nwIIFtnSMpiyJTjzh58stjJt4/H9/JCcO+wLea4TRpVFYQKDjJmTO2cFTGKz9XygOYy1uhnHeFANW0VVMWk0qaPbBrkPy3jqAxQl3ewDUTuYJOpVew7i4TmDHIeAhKau7thDx7IhdDidzIJvoaeks3/ibvFfVB2/M2jRRw9iRH6Bhj4ib3T/MpOO8rXddNF0A== 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=+GOmkCOa5Q9giN5fQxdlPnuRpLknDkuM6KOCfU0vzkw=; b=PPJJC8UVnvlMemDN2YB60R2B1k3KEHEPsn8MyCTjXtVr6LZy5Dy7MY+tMUHDeMpBDH1qSiqrXP8b1oFaEyZqZkXCaKpKam4Ti1GcSmdj17kgdD8nT4sTWXXanLQ3ssePY9CXKQVh+Mf8aVwy80e8paT4yp2vEaqQY7dzmG9BI3Ov9OkbLSBFX2TJzRbB+uuppxeIRdERXfWPmA7yMF7uT5GoRFDgxCQ8lG1bMdeT15f7UnHpNCER3UPgl1+9x8h5nKzuPc9W6+8xTLWUX9Z1siMoH5RWSsiVYEr+0vtUhEOsMNKZ10FGuLpTLAGL2mSPSMm+Wsm8ClHBI1db3eqkIA== 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 X-Received: from AM6PR08CA0035.eurprd08.prod.outlook.com (2603:10a6:20b:c0::23) by AM5PR0801MB1843.eurprd08.prod.outlook.com (2603:10a6:203:3a::12) 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:11:37 +0000 X-Received: from DB5EUR03FT007.eop-EUR03.prod.protection.outlook.com (2a01:111:f400:7e0a::206) by AM6PR08CA0035.outlook.office365.com (2603:10a6:20b:c0::23) 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: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) X-Received: from nebula.arm.com (40.67.248.234) by DB5EUR03FT007.mail.protection.outlook.com (10.152.20.148) 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 X-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:34 +0000 X-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:34 +0000 From: "Krzysztof Koch" To: CC: , , , , , Subject: [edk2-devel] [PATCH v1 03/11] ShellPkg: acpiview: FADT: Validate global pointer before use Date: Thu, 15 Aug 2019 14:11:13 +0100 Message-ID: <20190815131121.52644-4-krzysztof.koch@arm.com> 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)(396003)(136003)(2980300002)(199004)(189003)(2351001)(47776003)(50226002)(53416004)(6666004)(50466002)(8936002)(6916009)(48376002)(36756003)(305945005)(356004)(70206006)(70586007)(446003)(81156014)(1076003)(186003)(126002)(63370400001)(44832011)(51416003)(63350400001)(81166006)(7696005)(54906003)(486006)(8676002)(5660300002)(11346002)(76176011)(16586007)(2616005)(426003)(53936002)(478600001)(4326008)(2906002)(15650500001)(476003)(316002)(26005)(336012)(86362001);DIR:OUT;SFP:1101;SCL:1;SRVR:AM5PR0801MB1843;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: e5954133-3bae-4c87-ea13-08d72182233e X-Microsoft-Antispam-Untrusted: BCL:0;PCL:0;RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600148)(711020)(4605104)(1401327)(2017052603328);SRVR:AM5PR0801MB1843; X-MS-TrafficTypeDiagnostic: AM5PR0801MB1843:|DB8PR08MB4956: X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true X-MS-Oob-TLC-OOBClassifiers: OLM:5236;OLM:5236; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Message-Info-Original: JgtGo8MS0qHSNzFeqJi31A2+5HVaQTU7SjmTmaNaIsXgegwHpVBbYwc8+x31hWpLMXsS+FwkJtr4H119wSPsfyo996sQ4aChtJagnVq6ddrpSepzdBupV5QzrlRrztHmTyyBCe7N6IU6BWinwm7AwSWOFMpvHyiM6WnppHM/4+1CBpnJcmFT8uKtGRRW6qUs7jBgDIQ8ftVksyA9DI1Tpm8evNnz3VACY7PDRN3uCGrm8xhcEze9BqprFoZCgv9difaHkGrNfsve0hyd0wA6FY9wdxMNPDruBZtBme7UNapE+J/mVC9ed9h9aXqPXV1QcP/dvzIMoA0qg8f0hkCEdde3fiS9PpIJJK+jKWxb1/oMymadh4ZTymg2C02LrS0/f0575ThpGew1cDt6WVqjMR5F74oq6Q48ZcHd+TONnQ0= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM5PR0801MB1843 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; X-MS-Exchange-Transport-CrossTenantHeadersStripped: DB5EUR03FT063.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: bbe130e1-87a1-46e1-b6e2-08d7218219e3 NoDisclaimer: True X-Microsoft-Antispam-Message-Info: Wb+mZJMLgxsZdlmQdsAB0/R8LM+pNqjFoEfCZM6cths/Wk/uYy3pAzR9JvS/d7oH6l5O8+xVw5IGZu3bbXLLoA9tfZzC/7zL1/MwjDUfNRNC9PKoEA6MBnYnxFsw3Y8VYIZsfQwhAMcD+dmKOMrwMDYrwHVVt/wopj5hFtYtGRXTcEGNzx1FpkrofHEvM//pXYw2UEeo+8VoZkp+HFDnNHHsG+8cTjQqiZADU1Hpy2++W21MaHC+rL41+EMVyDLURcNl8LNQ/4rdqfj+LkhgpEpm++X35Vv0q1+PITTLyACeTpy+IglMaQJsXRFD+Ne/DaDn9nYXg2uUsRMKTOnck8/4y6IlpBcfyhwje158IocspjHzR4HHt12KBHsQdM1TpzixQVjotLOwznAhGNNuWN4ozlUbUseKTxf0yQcO9OE= X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Aug 2019 13:11:51.6444 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e5954133-3bae-4c87-ea13-08d72182233e 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: DB8PR08MB4956 Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,krzysztof.koch@arm.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1565874718; bh=E63bQZL2/y4eT4GxhJLF8GrQatlE9rCAFsa6iu0UknE=; h=CC:Content-Type:Date:From:Reply-To:Subject:To; b=MpFxvlpuAbElmNi1mx4+ZrLhErShFlouofI1HIr8PAhJx2xmJntO5rL4SqjCviHGdx0 hhKYGQD2NFRMVR+cY0ZUkh6joI3ZrGhhhx17nRLWIewSfZZWSwZFoD2ZT+BiNnJsbZ9ls eeH4inMonGtY8OpWDsqpPczV/v5PAF6/ICw= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Check if global pointers have been successfully updated before they are used for further table parsing. Signed-off-by: Krzysztof Koch Reviewed-by: Sami Mujawar --- Notes: v1: - Test against NULL pointers [Krzysztof] ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Fadt/FadtParser.c | 1= 4 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Fadt/Fadt= Parser.c b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Fadt/FadtPa= rser.c index e40c9ef8ee4b3285faf8c6edf3cb6236ee367397..e218e45926abced1096e75441e2= 2108db7a3a811 100644 --- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Fadt/FadtParser.c +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Fadt/FadtParser.c @@ -203,6 +203,20 @@ ParseAcpiFadt ( PARSER_PARAMS (FadtParser) ); =20 + // Check if the values used to control the parsing logic have been + // successfully read. + if ((DsdtAddress =3D=3D NULL) || + (FadtMinorRevision =3D=3D NULL) || + (X_DsdtAddress =3D=3D NULL)) { + IncrementErrorCount (); + Print ( + L"ERROR: Insufficient table length. AcpiTableLength =3D %d. " \ + L"FADT parsing aborted.\n", + AcpiTableLength + ); + return; + } + if (Trace) { Print (L"\nSummary:\n"); PrintFieldName (2, L"FADT Version"); -- 'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)' -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#45724): https://edk2.groups.io/g/devel/message/45724 Mute This Topic: https://groups.io/mt/32886566/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Mon Apr 29 03:39:50 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+45721+1787277+3901457@groups.io; arc=fail (BodyHash is different from the expected one) Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1565874719048706.2594187263933; Thu, 15 Aug 2019 06:11:59 -0700 (PDT) Return-Path: X-Received: from EUR02-AM5-obe.outbound.protection.outlook.com (EUR02-AM5-obe.outbound.protection.outlook.com [40.107.0.50]) by groups.io with SMTP; Thu, 15 Aug 2019 06:11:52 -0700 X-Received: from VE1PR08CA0008.eurprd08.prod.outlook.com (2603:10a6:803:104::21) by DB6PR0802MB2600.eurprd08.prod.outlook.com (2603:10a6:4:a1::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2178.16; Thu, 15 Aug 2019 13:11:48 +0000 X-Received: from AM5EUR03FT018.eop-EUR03.prod.protection.outlook.com (2a01:111:f400:7e08::209) by VE1PR08CA0008.outlook.office365.com (2603:10a6:803:104::21) 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:48 +0000 Received-SPF: pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+45721+1787277+3901457@groups.io; helo=web01.groups.io; Received-SPF: TempError (protection.outlook.com: error in processing during lookup of arm.com: DNS Timeout) X-Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by AM5EUR03FT018.mail.protection.outlook.com (10.152.16.114) 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 X-Received: ("Tessian outbound 220137ab7b0b:v26"); Thu, 15 Aug 2019 13:11:46 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 6e6fe97b1905bdde X-CR-MTA-TID: 64aa7808 X-Received: from 32c175e99651.1 (cr-mta-lb-1.cr-mta-net [104.47.8.51]) by 64aa7808-outbound-1.mta.getcheckrecipient.com id 8D130C8E-53A8-46D3-839A-DE07BEF2968E.1; Thu, 15 Aug 2019 13:11:39 +0000 X-Received: from EUR03-AM5-obe.outbound.protection.outlook.com (mail-am5eur03lp2051.outbound.protection.outlook.com [104.47.8.51]) by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 32c175e99651.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384); Thu, 15 Aug 2019 13:11:39 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=aG2U2Ij0ARCYwOrhtlNIaYqTz8qJZBj/Os6oJzm+lxlTSvFBQKMRmC6+Bzq3DMdfhdTK3IH5cIMOyGPUrd7SDImdcES58jI3qXUD3cYBRYRiteLpfMz4WHlEnbCg5fCpjDxb61QFMzwAURBNtNLte1b3Hc6/ePOftRBldqPs1DOP0A5A6U3QcLISZBvQMhcXn4QskLBrREGOD8sL/4YReZFUd5qpu4eH17Boeon2lBNre6ecS1SpmPp2JVlPrQlguo9vq2NddJrup4jW/vNiBwvKpOppJxmz7nV9BMyvf3JbNlBBR7BMBgHFKZ9zDyMsEb0npC5AjDE5F1xgIFbzRw== 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=wD023htNTzHRA50fVWCFUxwiz2OUkkfk6Dc0jd03ToQ=; b=kmlGim030pU4kMafGfO6JdYrsuP9A2J3SKlBSraZbLamSNCXoC7QKyZoSIEfQo3UcZ6P7GtX3M60uO03N4iUWL84C+IaCEKaGxUlzd7W5/Apn96uvl1gve/s0eJewMMlFAotLRLEVutFLyBeIj0eI75qv8xqSaoPjGzwWBHM/aEmKW4fuAIQgkHXftBkb1UP51FvUwsbwc0Y0/8JJW/Hllgb7da1vkBejSNR3vXmbO7VgFf9LxA105pwLvMaCuVWnniHhRLQKlIWQiM2Y9I8WygGEiiqy/C10E7408b8+7e8ELs9gsJwLZ4bZrZxYn8YaQbx/IidzFVhtEfHJWItjQ== 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 X-Received: from VI1PR08CA0133.eurprd08.prod.outlook.com (2603:10a6:800:d5::11) by DB8PR08MB4956.eurprd08.prod.outlook.com (2603:10a6:10:e0::25) 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 X-Received: from DB5EUR03FT040.eop-EUR03.prod.protection.outlook.com (2a01:111:f400:7e0a::205) by VI1PR08CA0133.outlook.office365.com (2603:10a6:800:d5::11) 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: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) X-Received: from nebula.arm.com (40.67.248.234) by DB5EUR03FT040.mail.protection.outlook.com (10.152.20.243) 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 X-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:35 +0000 X-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:34 +0000 From: "Krzysztof Koch" To: CC: , , , , , Subject: [edk2-devel] [PATCH v1 04/11] ShellPkg: acpiview: SLIT: Validate global pointer before use Date: Thu, 15 Aug 2019 14:11:14 +0100 Message-ID: <20190815131121.52644-5-krzysztof.koch@arm.com> 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)(396003)(39860400002)(136003)(376002)(346002)(2980300002)(189003)(199004)(51416003)(446003)(86362001)(76176011)(63370400001)(305945005)(26005)(15650500001)(426003)(2351001)(7696005)(44832011)(186003)(5660300002)(486006)(50466002)(6916009)(1076003)(2906002)(336012)(53416004)(126002)(356004)(6666004)(48376002)(11346002)(2616005)(63350400001)(476003)(70206006)(81156014)(81166006)(50226002)(8676002)(54906003)(478600001)(16586007)(8936002)(4326008)(36756003)(70586007)(316002)(47776003)(53936002);DIR:OUT;SFP:1101;SCL:1;SRVR:DB8PR08MB4956;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: a394886b-1ed1-421a-2008-08d721822009 X-Microsoft-Antispam-Untrusted: BCL:0;PCL:0;RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600148)(711020)(4605104)(1401327)(2017052603328);SRVR:DB8PR08MB4956; X-MS-TrafficTypeDiagnostic: DB8PR08MB4956:|DB6PR0802MB2600: X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true X-MS-Oob-TLC-OOBClassifiers: OLM:5797;OLM:5797; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Message-Info-Original: PPUdjQEMH2tsfcGO+A8VGDVxI+oppSFhYjhZ24erOpMtUDXK7XsK73ck7EqOZVuJH4WDaJOnLmdQ0rGINiscWIHHqe1RDwOxxhJweo36tgK3f6SQKkFEeoH5/J5M5tCj2G/ilGfbB1egm53mZPYMNvbjB7ZXnT7X3+PI9IPdZfI9fYAFa8VPAXMr3urj1aLcJsBip0ZRZcgsEf1v4ehfPT/yQ/RiafP8CBP5f/9P0iE4g59s3SDd0gVT7a48dkZPi3rxTRqjTZhCugfBT2fWMZ2GW4RMv3aJ6/K6eNGKMBnxzjB9ilaxqGMZtYy46jpFw7kVZH7cbnB5wqs4AWbjYWdUCzkuoB9VB5zDBQxZXztiJiQnEHb68o5rKaQrrhsmp5BSJxZJu1JzAp5tCI5cTTcVPh2Z+3RjCSUJAIHo3iE= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB8PR08MB4956 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; X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM5EUR03FT018.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: 914cf0f4-4bf0-4efb-49e8-08d7218219ce NoDisclaimer: True X-Microsoft-Antispam-Message-Info: Pb0q9WAbEFn2dbDV9kCc5Ve7gbLIpBlx5STBHi4BHBydjjwXPH+HHBTldxbwBXwJjpxonjXalCHSuufP+az3sGbsP+Y5ChLZCLHMUD4E2JFg909Svnta94ozXMOG9LKHvHgn/oKMSYkIiEdUad6Rko0qrzV84AQ7CIdlWKtw4HuK3cz/Dtt98LZPJiqgkLP+l2eDvlRN5D09nei6/BxQHMIqNN2DkGyIusz2fSUnIiUhwe3jI25ywfrAraEGOQbc3nlv+dwX8jrLEewpeFTTDO0XWXNqCkVq3FHYvXu6zE1HeMFLVwFr4y+zyi/MauzWc0R1l6EbaIveuQ+Dx1UT1eYVaVfmMzVLmlb/lfBljcDjq055sVbuhxZfZd0LzqYAkkf8qm7RMEF7ks8Nsfj12u5wFeiYC5PcrUS643WWd4U= X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Aug 2019 13:11:46.2407 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a394886b-1ed1-421a-2008-08d721822009 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: DB6PR0802MB2600 Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,krzysztof.koch@arm.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1565874713; bh=MlL6A/50pWqGJ7WOxi3soBmRAC22FEvTA4BeOiyr084=; h=CC:Content-Type:Date:From:Reply-To:Subject:To; b=cMxE5BOLgrRmLKSx6CMNyK8CaQmfEg+UBUI+Q1DXLGxB7AAtT4ojMSNqnwfjk8bwUsl uZ57OMeH/Fuhxe59dTVhnNRpOWIloalPjENl/2QSU2hM2+nEaiXGknAwGGN7+NO58Y9ez IKJs3CjGI5hyh7ZmsCNaWNkbAgcjB1bSiwE= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Check if SlitSystemLocalityCount pointer has been successfully updated before it is used for further table parsing. Signed-off-by: Krzysztof Koch Reviewed-by: Sami Mujawar --- Notes: v1: - Test against NULL pointers [Krzysztof] ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Slit/SlitParser.c | 1= 6 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Slit/Slit= Parser.c b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Slit/SlitPa= rser.c index ca2808db526b1bbb79aeb21ccfc0ae6c79b2dfd8..17e2166a09d8615b714e0c51d4d= 93d293fcdf601 100644 --- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Slit/SlitParser.c +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Slit/SlitParser.c @@ -1,7 +1,7 @@ /** @file SLIT table parser =20 - Copyright (c) 2016 - 2018, ARM Limited. All rights reserved. + Copyright (c) 2016 - 2019, ARM Limited. All rights reserved. SPDX-License-Identifier: BSD-2-Clause-Patent =20 @par Reference(s): @@ -75,9 +75,21 @@ ParseAcpiSlit ( AcpiTableLength, PARSER_PARAMS (SlitParser) ); + + // Check if the values used to control the parsing logic have been + // successfully read. + if (SlitSystemLocalityCount =3D=3D NULL) { + IncrementErrorCount (); + Print ( + L"ERROR: Insufficient table length. AcpiTableLength =3D %d.\n", + AcpiTableLength + ); + return; + } + LocalityPtr =3D Ptr + Offset; - LocalityCount =3D *SlitSystemLocalityCount; + // We only print the Localities if the count is less than 16 // If the locality count is more than 16 then refer to the // raw data dump. -- 'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)' -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#45721): https://edk2.groups.io/g/devel/message/45721 Mute This Topic: https://groups.io/mt/32886562/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Mon Apr 29 03:39:50 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+45728+1787277+3901457@groups.io; arc=fail (BodyHash is different from the expected one) Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 15658763684599.014907861104462; Thu, 15 Aug 2019 06:39:28 -0700 (PDT) Return-Path: X-Received: from EUR02-AM5-obe.outbound.protection.outlook.com (EUR02-AM5-obe.outbound.protection.outlook.com [40.107.0.62]) by groups.io with SMTP; Thu, 15 Aug 2019 06:12:47 -0700 X-Received: from VI1PR08CA0099.eurprd08.prod.outlook.com (10.175.228.25) by VE1PR08MB4958.eurprd08.prod.outlook.com (10.255.158.83) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2157.16; Thu, 15 Aug 2019 13:12:43 +0000 X-Received: from DB5EUR03FT047.eop-EUR03.prod.protection.outlook.com (2a01:111:f400:7e0a::205) by VI1PR08CA0099.outlook.office365.com (2603:10a6:800:d3::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.2157.18 via Frontend Transport; Thu, 15 Aug 2019 13:12:43 +0000 Received-SPF: pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+45728+1787277+3901457@groups.io; helo=web01.groups.io; Received-SPF: TempError (protection.outlook.com: error in processing during lookup of arm.com: DNS Timeout) X-Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by DB5EUR03FT047.mail.protection.outlook.com (10.152.21.232) 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:41 +0000 X-Received: ("Tessian outbound a1fd2c3cfdb0:v26"); Thu, 15 Aug 2019 13:12:41 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 8b6d67feabe564ca X-CR-MTA-TID: 64aa7808 X-Received: from 7c663dce1b7e.1 (cr-mta-lb-1.cr-mta-net [104.47.12.50]) by 64aa7808-outbound-1.mta.getcheckrecipient.com id AE257A80-32EF-4C26-ACE9-ED52D32CBAB5.1; Thu, 15 Aug 2019 13:12:35 +0000 X-Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-db3eur04lp2050.outbound.protection.outlook.com [104.47.12.50]) by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 7c663dce1b7e.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Thu, 15 Aug 2019 13:12:35 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=DTpVNfS3FNjrptvhfXtUUXb7DGhKcZpmy8rw6vGCbVQ+RbOyvi1uTY5/S2pvPE8cyNvRjRr3kUYSniQvYNWoxhnpQ4g7BO0bP72Jp6DmIE1ET3kSkYrzgSgiv8esc9jF1pPPlNbwmW0ddi/NDNP9brWiVz5b/g1uoU1OSNc3s3eTl4BVoGjEy5SOrkPyP0BMJjKl+VbPRMWqPPZ0C/QEra+ngveOqW2k5dy5cxbRoPWofSdPeaKALSSOBahZWxr5adKb72Fjws8TCxhgmiPCzC0rQUVNjhDr+nU0IBrali58hU37KTLnGmAxnCZ31mt6xmBMdNNcww5A+BP0d8/rNg== 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=q9kUs9ziDNmfQqfeyxwQHzWW6UA8K+SfdQmGMYlQCs4=; b=UC6vDaMYenQJfzgM9LmVaVGMVu9DdQvTBn8YjdWESGktg7TYjpFenSo97hDmyqYJz567Hcz9n9H9MoILpevT3XFbouXrDJcZpvJVnAVg0ypFcaeEbrJBzb5uy0HsNDKc3BY1DRnRg+0RwdlJD/vyBaISI3DovHbODzVysDevC44vqurxgoEIYJEEbwDn1JKX5bSabn2lhWvpy2bXDiylwWVSZWqaS3c3uEDzhnozJ6/9Dk0quBAbS/tLjvXNUiPCTzHojOAYzrxV0EhWhz1DyOKcTK1LlayRQ25gYwwh9U2fWtTtjnEtPemKnNoNJe1sGUSWOxYhrQMvFxuOjaLWWw== 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 X-Received: from HE1PR0802CA0006.eurprd08.prod.outlook.com (2603:10a6:3:bd::16) by AM0PR08MB4945.eurprd08.prod.outlook.com (2603:10a6:208:157::22) 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:33 +0000 X-Received: from DB5EUR03FT027.eop-EUR03.prod.protection.outlook.com (2a01:111:f400:7e0a::205) by HE1PR0802CA0006.outlook.office365.com (2603:10a6:3:bd::16) 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:12:32 +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) X-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:30 +0000 X-Received: from AZ-NEU-EX01.Emea.Arm.com (10.251.26.4) by AZ-NEU-EX03.Arm.com (10.251.24.31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.1.1415.2; Thu, 15 Aug 2019 13:11:36 +0000 X-Received: from AZ-NEU-EX04.Arm.com (10.251.24.32) by AZ-NEU-EX01.Emea.Arm.com (10.251.26.4) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1415.2; Thu, 15 Aug 2019 13:11:35 +0000 X-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:35 +0000 From: "Krzysztof Koch" To: CC: , , , , , Subject: [edk2-devel] [PATCH v1 05/11] ShellPkg: acpiview: SLIT: Validate System Locality count Date: Thu, 15 Aug 2019 14:11:15 +0100 Message-ID: <20190815131121.52644-6-krzysztof.koch@arm.com> 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)(136003)(346002)(376002)(39860400002)(396003)(2980300002)(199004)(189003)(70586007)(11346002)(4326008)(16586007)(14444005)(446003)(15650500001)(6666004)(8676002)(54906003)(47776003)(36756003)(476003)(81156014)(5660300002)(70206006)(126002)(486006)(2906002)(44832011)(50226002)(81166006)(53936002)(86362001)(26005)(53416004)(305945005)(478600001)(2616005)(1076003)(48376002)(50466002)(51416003)(336012)(7696005)(6916009)(356004)(8936002)(426003)(2351001)(186003)(63350400001)(63370400001)(316002)(76176011);DIR:OUT;SFP:1101;SCL:1;SRVR:AM0PR08MB4945;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: 668a5785-dd7d-4fcd-6616-08d7218240cd X-Microsoft-Antispam-Untrusted: BCL:0;PCL:0;RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600148)(711020)(4605104)(1401327)(2017052603328);SRVR:AM0PR08MB4945; X-MS-TrafficTypeDiagnostic: AM0PR08MB4945:|VE1PR08MB4958: X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true X-MS-Oob-TLC-OOBClassifiers: OLM:6430;OLM:6430; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Message-Info-Original: 5AWsxyQavXru4btOTHKzYiy3ru3ySNr/Uc5hvsA5cWR2gs/WhGvvNdFvSFcyPaqCkMxceGX9MEgGx6N7NSARAKiOf/fEoAntmdVkLhJEUuBMWRWqActRJJUMe+a+Y3X40kE8LdnO0UVt3YlBF8NWf8JXjU91tcX+dVlsFVgsxGTHvYadV330iCkC7JVouA99FYQbKCaErz3WgaqVulYWbshF/bJc3lKqwYvkVRe+kKABXtSi574nt5KCTyERPF/Lg2HToldLsG6JFmpCybP0Q9vLv3tFO0tBzbyicMwJL8O1Cye3kL+Tbzf0COxZex887EifiL9or9eiWDopDvKZg1ieSWW7xH6SZC3FH78WppqCopFcTsGH1oVZZN+hKhYhL3JlReyE7PSAxqIkxNuD3Eqz3TeqrWqxyrlk03ONg40= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR08MB4945 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; X-MS-Exchange-Transport-CrossTenantHeadersStripped: DB5EUR03FT047.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: e8fb2f1a-f7d3-4db2-06ac-08d721823a92 NoDisclaimer: True X-Microsoft-Antispam-Message-Info: mC5PFZq/2097t+4kbBPN0vu2QK47bqKySurP2IiVBBVFc4C8DMd3ML+ChNFR4ThkdCRgOIhJDq8PJSSrFnILwbKTs8ZE8OTdkjpVhZH1vTyYmJWg5hOarMHnbWyQfZXFZmmJ5jhh28zsgJuln8M3gg9sr6d/y6CG1+lEdeDIlV2YkYRZfO7Ds8+lRH6DKMlMmXW/x3opV69oDZpM+Jh16MMEthj9xAQEZ0kZRkt81D+qC0QA4hrO7zm3kiTpbtJfkMraUFxPKkTNPIDN6cY26kX4yFfKhtE2RXx3ZSp1DW8PBRQlyF8oqwfeZE8nJCeBk+Z0yvy/dd2/wAPYNTQ66brGNhF4yeFZhj6kGPVqqXPglbef8g1aHaV5jQQUn0riBvmLMAaaXY54CojhXKzYocNGHEksw1s2v2kM8EEXAnw= X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Aug 2019 13:12:41.2332 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 668a5785-dd7d-4fcd-6616-08d7218240cd 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: VE1PR08MB4958 Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,krzysztof.koch@arm.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1565876368; bh=ta/w3EQiRHDORHD1ftALG21qoKVPuffFeBa7ApqdqIE=; h=CC:Content-Type:Date:From:Reply-To:Subject:To; b=B0ttmD2FTX5o8+abjxc2jKngfbUiI0OtFjniEnfsIBpujDIwduj3BZy2s8gW1bqUyDM NQtl15T1bTN2tehSP9AB/b4OFwQlzMEaOYBkx2+HvJPQY4X+rZXVHoPJhQJX75GhfKtEW sze04aAmgRADwQvhAcLEcDNwKbst4KQ7Lzw= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 1. Check if the 'Number of System Localities' provided can be represented in the SLIT table. The table 'Length' field is a 32-bit value while the 'Number of System Localities' field is 64-bit long. 2. Check if the SLIT matrix fits in the table buffer. If N is the SLIT locality count, then the matrix used to represent the localities is N*N bytes long. The ACPI table length must be big enough to fit the matrix. 3. Remove (now) redundant 64x64 bit multiplication. Signed-off-by: Krzysztof Koch Reviewed-by: Sami Mujawar --- Notes: v1: - Validate the 'Number of System Localities' Field [Krzysztof] - Remove redundant 64x64 bit multiplication [Krzysztof] ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Slit/SlitParser.c | 4= 7 +++++++++++++++++--- 1 file changed, 42 insertions(+), 5 deletions(-) diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Slit/Slit= Parser.c b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Slit/SlitPa= rser.c index 17e2166a09d8615b714e0c51d4d93d293fcdf601..e4625ee8b13907893a9b6990ecb= 956baf91cc3b9 100644 --- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Slit/SlitParser.c +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Slit/SlitParser.c @@ -30,7 +30,7 @@ STATIC CONST ACPI_PARSER SlitParser[] =3D { /** Macro to get the value of a System Locality **/ -#define SLIT_ELEMENT(Ptr, i, j) *(Ptr + (MultU64x64 (i, LocalityCount)) + = j) +#define SLIT_ELEMENT(Ptr, i, j) *(Ptr + (i * LocalityCount) + j) =20 /** This function parses the ACPI SLIT table. @@ -57,9 +57,9 @@ ParseAcpiSlit ( ) { UINT32 Offset; - UINT64 Count; - UINT64 Index; - UINT64 LocalityCount; + UINT32 Count; + UINT32 Index; + UINT32 LocalityCount; UINT8* LocalityPtr; CHAR16 Buffer[80]; // Used for AsciiName param of ParseAcpi =20 @@ -87,8 +87,45 @@ ParseAcpiSlit ( return; } =20 + /* + Despite the 'Number of System Localities' being a 64-bit field in SLIT, + the maximum number of localities that can be represented in SLIT is li= mited + by the 'Length' field of the ACPI table. + + Since the ACPI table length field is 32-bit wide. The maximum number of + localities that can be represented in SLIT can be calculated as: + + MaxLocality =3D sqrt (MAX_UINT32 - sizeof (EFI_ACPI_6_3_SYSTEM_LOCALIT= Y_DISTANCE_INFORMATION_TABLE_HEADER)) + =3D 65535 + =3D MAX_UINT16 + */ + if (*SlitSystemLocalityCount > MAX_UINT16) { + IncrementErrorCount (); + Print ( + L"ERROR: The Number of System Localities provided can't be represent= ed " \ + L"in the SLIT table. SlitSystemLocalityCount =3D %ld. " \ + L"MaxLocalityCountAllowed =3D %d.\n", + *SlitSystemLocalityCount, + MAX_UINT16 + ); + return; + } + + LocalityCount =3D (UINT32)*SlitSystemLocalityCount; + + // Make sure system localities fit in the table buffer provided + if (Offset + (LocalityCount * LocalityCount) > AcpiTableLength) { + IncrementErrorCount (); + Print ( + L"ERROR: Invalid Number of System Localities. " \ + L"SlitSystemLocalityCount =3D %ld. AcpiTableLength =3D %d.\n", + *SlitSystemLocalityCount, + AcpiTableLength + ); + return; + } + LocalityPtr =3D Ptr + Offset; - LocalityCount =3D *SlitSystemLocalityCount; =20 // We only print the Localities if the count is less than 16 // If the locality count is more than 16 then refer to the -- 'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)' -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#45728): https://edk2.groups.io/g/devel/message/45728 Mute This Topic: https://groups.io/mt/32886579/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Mon Apr 29 03:39:50 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+45725+1787277+3901457@groups.io; arc=fail (BodyHash is different from the expected one) Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1565874903967793.775724875488; Thu, 15 Aug 2019 06:15:03 -0700 (PDT) Return-Path: X-Received: from EUR04-VI1-obe.outbound.protection.outlook.com (EUR04-VI1-obe.outbound.protection.outlook.com [40.107.8.77]) by groups.io with SMTP; Thu, 15 Aug 2019 06:11:53 -0700 X-Received: from VI1PR0802CA0048.eurprd08.prod.outlook.com (2603:10a6:800:a9::34) by AM6PR08MB4949.eurprd08.prod.outlook.com (2603:10a6:20b:ee::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2178.16; Thu, 15 Aug 2019 13:11:49 +0000 X-Received: from AM5EUR03FT052.eop-EUR03.prod.protection.outlook.com (2a01:111:f400:7e08::208) by VI1PR0802CA0048.outlook.office365.com (2603:10a6:800:a9::34) 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:11:48 +0000 Received-SPF: pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+45725+1787277+3901457@groups.io; helo=web01.groups.io; Received-SPF: TempError (protection.outlook.com: error in processing during lookup of arm.com: DNS Timeout) X-Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by AM5EUR03FT052.mail.protection.outlook.com (10.152.17.161) 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:11:47 +0000 X-Received: ("Tessian outbound 6d016ca6b65d:v26"); Thu, 15 Aug 2019 13:11:47 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: edaed859b901116a X-CR-MTA-TID: 64aa7808 X-Received: from 2c949de86b43.1 (cr-mta-lb-1.cr-mta-net [104.47.6.56]) by 64aa7808-outbound-1.mta.getcheckrecipient.com id A4B108FC-EFE0-41EE-A689-1526ECF96C9E.1; Thu, 15 Aug 2019 13:11:42 +0000 X-Received: from EUR02-VE1-obe.outbound.protection.outlook.com (mail-ve1eur02lp2056.outbound.protection.outlook.com [104.47.6.56]) by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 2c949de86b43.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384); Thu, 15 Aug 2019 13:11:42 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fh8cqxGEeomtDsXVZoVJVlk6QzUxzghyiGcy7e84pw3+p5CVcMThotoYK/b+jyD8p/YlsMHACkaXxMIsXwztTM4Jh9VBd4FjnDpnRjbnYAPUQ4X1m0hy2y6UIXTofNFPi47JTYpwSJpuo6rPnFgujPNzu7DcjPEFZXRR6wYWHepzqsFCkMe2ea2ghnBx+cmajOrNnAWsr2HnuE5TxwWe9/R9YEfYX4wfi9o8l2YMKal8cJ5DcT1CUf6XM+CATu4TtNd9pWYmbkqMoAevCmvxrFXb0+MRMupf36FnLNVxp/7I3lKwgJsygjfGTKFsaUNrxd6p+uERlO2sNhLQlnVkZA== 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=yhei8kaicYL43eJ5pXFMrpXkMmcjvOFP3zeK1lpgBWg=; b=Zp1/ng5w6KjX/TKRU4eJO0jxpW/avCIodSbhYOq5awpOYMnirN+dA0HsKQeYpI/2B0C0/IpowkbmacseKPxpYlP9Ox8sgYtXzk676lUilTUj/8FEWSSE4mTST6THY5aaD3zYuULS7LbagmpvRtST33Q8AfFeXqmGMazldVm08hwYiUgylNoSsUg+quoEnYl1tzEcRUKqgU14+P7cRcWXNxPdOAObNXpty5JZQ4AsRcg60srhV0UxHENt1Pxv7RrCrA/4G+VdzkunXYicETu7VbmRuaxV33qSMOR2Ie+D2+VUDE4glSkWKK9AKegzNnmg6qUKee/4V9Rpxr2cdIbfdg== 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 X-Received: from VI1PR08CA0214.eurprd08.prod.outlook.com (2603:10a6:802:15::23) by DB8PR08MB4955.eurprd08.prod.outlook.com (2603:10a6:10:38::26) 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:38 +0000 X-Received: from DB5EUR03FT062.eop-EUR03.prod.protection.outlook.com (2a01:111:f400:7e0a::202) by VI1PR08CA0214.outlook.office365.com (2603:10a6:802:15::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.2157.18 via Frontend Transport; Thu, 15 Aug 2019 13:11:38 +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) X-Received: from nebula.arm.com (40.67.248.234) by DB5EUR03FT062.mail.protection.outlook.com (10.152.20.197) 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:36 +0000 X-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:35 +0000 X-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:35 +0000 From: "Krzysztof Koch" To: CC: , , , , , Subject: [edk2-devel] [PATCH v1 06/11] ShellPkg: acpiview: SRAT: Validate global pointers before use Date: Thu, 15 Aug 2019 14:11:16 +0100 Message-ID: <20190815131121.52644-7-krzysztof.koch@arm.com> 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)(376002)(39860400002)(346002)(136003)(396003)(2980300002)(199004)(189003)(50466002)(2616005)(186003)(8936002)(478600001)(44832011)(47776003)(53416004)(53936002)(86362001)(48376002)(446003)(26005)(76176011)(4326008)(36756003)(8676002)(63350400001)(81156014)(336012)(426003)(15650500001)(63370400001)(2906002)(126002)(81166006)(476003)(7696005)(486006)(51416003)(2351001)(70206006)(1076003)(305945005)(50226002)(11346002)(5660300002)(6666004)(70586007)(54906003)(6916009)(16586007)(356004)(316002);DIR:OUT;SFP:1101;SCL:1;SRVR:DB8PR08MB4955;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: 651a44f3-b60b-4337-435a-08d7218220b5 X-Microsoft-Antispam-Untrusted: BCL:0;PCL:0;RULEID:(2390118)(7020095)(4652040)(8989299)(5600148)(711020)(4605104)(1401327)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328);SRVR:DB8PR08MB4955; X-MS-TrafficTypeDiagnostic: DB8PR08MB4955:|AM6PR08MB4949: X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true X-MS-Oob-TLC-OOBClassifiers: OLM:3173;OLM:3173; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Message-Info-Original: qvvxQW6nfPmzurM4i50NWXj4jy94d7VtT0sALzacySBR1LXE16bySf6YSK/Hx4hY9yFbmE6HE0tD3NTL/YjxTtY2lFluXUErNLQamUDiBnxpjGijOEWYgLvY6XFwJBc/wLQcwTrrEtQunLy0rVm8HQLGSTLmbngLhECPpO1AKSuzlCNLbpStzhhjl45rsATwXZyxRuRwxQn4sQlnomqsF1Dc/tdMehhrExY1J58IvHw+x96Af0TWpk7dcmVJDITxV3dKHfJ46TyKLiwgLDjgkoVcoKmymWbTXHdp3J3m9VdTPQeXgQMVySIiIJ2WE+LmZXKmxEG1VdMLytA8Cj6ZYqi7q4a7n16zsdmQ4doNaUn3iabzHMsWXuyQSQHZjKw+eeuBrFZLLNs6gU+293QDChEBnJ6moEw+pKmhtUOSr9U= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB8PR08MB4955 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; X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM5EUR03FT052.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: e4fa2b51-0f41-4155-d4f8-08d721821a62 NoDisclaimer: True X-Microsoft-Antispam-Message-Info: bcAZhk3lxBoG7pvrDKSLokAIeeEtjlUffFZfZv+IYv6eyVIeOo4G/HesOrE3vFLibzXT1d4tb0WWIxIHQEzRAGIWPHRbEHCNMgHzf7Fq1uSWH0TLx6dXAKU27JnDqAyBXlK9n8un1ovnSHQCl2MuJjvpxNl2uONT8srvjh1XBdyJNFwi08iFicuPF3Ir24aQBkab1kLwbjAlQVlERwSEenXxAmTxI7DrIcMspu+bTFN7fqMdZ/m42bPWIuY11cAqR5P54ym1mrJcT+659mZwR/OmwKv86/T/DKTZUNh0okmUpXurYCE/e9gXY5AdHCCsB8jbI1LMnU7XefzY18hfNGrU/3TB3BNv0Efiy8iCHzVEga7QwN9cZP3UKpY5bTwYwTs1qBoG2bHvbkL+zRVRMukEYq2KCdxgd1q/GNfc3P4= X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Aug 2019 13:11:47.3679 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 651a44f3-b60b-4337-435a-08d7218220b5 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: AM6PR08MB4949 Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,krzysztof.koch@arm.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1565874899; bh=/P3+hniMWLVXYyybxGtZuyWLnD/joM0SQqxvnDt/6+g=; h=CC:Content-Type:Date:From:Reply-To:Subject:To; b=i/YcxWb8Ycm93PjoGwJFkh0EToSRq5WuU36wLsfVTju0DrQ5oNRZ0Kkl9QhOowB3h9y VHTfw0dYf8V9S6xVfb5r16Ff49Co3smkDjfrKnPuneGmi/U1C5wT4cm0bnWMFz+nKpXgu yH1DW9TED5/L0ywzqW6GtK5SJzpq3QyswbY= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Check if SratRAType and SratRALength pointers have been successfully updated before they are used for further table parsing. Signed-off-by: Krzysztof Koch Reviewed-by: Sami Mujawar --- Notes: v1: - Test against NULL pointers [Krzysztof] ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Srat/SratParser.c | 1= 3 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Srat/Srat= Parser.c b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Srat/SratPa= rser.c index a8aa420487bb6bf29fc38221d0b221573c64b8b3..e09a7db8f5c92b44c96b6c37a44= a39693352b442 100644 --- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Srat/SratParser.c +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Srat/SratParser.c @@ -219,6 +219,19 @@ ParseAcpiSrat ( PARSER_PARAMS (SratResourceAllocationParser) ); =20 + // Check if the values used to control the parsing logic have been + // successfully read. + if ((SratRAType =3D=3D NULL) || + (SratRALength =3D=3D NULL)) { + IncrementErrorCount (); + Print ( + L"ERROR: Insufficient remaining table buffer length to read the " \ + L"Static Resource Allocation structure header. Length =3D %d.\n", + AcpiTableLength - Offset + ); + return; + } + // Make sure the SRAT structure lies inside the table if ((Offset + *SratRALength) > AcpiTableLength) { IncrementErrorCount (); -- 'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)' -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#45725): https://edk2.groups.io/g/devel/message/45725 Mute This Topic: https://groups.io/mt/32886567/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Mon Apr 29 03:39:50 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+45732+1787277+3901457@groups.io; arc=fail (BodyHash is different from the expected one) Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1565876383446425.0814255867772; Thu, 15 Aug 2019 06:39:43 -0700 (PDT) Return-Path: X-Received: from EUR03-VE1-obe.outbound.protection.outlook.com (EUR03-VE1-obe.outbound.protection.outlook.com [40.107.5.88]) by groups.io with SMTP; Thu, 15 Aug 2019 06:13:03 -0700 X-Received: from VI1PR08CA0177.eurprd08.prod.outlook.com (2603:10a6:800:d1::31) by VE1PR08MB4957.eurprd08.prod.outlook.com (2603:10a6:803:110::18) 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:12:59 +0000 X-Received: from DB5EUR03FT020.eop-EUR03.prod.protection.outlook.com (2a01:111:f400:7e0a::206) by VI1PR08CA0177.outlook.office365.com (2603:10a6:800:d1::31) 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:12:59 +0000 Received-SPF: pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+45732+1787277+3901457@groups.io; helo=web01.groups.io; Received-SPF: TempError (protection.outlook.com: error in processing during lookup of arm.com: DNS Timeout) X-Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by DB5EUR03FT020.mail.protection.outlook.com (10.152.20.134) 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:57 +0000 X-Received: ("Tessian outbound 40a263b748b4:v26"); Thu, 15 Aug 2019 13:12:57 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 055b65c859299a90 X-CR-MTA-TID: 64aa7808 X-Received: from f3976feeba6a.1 (cr-mta-lb-1.cr-mta-net [104.47.13.58]) by 64aa7808-outbound-1.mta.getcheckrecipient.com id 40E0421E-AEBD-4CF3-AC6F-B3B9B315C7E3.1; Thu, 15 Aug 2019 13:12:57 +0000 X-Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-he1eur04lp2058.outbound.protection.outlook.com [104.47.13.58]) by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id f3976feeba6a.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384); Thu, 15 Aug 2019 13:12:57 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=CpDH0c1xtZI6JAW8f+SLEaEn9pkhIRx5yZRmofmt4S06NJ8kv567a6T9x5dLOI/JRXNlNe0pA48pXycq3stugbRpJudxKv2/2wugtucToiWjebEff/uYz1bdlwO1h+6tNIQirCgu9bnZpsryFTKcQgglcgInCklRkEK+OHA8ipi2n+6JENe+7YTBRYZLdY4CMfOac2jtSimBMa3gI805nNgk/GUmC+v0nKJZq7qEyjA5AWcZpkKK/q3xklwo8+0xFbSIcwyQFZKMt38qOBkdecmzj2r4iHC0UxUqJ+es0W00p4282UaH9hWaYnf3YrNAQK86xU6QL9JRHk5/apz2xg== 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=SKWDf2dGutztx0ibC/f+O4UEzvCH1S6D9gnhcoSCKZw=; b=XGXkNkr9vzqa96NqQAux99XtiEMO2QEVsNisMdMoSu64cLEYl1E71BIx2E0ElPUR/UztOIcuDIMprA8vGSwaFY0JE8/Do+Pq47kKA+gPXX2VaTi19+ebjA0rl/7vyCGasUC6xWp/RLw3TeDUz/lB8XjxDQEuzEaV1Zvc4KTw4FeEpX0cRqq/OeKqnhuQ0XyGA7e1Cwq7bi6u0rp5u2QqsRE79BRhnGIqSn3lPNNmkcphNd4CA/RKI+knMsX3WuBpWCByvT9E7RPhfs49SWylODw4p5HkFq3nxmNtoC1SYxiq7M+ZmJeyvH/mJ41LDT45e8bjO1rx7FcwHiCBiwKZAQ== 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 X-Received: from VI1PR0802CA0016.eurprd08.prod.outlook.com (2603:10a6:800:aa::26) by VE1PR08MB4960.eurprd08.prod.outlook.com (2603:10a6:803:110::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2157.15; Thu, 15 Aug 2019 13:12:54 +0000 X-Received: from DB5EUR03FT050.eop-EUR03.prod.protection.outlook.com (2a01:111:f400:7e0a::203) by VI1PR0802CA0016.outlook.office365.com (2603:10a6:800:aa::26) 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:54 +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) X-Received: from nebula.arm.com (40.67.248.234) by DB5EUR03FT050.mail.protection.outlook.com (10.152.21.128) 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:53 +0000 X-Received: from AZ-NEU-EX01.Emea.Arm.com (10.251.26.4) by AZ-NEU-EX04.Arm.com (10.251.24.32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.1.1415.2; Thu, 15 Aug 2019 13:11:36 +0000 X-Received: from AZ-NEU-EX04.Arm.com (10.251.24.32) by AZ-NEU-EX01.Emea.Arm.com (10.251.26.4) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1415.2; Thu, 15 Aug 2019 13:11:36 +0000 X-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:35 +0000 From: "Krzysztof Koch" To: CC: , , , , , Subject: [edk2-devel] [PATCH v1 07/11] ShellPkg: acpiview: MADT: Validate global pointers before use Date: Thu, 15 Aug 2019 14:11:17 +0100 Message-ID: <20190815131121.52644-8-krzysztof.koch@arm.com> 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)(376002)(346002)(136003)(396003)(39860400002)(2980300002)(189003)(199004)(54906003)(44832011)(126002)(11346002)(76176011)(51416003)(476003)(2616005)(486006)(446003)(7696005)(478600001)(36756003)(316002)(16586007)(81156014)(81166006)(336012)(63370400001)(6916009)(4326008)(63350400001)(426003)(47776003)(53416004)(50226002)(8936002)(26005)(2351001)(70586007)(70206006)(53936002)(5660300002)(186003)(86362001)(48376002)(356004)(6666004)(50466002)(305945005)(15650500001)(8676002)(2906002)(1076003);DIR:OUT;SFP:1101;SCL:1;SRVR:VE1PR08MB4960;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: b20a90f2-501a-4f75-08c0-08d721824aad X-Microsoft-Antispam-Untrusted: BCL:0;PCL:0;RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600148)(711020)(4605104)(1401327)(2017052603328);SRVR:VE1PR08MB4960; X-MS-TrafficTypeDiagnostic: VE1PR08MB4960:|VE1PR08MB4957: X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true X-MS-Oob-TLC-OOBClassifiers: OLM:5797;OLM:5797; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Message-Info-Original: 4Fj2bJyOas26CtV1fEp5dx0OUKnW+r6xFteTquB/vXgaZLN9PYTttec78LHUzQ5eu/teQzvfFJsCrt080PTkdIioB+4miULeaC0pJBNxvXOoQGqVt3PXQU+ldMnoxSjDlPj0KB9kSvxX99lXosbjZyDnWAEN3KhefJjIuN+LF5Mk0wacLJnXosKp+Q6+CeEyWfGPe3u7jXrJpxq0zez1+ZwCws8jpAhnjbF7h4j7fCN91q3g9SmfE/hhIHzDyzM7BhjI22wKiypMvjKzdgXlPgyGQbPOeCFckkk4eGUykRMX/yXjVL8VANEFFO6jWg6zJ2Jg8EvTFtK2qXkaxiAs6UpYLMCWnPjFVoF/Y+IkdO8qogch/sLVrm0WziUZeJbkSQhwkNV0ZBl2qeJ7oEF9BOIe6upxhpkYpkl+duXZ9So= X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR08MB4960 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; X-MS-Exchange-Transport-CrossTenantHeadersStripped: DB5EUR03FT020.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: 81f5609b-c7a4-4c93-cba8-08d7218247de NoDisclaimer: True X-Microsoft-Antispam-Message-Info: gQd2k/KYARJRfs6giHHsFddmqUwC+puDs1phqiigI07ABiJwhzJ+gpgxxaaO2jdEobwWCr9QcjRVCwDJYgXnqNZEeZfrKJEV84IcJbCjPfWO+DRKe2wJz6u+wD0Q48U0qR1FD4foVZU3vH11RKsOWoNPNNIgPXPd6Ijs7LeFmUH0aLO/AZgh7RRN48CfsI21K1gRQ8fDIkR7i+p8Fm0XkpMEt4hh4kVGDXVIo+zL8hcfPZLuSY0r/4ehNE0fTaTOW9t3b6TRdKdwg1rMk6hbxuWFcd4+WHpy1RufmSI+YFhx7M0zIvyRhIETszqUBbw1+uRvfA2RW+GVUSrvllKLdrjAz/3hodzz3J2Pebrow+wDYXeUqwzvu60ecckZeZrNtXiyph+Nrt4YY5ej6VhXuWG4C31UogsjHqFGOEMz72U= X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Aug 2019 13:12:57.7973 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b20a90f2-501a-4f75-08c0-08d721824aad 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: VE1PR08MB4957 Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,krzysztof.koch@arm.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1565876383; bh=Y6T/dwoazK0YXPEUlhW2gl+SZzv4P8riNq5oJ7ZTrD4=; h=CC:Content-Type:Date:From:Reply-To:Subject:To; b=Kyhnl7bjimeSf7ye7elWx8NZNSwuJ2jSddJrkbCqlb0KZMzbO/M3aYZ1pA3H4wrTFUe byU4t+gIhscwKhVhDKrksC7TYLYRhwtet8O5wJEJOqaSTx9UHv77NOwteJFNXax8i/GNA eDzw6jRDUNAndDfslh0QcsyycGFQf3ZUo78= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Check if the MadtInterruptControllerType and MadtInterruptControllerLength pointers have been successfully updated before they are used for further table parsing. Signed-off-by: Krzysztof Koch Reviewed-by: Sami Mujawar --- Notes: v1: - Test against NULL pointers [Krzysztof] ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Madt/MadtParser.c | 1= 3 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Madt/Madt= Parser.c b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Madt/MadtPa= rser.c index 90bdafea1970db522e8ed96de7c6e986cdaca5ba..438905cb24f58b8b82e8fe61280= e72f765d578d8 100644 --- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Madt/MadtParser.c +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Madt/MadtParser.c @@ -260,6 +260,19 @@ ParseAcpiMadt ( PARSER_PARAMS (MadtInterruptControllerHeaderParser) ); =20 + // Check if the values used to control the parsing logic have been + // successfully read. + if ((MadtInterruptControllerType =3D=3D NULL) || + (MadtInterruptControllerLength =3D=3D NULL)) { + IncrementErrorCount (); + Print ( + L"ERROR: Insufficient remaining table buffer length to read the " \ + L"Interrupt Controller Structure header. Length =3D %d.\n", + AcpiTableLength - Offset + ); + return; + } + // Make sure forward progress is made. if (*MadtInterruptControllerLength < 2) { IncrementErrorCount (); -- 'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)' -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#45732): https://edk2.groups.io/g/devel/message/45732 Mute This Topic: https://groups.io/mt/32886584/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Mon Apr 29 03:39:50 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+45729+1787277+3901457@groups.io; arc=fail (BodyHash is different from the expected one) Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1565876372556314.28090300558176; Thu, 15 Aug 2019 06:39:32 -0700 (PDT) Return-Path: X-Received: from EUR02-AM5-obe.outbound.protection.outlook.com (EUR02-AM5-obe.outbound.protection.outlook.com [40.107.0.81]) by groups.io with SMTP; Thu, 15 Aug 2019 06:12:51 -0700 X-Received: from VI1PR08CA0188.eurprd08.prod.outlook.com (2603:10a6:800:d2::18) by VI1PR0801MB1854.eurprd08.prod.outlook.com (2603:10a6:800:5c::15) 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:46 +0000 X-Received: from VE1EUR03FT008.eop-EUR03.prod.protection.outlook.com (2a01:111:f400:7e09::203) by VI1PR08CA0188.outlook.office365.com (2603:10a6:800:d2::18) 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-SPF: pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+45729+1787277+3901457@groups.io; helo=web01.groups.io; Received-SPF: TempError (protection.outlook.com: error in processing during lookup of arm.com: DNS Timeout) X-Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by VE1EUR03FT008.mail.protection.outlook.com (10.152.18.75) 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:44 +0000 X-Received: ("Tessian outbound 40a263b748b4:v26"); Thu, 15 Aug 2019 13:12:44 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 6cbe08c03f781ee5 X-CR-MTA-TID: 64aa7808 X-Received: from 2a685ec98569.1 (cr-mta-lb-1.cr-mta-net [104.47.12.53]) by 64aa7808-outbound-1.mta.getcheckrecipient.com id B135B823-13E9-4A20-8CF3-AB90D2978AF3.1; Thu, 15 Aug 2019 13:12:38 +0000 X-Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-db3eur04lp2053.outbound.protection.outlook.com [104.47.12.53]) by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 2a685ec98569.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Thu, 15 Aug 2019 13:12:38 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=a08gIdyVhMyBRH81/sHVuctz8/O9Km/blyGX/cJ1oCTAXeub7ScT5yvDADRLrxlBAE7UFuiIVOPkzNO6eCkVaMlqaDHVg4k5cjXEURmXNwnPRDMzsOwTBDz/ZOPF3FV0pEQW8HqZ2Z4DvlYQFzXQd0IU0+6/GxFAVFvfJm1UfnVpLa5gklnqg+yEUJX2cl9B2M2F/DCFk80gxb8t47KKbZg9BUSWd70zWoWTQ0lQ4IVayIlDEMCYSrtVugoexsf/TgZ7lmnyKuiwDKa//fHTafLrAHz5yepMq5G/5215oxTh4tgGMziU7THs/9kxI8GYFDO1hVHxalEV8r/SCpD4/w== 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=l2r57rwFiUji96Hcbj17iquQDRwHQcjb3WeZVndHCug=; b=ZkQO4cbLVQcMcVmZUelinfP8hpEyEmUc5aVdeoC8jzk20FqCAnh3NZRTpiaxtjKn0hu4OsPeFRDdm7SbnXpwCav+XijG31K8thKpeIDW7IXOh6/e5Wo4+0nDwct9AVKw1p6cmZ+tdQj/QD13nRgycndGbGYjucF6twPudZx6aTT3TWY9pMYwDIsmJcf+upaO6yi7eV92koQBufKHvjjag3zG4MnwPD3dHumY5P7x0JnAGD36d+njuCrVv7yAKxwHa5FTx9EJg+Fqa+5QLvsRj8B2J23ILZb9CKxkA2v8D5V6SfoMHZo1V1MJHjK0NtcISd/S6afs0yyXy6Cm2BZdNQ== 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 X-Received: from HE1PR0802CA0008.eurprd08.prod.outlook.com (2603:10a6:3:bd::18) by AM0PR08MB4945.eurprd08.prod.outlook.com (2603:10a6:208:157::22) 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:35 +0000 X-Received: from DB5EUR03FT027.eop-EUR03.prod.protection.outlook.com (2a01:111:f400:7e0a::205) by HE1PR0802CA0008.outlook.office365.com (2603:10a6:3:bd::18) 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:34 +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) X-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:33 +0000 X-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:36 +0000 X-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:36 +0000 From: "Krzysztof Koch" To: CC: , , , , , Subject: [edk2-devel] [PATCH v1 08/11] ShellPkg: acpiview: PPTT: Validate global pointers before use Date: Thu, 15 Aug 2019 14:11:18 +0100 Message-ID: <20190815131121.52644-9-krzysztof.koch@arm.com> 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)(136003)(346002)(376002)(39860400002)(396003)(2980300002)(199004)(189003)(70586007)(11346002)(4326008)(16586007)(446003)(15650500001)(6666004)(8676002)(54906003)(47776003)(36756003)(476003)(81156014)(5660300002)(70206006)(126002)(486006)(2906002)(44832011)(50226002)(81166006)(53936002)(86362001)(26005)(53416004)(305945005)(478600001)(2616005)(1076003)(48376002)(50466002)(51416003)(336012)(7696005)(6916009)(356004)(8936002)(426003)(2351001)(186003)(63350400001)(63370400001)(316002)(76176011);DIR:OUT;SFP:1101;SCL:1;SRVR:AM0PR08MB4945;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: f784f070-b009-406d-6b43-08d7218242ac X-Microsoft-Antispam-Untrusted: BCL:0;PCL:0;RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600148)(711020)(4605104)(1401327)(2017052603328);SRVR:AM0PR08MB4945; X-MS-TrafficTypeDiagnostic: AM0PR08MB4945:|VI1PR0801MB1854: X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true X-MS-Oob-TLC-OOBClassifiers: OLM:3513;OLM:3513; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Message-Info-Original: EHRV46GE8XIUgrYZmimI5Qj8mTwzNUaLEt7F8ntOdZ8oty/TN0fYcsRy2fPefMJzWA1TEvtI/6SuWGZoDlw8Afds4ktLamzTJJLFDU+6+eIAfHIejZEMb9s0szedLqDfu3QnKHJAUxJXIPOVV8sOEajjYq1SL9gfkp/XYbyIeQJT6mp73uu4O4rwzNjPHFRwbgbpI+o334CSN5EErfNLUQeoDtoq3XvlEpevZRC/41eoJNc8DZ1fGISe8PGO7QHGwOE/SB0TAxTKofAsHdVyy4u+snYK2LwCrZuuykOvmWRVlTehjNrsiitQoo7nQ1e/Kb4k7g3IQ8UEHUH8mZweuxaMSN60yhUqIpM6nvSyUEHjHjDvXW4xnpnoSWWthROaAuRK4cB/bP0/kQUlCyU0S5ToD40psjdWMcWs/Hw05aE= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR08MB4945 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; X-MS-Exchange-Transport-CrossTenantHeadersStripped: VE1EUR03FT008.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: 8d65adbd-0f01-4523-ff51-08d721823c14 NoDisclaimer: True X-Microsoft-Antispam-Message-Info: vq3nACWmcMaeAXRD55l+aEHHver1RwhlJwMs2fGO3C0zKIxpzCLwI9ds/84Zyj+Iqwg9eX6E4hq0oHUUqPOnZ0nkM/GU3/yMD7Ul52Zo+3BZJuX5UKz/w3cHmpFMDoSxZa3LLMAPL/KdWnFNdwgrkqVX7RU8MjLl1+qXjJKIdPLnQDxoE7tQR758W0z4JOzZeBTsOCoFGhv5hI+a/vqXz7w5UdReh8Goa7vAr7qqz9cEQqLRMUaY625+mcgh2plY1AfNv40yON7B3c8XbVgy1WzhevF1YBAE4z6D6et1UZVk/yj2xsRrit8UdMPTwjFE9GemAYerU+2LsFVDgZnHPgezvtKcboOCMVS2MTMyQV3er8dLhpuuvk/KezlJsAe38gEe3yRBILAjOj379JtmxwRvTSBVH4FM1a92mB3bSnA= X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Aug 2019 13:12:44.2944 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f784f070-b009-406d-6b43-08d7218242ac 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: VI1PR0801MB1854 Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,krzysztof.koch@arm.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1565876372; bh=tfo5NPjuBd30kKyX/n+iexSCZZ0SVoEISi95Cuj4GBs=; h=CC:Content-Type:Date:From:Reply-To:Subject:To; b=Mnil0zZvoNT9dUNyxloapLGs9Z05it7jeUROcaqw6MuCrDDX5NsdYzg3qDWM+ZPJxcl HXdjNUoR6h98zs5f7xePxdiJoSNq6rbWfxbJ7OaNIVZnw1Ms0lPxoUTrhg90D/ZClBo9x GtObUA0x9AUppxBBYj0+a2xIa1JJGEFA0A0= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Check if the NumberOfPrivateResources, ProcessorTopologyStructureType and ProcessorTopologyStructureLength pointers have been successfully updated before they are used for further table parsing. Signed-off-by: Krzysztof Koch Reviewed-by: Sami Mujawar --- Notes: v1: - Test against NULL pointers [Krzysztof] ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Pptt/PpttParser.c | 2= 5 ++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Pptt/Pptt= Parser.c b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Pptt/PpttPa= rser.c index 6254b9913fffb429fc54bb1301bf3e4b2e5bf161..675ba75f02b367cd5ad9f2ac23c= 30ed0ab58f286 100644 --- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Pptt/PpttParser.c +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Pptt/PpttParser.c @@ -264,6 +264,17 @@ DumpProcessorHierarchyNodeStructure ( PARSER_PARAMS (ProcessorHierarchyNodeStructureParser) ); =20 + // Check if the values used to control the parsing logic have been + // successfully read. + if (NumberOfPrivateResources =3D=3D NULL) { + IncrementErrorCount (); + Print ( + L"ERROR: Insufficient Processor Hierarchy Node length. Length =3D %d= .\n", + Length + ); + return; + } + // Make sure the Private Resource array lies inside this structure if (Offset + (*NumberOfPrivateResources * sizeof (UINT32)) > Length) { IncrementErrorCount (); @@ -387,6 +398,7 @@ ParseAcpiPptt ( AcpiTableLength, PARSER_PARAMS (PpttParser) ); + ProcessorTopologyStructurePtr =3D Ptr + Offset; =20 while (Offset < AcpiTableLength) { @@ -400,6 +412,19 @@ ParseAcpiPptt ( PARSER_PARAMS (ProcessorTopologyStructureHeaderParser) ); =20 + // Check if the values used to control the parsing logic have been + // successfully read. + if ((ProcessorTopologyStructureType =3D=3D NULL) || + (ProcessorTopologyStructureLength =3D=3D NULL)) { + IncrementErrorCount (); + Print ( + L"ERROR: Insufficient remaining table buffer length to read the " \ + L"processor topology structure header. Length =3D %d.\n", + AcpiTableLength - Offset + ); + return; + } + // Make sure the PPTT structure lies inside the table if ((Offset + *ProcessorTopologyStructureLength) > AcpiTableLength) { IncrementErrorCount (); -- 'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)' -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#45729): https://edk2.groups.io/g/devel/message/45729 Mute This Topic: https://groups.io/mt/32886580/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Mon Apr 29 03:39:50 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+45730+1787277+3901457@groups.io; arc=fail (BodyHash is different from the expected one) Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1565876372504953.7722465539123; Thu, 15 Aug 2019 06:39:32 -0700 (PDT) Return-Path: X-Received: from EUR01-VE1-obe.outbound.protection.outlook.com (EUR01-VE1-obe.outbound.protection.outlook.com [40.107.14.88]) by groups.io with SMTP; Thu, 15 Aug 2019 06:12:51 -0700 X-Received: from VI1PR08CA0169.eurprd08.prod.outlook.com (10.175.227.23) by VI1PR0801MB1853.eurprd08.prod.outlook.com (10.168.67.22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2157.13; Thu, 15 Aug 2019 13:12:47 +0000 X-Received: from VE1EUR03FT051.eop-EUR03.prod.protection.outlook.com (2a01:111:f400:7e09::201) by VI1PR08CA0169.outlook.office365.com (2603:10a6:800:d1::23) 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:47 +0000 Received-SPF: pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+45730+1787277+3901457@groups.io; helo=web01.groups.io; Received-SPF: TempError (protection.outlook.com: error in processing during lookup of arm.com: DNS Timeout) X-Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by VE1EUR03FT051.mail.protection.outlook.com (10.152.19.75) 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:45 +0000 X-Received: ("Tessian outbound 1e6e633a5b56:v26"); Thu, 15 Aug 2019 13:12:45 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: ef767dc2ac480e4c X-CR-MTA-TID: 64aa7808 X-Received: from 63101f608e55.1 (cr-mta-lb-1.cr-mta-net [104.47.13.59]) by 64aa7808-outbound-1.mta.getcheckrecipient.com id 7A3A7BD5-AE1B-45CB-86CF-8D3A1D57C750.1; Thu, 15 Aug 2019 13:12:40 +0000 X-Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-he1eur04lp2059.outbound.protection.outlook.com [104.47.13.59]) by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 63101f608e55.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384); Thu, 15 Aug 2019 13:12:40 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=BgA2qV6oXa3nZhKGLjMFyMh+6ouU0tSJTfwmnrVQX2pu5QhXXeiO2s7GWnk80VAwIa4NBxLW3Yr6wWfP/EdKjJ1Ji6VP9d97j7KlgYd3uPUVqY1/1QAhyErj1RxgaMw06NPHrtdK6r7bv6LRXy9D4JgRLTMh/s51MnYoDmF/eL4SfCFQM58+ASWq9+mEpLYy6b31Tr7rItj50jZyX+D953COLDK3TvSrrsNa0D10dxHN1Vw24PRdYeWa4TCJOGvm4sllNH0vV+Q696oQX5rQvW8J5DovU2ZVfe//R9W25bQL+OFeJlktUmoUyQpWtniE4SeUZ7QRczG21GYzvlS76g== 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=BNH4Z0Cf+o+D+yE5YmyZtij3Q/cOmjbsTOMGjUbUNdI=; b=S9zBcdAJ2PZEnqIx357IhwA3Cj3rS0qLaFjZegN9DzatNfYkGxgTyWe0XKpSsTN2CR2x6OVcfanoz1pYp8NdLAlXziXn2eau9gluD6fJPHjJ6QyJ61KGyBXU/8rMjUjblL5J7MgSlWOcn0Pbbj8XAytnPxTt3mioY3DRDfrhW2mUqte2oHV6vIbv4cUmlOjLRODMiIeMVIOdS5V3sPt7HLNVs2tae2A0Ife6DwZB7WFtUuih3Eizpy3/K/+WgZoRMv3bPixtWQPR6bv84QYcFPSzc6B3aTChfQyW47bw3Pk8X33FvAH5K+DIPOu5kBM5yprOsfpsfHybsWgBAlZUEw== 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 X-Received: from VI1PR0802CA0036.eurprd08.prod.outlook.com (2603:10a6:800:a9::22) by DB6PR0801MB1846.eurprd08.prod.outlook.com (2603:10a6:4:35::23) 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:36 +0000 X-Received: from DB5EUR03FT025.eop-EUR03.prod.protection.outlook.com (2a01:111:f400:7e0a::201) by VI1PR0802CA0036.outlook.office365.com (2603:10a6:800:a9::22) 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:36 +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) X-Received: from nebula.arm.com (40.67.248.234) by DB5EUR03FT025.mail.protection.outlook.com (10.152.20.104) 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:34 +0000 X-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:36 +0000 X-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:36 +0000 From: "Krzysztof Koch" To: CC: , , , , , Subject: [edk2-devel] [PATCH v1 09/11] ShellPkg: acpiview: IORT: Validate global pointers before use Date: Thu, 15 Aug 2019 14:11:19 +0100 Message-ID: <20190815131121.52644-10-krzysztof.koch@arm.com> 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)(396003)(376002)(346002)(136003)(39860400002)(2980300002)(189003)(199004)(486006)(70206006)(51416003)(2616005)(126002)(50466002)(476003)(426003)(50226002)(8936002)(336012)(446003)(186003)(48376002)(86362001)(7696005)(70586007)(26005)(2351001)(63350400001)(44832011)(76176011)(11346002)(47776003)(63370400001)(6916009)(2906002)(1076003)(81156014)(54906003)(356004)(81166006)(8676002)(19627235002)(6666004)(36756003)(478600001)(305945005)(53416004)(316002)(15650500001)(53936002)(16586007)(4326008)(5660300002);DIR:OUT;SFP:1101;SCL:1;SRVR:DB6PR0801MB1846;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: 208b374e-d85e-4626-b0c1-08d721824390 X-Microsoft-Antispam-Untrusted: BCL:0;PCL:0;RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600148)(711020)(4605104)(1401327)(2017052603328);SRVR:DB6PR0801MB1846; X-MS-TrafficTypeDiagnostic: DB6PR0801MB1846:|VI1PR0801MB1853: X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true X-MS-Oob-TLC-OOBClassifiers: OLM:6108;OLM:6108; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Message-Info-Original: tQ14S7HSexsERXElhPIq4kZdheaTX8/a4/RoHQ1cvPO5W/8B5NZf89UBUpyEQSzQmkFsnolkUOrqGfI7CJwJGzSbLfeVnjGn6BkaflhustJDOx4GrSkXYmhThHrFKQJbfCOAAQxvBYxYyaRWZpwsDq/1G7d7Ao9SzzZT87P90onQ5KCBaXA1Jr0HTARqC8Z2tBto9cO9Yl5EoD81KW/IG2OWXkkHXIntawlrHSuJ48QhZ5RGDVJMjp3Yq7yLMcIMZU2ac+dWKNDlpI0PBb6loohbBNm8c3wwPdEjno+mV3/PJ6SRksW9zeX0zG5RHRUfVBUAKdNY8RoVyW7bB9xoC6Tk1+Jy/svhGTmGWF+mw+vekRQw39j3VN9dZP9vluuyHK2z6gR/k2BIkxU7nfBa9Nsom2KNIFQn+MRGtihfIH8= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB6PR0801MB1846 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; X-MS-Exchange-Transport-CrossTenantHeadersStripped: VE1EUR03FT051.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: 978b53bc-c408-4aae-97d3-08d721823d0b NoDisclaimer: True X-Microsoft-Antispam-Message-Info: l9HWgxcYxnWaMSdwbmd/HemxbOopkaTLUYhNpAUVQk2TUBwlR7adlPoDqwp4iLi2Qv4hbbJdFbrs4ixpS5oj1fMpnO2uctnKq10NfSykWsBohkkY3kyS7l21ez+qHCHDVcAZSoWD7pZilwXsYB9TFfWHRG8iAX+fof3JGPnDroMlGyD2zeeKCmpMWS8c1Umd8DIeJ5RC4WLo8YdnlAlGCJnj+YMw3mQIPs1rQSDFZzT+YfPc64Pn8VYnKiqviLvftW2BuuxAi8X8dPgo+cigL4WF+q8IYPav3xj3ME3YdUgmrj8ZYNRztYARCxiBSgVcyc5kXQtd5e7PZRmmvHm9iw6NWq6gxbjyK4XPIykoeg7Z30RT9y8MNI2SWBHKol9VSJNZjTgVFi/UqELkttc738if5sFWdgSj4j93UrD2Il8= X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Aug 2019 13:12:45.7974 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 208b374e-d85e-4626-b0c1-08d721824390 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: VI1PR0801MB1853 Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,krzysztof.koch@arm.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1565876372; bh=RqUdEgGyRe2t1C4//L/10jynshXphvL7eMnrDI3BJ60=; h=CC:Content-Type:Date:From:Reply-To:Subject:To; b=wRY1J0nqAtaQ9TC4Xj+RhVktgaroGDdC+ecIYOFgi80bTUIFJotmkabDwbtpEpr3JR4 DwDaY3Go6SBgfxmfuZk/WXJpxwuq4QGeuR3X/1YDsm7t43AfRIlT7vGzE2zTo0EEplH2E WeiW23ABsozYWAx8HI/jFqSLoLDI/2k07co= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Check if global (in the scope of the IORT parser) pointers have been successfully updated before they are used for further table parsing. Signed-off-by: Krzysztof Koch Reviewed-by: Sami Mujawar --- Notes: v1: - Test against NULL pointers [Krzysztof] ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Iort/IortParser.c | 5= 2 ++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Iort/Iort= Parser.c b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Iort/IortPa= rser.c index f1cdb9ac01d848f22ab588d8f824886387c5983d..c43ed4ee5fdd8de409052d57c13= a27811c75c7d0 100644 --- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Iort/IortParser.c +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Iort/IortParser.c @@ -317,6 +317,20 @@ DumpIortNodeSmmuV1V2 ( PARSER_PARAMS (IortNodeSmmuV1V2Parser) ); =20 + // Check if the values used to control the parsing logic have been + // successfully read. + if ((InterruptContextCount =3D=3D NULL) || + (InterruptContextOffset =3D=3D NULL) || + (PmuInterruptCount =3D=3D NULL) || + (PmuInterruptOffset =3D=3D NULL)) { + IncrementErrorCount (); + Print ( + L"ERROR: Insufficient SMMUv1/2 node length. Length =3D %d\n", + Length + ); + return; + } + Offset =3D *InterruptContextOffset; Index =3D 0; =20 @@ -428,6 +442,17 @@ DumpIortNodeIts ( PARSER_PARAMS (IortNodeItsParser) ); =20 + // Check if the values used to control the parsing logic have been + // successfully read. + if (ItsCount =3D=3D NULL) { + IncrementErrorCount (); + Print ( + L"ERROR: Insufficient ITS group length. Length =3D %d.\n", + Length + ); + return; + } + Index =3D 0; =20 while ((Index < *ItsCount) && @@ -612,6 +637,18 @@ ParseAcpiIort ( PARSER_PARAMS (IortParser) ); =20 + // Check if the values used to control the parsing logic have been + // successfully read. + if ((IortNodeCount =3D=3D NULL) || + (IortNodeOffset =3D=3D NULL)) { + IncrementErrorCount (); + Print ( + L"ERROR: Insufficient table length. AcpiTableLength =3D %d.\n", + AcpiTableLength + ); + return; + } + Offset =3D *IortNodeOffset; NodePtr =3D Ptr + Offset; Index =3D 0; @@ -630,6 +667,21 @@ ParseAcpiIort ( PARSER_PARAMS (IortNodeHeaderParser) ); =20 + // Check if the values used to control the parsing logic have been + // successfully read. + if ((IortNodeType =3D=3D NULL) || + (IortNodeLength =3D=3D NULL) || + (IortIdMappingCount =3D=3D NULL) || + (IortIdMappingOffset =3D=3D NULL)) { + IncrementErrorCount (); + Print ( + L"ERROR: Insufficient remaining table buffer length to read the " \ + L"IORT node header. Length =3D %d.\n", + AcpiTableLength - Offset + ); + return; + } + // Make sure the IORT Node is inside the table if ((Offset + (*IortNodeLength)) > AcpiTableLength) { IncrementErrorCount (); -- 'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)' -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#45730): https://edk2.groups.io/g/devel/message/45730 Mute This Topic: https://groups.io/mt/32886581/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Mon Apr 29 03:39:50 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+45731+1787277+3901457@groups.io; arc=fail (BodyHash is different from the expected one) Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1565874782068992.3635135749244; Thu, 15 Aug 2019 06:13:02 -0700 (PDT) Return-Path: X-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 X-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 X-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 Received-SPF: pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+45731+1787277+3901457@groups.io; helo=web01.groups.io; Received-SPF: TempError (protection.outlook.com: error in processing during lookup of arm.com: DNS Timeout) X-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 X-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 X-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 X-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 X-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 X-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) X-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 X-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 X-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: [edk2-devel] [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> 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-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; X-MS-Exchange-Transport-CrossTenantHeadersStripped: DB5EUR03FT063.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: 88960715-134a-481a-ae26-08d721823df2 NoDisclaimer: True 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 Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,krzysztof.koch@arm.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1565874778; bh=li/6h7jDRbFyHmqBET75muyZRDsUy+3aknRMCdHRzH8=; h=CC:Content-Type:Date:From:Reply-To:Subject:To; b=VRdaywZMTLzIg99Pn/lBjPhE5JQ9ZjP3bF41zUjmNrGlZoPecVYK3kt4+H8hkAoOXah j5cNZIjg8g3beO2G6N13zuZ/GCojDj6OENc5YnmiYdsrVQMK/RemBrKfq2HHjyEX1gp6K Bz0J5gd6weo+6FPtlqIoesyVXomkgy/7jMI= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 Reviewed-by: Sami Mujawar --- Notes: v1: - Test against NULL pointers [Krzysztof] ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Gtdt/GtdtParser.c | 3= 7 ++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Gtdt/Gtdt= Parser.c b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Gtdt/GtdtPa= rser.c index 57174e14c80072f12b90e1996ebe8f0002d0c404..699a55b549ec3fa61bbd1568988= 21055dc019199 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) ); =20 + // Check if the values used to control the parsing logic have been + // successfully read. + if ((GtBlockTimerCount =3D=3D NULL) || + (GtBlockTimerOffset =3D=3D NULL)) { + IncrementErrorCount (); + Print ( + L"ERROR: Insufficient GT Block Structure length. Length =3D %d.\n", + Length + ); + return; + } + Offset =3D *GtBlockTimerOffset; Index =3D 0; =20 @@ -272,6 +284,18 @@ ParseAcpiGtdt ( PARSER_PARAMS (GtdtParser) ); =20 + // Check if the values used to control the parsing logic have been + // successfully read. + if ((GtdtPlatformTimerCount =3D=3D NULL) || + (GtdtPlatformTimerOffset =3D=3D NULL)) { + IncrementErrorCount (); + Print ( + L"ERROR: Insufficient table length. AcpiTableLength =3D %d.\n", + AcpiTableLength + ); + return; + } + TimerPtr =3D Ptr + *GtdtPlatformTimerOffset; Offset =3D *GtdtPlatformTimerOffset; Index =3D 0; @@ -290,6 +314,19 @@ ParseAcpiGtdt ( PARSER_PARAMS (GtPlatformTimerHeaderParser) ); =20 + // Check if the values used to control the parsing logic have been + // successfully read. + if ((PlatformTimerType =3D=3D NULL) || + (PlatformTimerLength =3D=3D NULL)) { + IncrementErrorCount (); + Print ( + L"ERROR: Insufficient remaining table buffer length to read the " \ + L"Platform Timer Structure header. Length =3D %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)' -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#45731): https://edk2.groups.io/g/devel/message/45731 Mute This Topic: https://groups.io/mt/32886582/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Mon Apr 29 03:39:50 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+45733+1787277+3901457@groups.io; arc=fail (BodyHash is different from the expected one) Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1565876390507964.184562630184; Thu, 15 Aug 2019 06:39:50 -0700 (PDT) Return-Path: X-Received: from EUR01-DB5-obe.outbound.protection.outlook.com (EUR01-DB5-obe.outbound.protection.outlook.com [40.107.15.81]) by groups.io with SMTP; Thu, 15 Aug 2019 06:13:09 -0700 X-Received: from VI1PR08CA0167.eurprd08.prod.outlook.com (2603:10a6:800:d1::21) by HE1PR0802MB2601.eurprd08.prod.outlook.com (2603:10a6:3:d8::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2178.16; Thu, 15 Aug 2019 13:13:04 +0000 X-Received: from DB5EUR03FT020.eop-EUR03.prod.protection.outlook.com (2a01:111:f400:7e0a::206) by VI1PR08CA0167.outlook.office365.com (2603:10a6:800:d1::21) 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:13:04 +0000 Received-SPF: pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+45733+1787277+3901457@groups.io; helo=web01.groups.io; Received-SPF: TempError (protection.outlook.com: error in processing during lookup of arm.com: DNS Timeout) X-Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by DB5EUR03FT020.mail.protection.outlook.com (10.152.20.134) 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:13:03 +0000 X-Received: ("Tessian outbound 40a263b748b4:v26"); Thu, 15 Aug 2019 13:13:03 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 400698d2cdefa8eb X-CR-MTA-TID: 64aa7808 X-Received: from 8ec41b02b547.1 (cr-mta-lb-1.cr-mta-net [104.47.9.54]) by 64aa7808-outbound-1.mta.getcheckrecipient.com id BB180F35-9BB1-42FE-8792-5512C76E62A2.1; Thu, 15 Aug 2019 13:12:58 +0000 X-Received: from EUR03-VE1-obe.outbound.protection.outlook.com (mail-ve1eur03lp2054.outbound.protection.outlook.com [104.47.9.54]) by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 8ec41b02b547.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384); Thu, 15 Aug 2019 13:12:58 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=XaSFd4fM6ledVegxbMBs/c1pAOvXUluIlX7xfk3Peh0EjQXcbSgfYjEx31fHhovKVkDPwZwx0l3qk7AInpD1bOurjSwaIVosdQj3GeCnW4OlZDe7n4P/x+OX1i24Q8ufJmSoWxhA2cc3OHlCC2V29NKtIub142MnRmQ+/zvKdEsO/W/qhbj71MoujS4lxN5e6v9U4ayAZEzWULPCEZoPYBx1bcfL2g+H6lbhNIDg/O560dIdAs+lGg+UYosVrencAPE9TMOYqJCF73fPTNwOMrz5p/CBcsrNq7yrr4KfCjPFU+Cz1gwV2NxihQ5RPfz9mYGf9y9fn5JLGURF8PKthQ== 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=bHX7GHe/SdQGVmo99dU8M1GGCiCmG+k/3yaXEwSzzl8=; b=O3gTE/iNrkPr0/FBmo0D+rstua5IBv0co8HMk8ASHj3HtqWkpQWHgH62iUkmqqSYyssW7G4j8re0sQyag0xwQzIO7RtNQF2H4yNwpl9daMxErY4rydc31nBAS1ZY8zJD46NBR/LOAmuWmdI9ReBmrk3eMdyxleOyBnm37MpIAqJRyCheb+1G9NNdBwHsDt2EavWWGniSxTKnQCrFpuXJJqsJdDHpUiIv+yxZkbYNB+zBOpCh8QeDBRXrRF/b5GY64JSeVsyFs0UpT8rJXrLiSDINrXLKN8lvrKwVskUnXuISGTdnH6DDlh0MJpBMsCamPwrl3JIAT8Pep0BKyRBnRg== 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 X-Received: from VI1PR0802CA0016.eurprd08.prod.outlook.com (2603:10a6:800:aa::26) by VI1PR0801MB1855.eurprd08.prod.outlook.com (2603:10a6:800:59::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2157.15; Thu, 15 Aug 2019 13:12:55 +0000 X-Received: from DB5EUR03FT050.eop-EUR03.prod.protection.outlook.com (2a01:111:f400:7e0a::203) by VI1PR0802CA0016.outlook.office365.com (2603:10a6:800:aa::26) 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:55 +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) X-Received: from nebula.arm.com (40.67.248.234) by DB5EUR03FT050.mail.protection.outlook.com (10.152.21.128) 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:54 +0000 X-Received: from AZ-NEU-EX01.Emea.Arm.com (10.251.26.4) by AZ-NEU-EX04.Arm.com (10.251.24.32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.1.1415.2; Thu, 15 Aug 2019 13:11:38 +0000 X-Received: from AZ-NEU-EX04.Arm.com (10.251.24.32) by AZ-NEU-EX01.Emea.Arm.com (10.251.26.4) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1415.2; Thu, 15 Aug 2019 13:11:37 +0000 X-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: [edk2-devel] [PATCH v1 11/11] ShellPkg: acpiview: DBG2: Validate global pointers before use Date: Thu, 15 Aug 2019 14:11:21 +0100 Message-ID: <20190815131121.52644-12-krzysztof.koch@arm.com> 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)(53416004)(81156014)(44832011)(36756003)(336012)(2351001)(48376002)(2906002)(63370400001)(5660300002)(426003)(486006)(2616005)(6916009)(63350400001)(126002)(1076003)(50226002)(8936002)(70586007)(446003)(15650500001)(11346002)(70206006)(476003)(81166006)(305945005)(16586007)(6666004)(316002)(50466002)(8676002)(4326008)(26005)(54906003)(7696005)(47776003)(356004)(186003)(53936002)(478600001)(86362001)(76176011)(51416003);DIR:OUT;SFP:1101;SCL:1;SRVR:VI1PR0801MB1855;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: 67c94a5a-e22e-4c2b-30d3-08d721824e1c X-Microsoft-Antispam-Untrusted: BCL:0;PCL:0;RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600148)(711020)(4605104)(1401327)(2017052603328);SRVR:VI1PR0801MB1855; X-MS-TrafficTypeDiagnostic: VI1PR0801MB1855:|HE1PR0802MB2601: X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true X-MS-Oob-TLC-OOBClassifiers: OLM:3383;OLM:3383; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Message-Info-Original: F3OLmqDGQDJqFXKKT/dE+fXL6SPP+d0feIt1dKb3SGX0QyZqvENtf6cyd5OtmweP/9TXccAiTpGZeX6vOv8UzE5EhT8AedsGKE3k032PSj7USfeS4rruXwxY07DCr8iZgQU9sBS94rofjqJ4aSxFsW5PMHQ3550+9wtcO2PoO3vhq96Y01+i7HvdzwGR+egwzrRh1Ju6LZn5twN5fIhOcFkr6GLjObVM5fCwwsDhIvhGJ36vpBYOjcTaZNP0reWzCzLBlOvoEU9rKb6ppvM5mYfPQZpoQlPeLOS9hea2B9wXblITdNT8fqx5hHVv3T6lDydzf91Od0zcFVOKMDychS4DtIxUZ7ZT8+GvzWm+pOol9l0lXx54Kk9K4N+2hheCwnG0PrflB3e0/BTjqOjHJujGlyURMZTc4p3rbSmC9M4= X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0801MB1855 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; X-MS-Exchange-Transport-CrossTenantHeadersStripped: DB5EUR03FT020.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: aaf19ab3-535f-41d1-8835-08d72182489d NoDisclaimer: True X-Microsoft-Antispam-Message-Info: EVacEqgz39EtwxH3fdBfFapqmBdN9SGH6K/Z40CWkQu2dKcBszsHBc9Am2+ctE+oOtcFebT7pnICHiCHBvInjNS/x9Yj089cuf0+gT0JVrwyzgq9q8YNYw4M4XhpXJv+uY4ZqwUu/X8s82g70/MKUl5bF4dBf0USffCfEFyQ35UxeOqslUmx0FCc9IGKsAUfev78/P3379MuLauzA8yF3nVpG3alKrAebC+PN2yYtqDiiWCXhbTf2t7Cmt8ZYD0krtuIHlhO24httzlBN1XPDfC+nj6Uw3hl/SVgl0wMx877eIFk7fdg11eFEGsC19DQNn9Dke9eD21Ox/+8mATo8JaioJXvW8fdWxxiuEtpqKTO0j/XVgMNy7rosymEx5fjPNZSFi1aSXWyNk/tgaeimlRUujQGR3poercNzxdnRuI= X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Aug 2019 13:13:03.5569 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 67c94a5a-e22e-4c2b-30d3-08d721824e1c 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: HE1PR0802MB2601 Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,krzysztof.koch@arm.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1565876390; bh=HhrvNakTYfVjn2wZaXZuD1f+PwR9wQKN4S/Ektc9HlI=; h=CC:Content-Type:Date:From:Reply-To:Subject:To; b=spWFVUj1C5QN9zcLzmL6ErCCwtvQPqbnKS3F16gYcfFpjPGaVYTavOVPHvcB5WbUN7N NxKyxnhJdBPbWb8tyxjeDokWIcjOQW8k3C6ag5weEYC9+g2wpnFdsudrBJsfSXMBkTZFp /D1EPdBWgF9OIEII/ZjsSQDg25F+5vFatZo= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Check if global (in the scope of the DBG2 parser) pointers have been successfully updated before they are used for further table parsing. Signed-off-by: Krzysztof Koch Reviewed-by: Sami Mujawar --- Notes: v1: - Test against NULL pointers [Krzysztof] ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Dbg2/Dbg2Parser.c | 4= 3 ++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Dbg2/Dbg2= Parser.c b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Dbg2/Dbg2Pa= rser.c index 869e700b9beda4886bf7bc5ae4ced3ab9a59efa3..0f730a306a94329a23fbaf54b59= f1833b44616ba 100644 --- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Dbg2/Dbg2Parser.c +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Dbg2/Dbg2Parser.c @@ -123,6 +123,24 @@ DumpDbgDeviceInfo ( PARSER_PARAMS (DbgDevInfoParser) ); =20 + // Check if the values used to control the parsing logic have been + // successfully read. + if ((GasCount =3D=3D NULL) || + (NameSpaceStringLength =3D=3D NULL) || + (NameSpaceStringOffset =3D=3D NULL) || + (OEMDataLength =3D=3D NULL) || + (OEMDataOffset =3D=3D NULL) || + (BaseAddrRegOffset =3D=3D NULL) || + (AddrSizeOffset =3D=3D NULL)) { + IncrementErrorCount (); + Print ( + L"ERROR: Insufficient Debug Device Information Structure length. " \ + L"Length =3D %d.\n", + Length + ); + return; + } + // GAS Index =3D 0; Offset =3D *BaseAddrRegOffset; @@ -224,6 +242,18 @@ ParseAcpiDbg2 ( PARSER_PARAMS (Dbg2Parser) ); =20 + // Check if the values used to control the parsing logic have been + // successfully read. + if ((OffsetDbgDeviceInfo =3D=3D NULL) || + (NumberDbgDeviceInfo =3D=3D NULL)) { + IncrementErrorCount (); + Print ( + L"ERROR: Insufficient table length. AcpiTableLength =3D %d\n", + AcpiTableLength + ); + return; + } + Offset =3D *OffsetDbgDeviceInfo; Index =3D 0; =20 @@ -239,6 +269,19 @@ ParseAcpiDbg2 ( PARSER_PARAMS (DbgDevInfoHeaderParser) ); =20 + // Check if the values used to control the parsing logic have been + // successfully read. + if (DbgDevInfoLen =3D=3D NULL) { + IncrementErrorCount (); + Print ( + L"ERROR: Insufficient remaining table buffer length to read the " \ + L"Debug Device Information structure's 'Length' field. " \ + L"RemainingTableBufferLength =3D %d.\n", + AcpiTableLength - Offset + ); + return; + } + // Make sure the Debug Device Information structure lies inside the ta= ble. if ((Offset + *DbgDevInfoLen) > AcpiTableLength) { IncrementErrorCount (); -- 'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)' -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#45733): https://edk2.groups.io/g/devel/message/45733 Mute This Topic: https://groups.io/mt/32886586/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-