From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from EUR01-HE1-obe.outbound.protection.outlook.com (EUR01-HE1-obe.outbound.protection.outlook.com [40.107.13.78]) by mx.groups.io with SMTP id smtpd.web09.10302.1581952961031418714 for ; Mon, 17 Feb 2020 07:22:41 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@armh.onmicrosoft.com header.s=selector2-armh-onmicrosoft-com header.b=jp48C44Z; spf=pass (domain: arm.com, ip: 40.107.13.78, mailfrom: krzysztof.koch@arm.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=8KbLPAFS/svV+Ky5UmYZoVe4catFRF152jnDaAXVy5c=; b=jp48C44Z5B48zdglt3ITHcXzvMOnCuLON1iezLg/t0Vel0oyRShiCGrSCJBp8+pGRRWIkfQ0iu+oD5aAKe5EHwb2Oa6AZ1EcIQCC14kg8m9o24IzLZqJXKh7keAJlUWXM2GTa7WRN9XD1qdTyfj0x6lzZ/Wx7JXsDLcMXhTmMms= Received: from HE1PR08CA0069.eurprd08.prod.outlook.com (2603:10a6:7:2a::40) by AM7PR08MB5351.eurprd08.prod.outlook.com (2603:10a6:20b:dc::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2729.25; Mon, 17 Feb 2020 15:22:37 +0000 Received: from VE1EUR03FT053.eop-EUR03.prod.protection.outlook.com (2a01:111:f400:7e09::207) by HE1PR08CA0069.outlook.office365.com (2603:10a6:7:2a::40) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2729.22 via Frontend Transport; Mon, 17 Feb 2020 15:22:37 +0000 Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; edk2.groups.io; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;edk2.groups.io; dmarc=bestguesspass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 63.35.35.123 as permitted sender) receiver=protection.outlook.com; client-ip=63.35.35.123; helo=64aa7808-outbound-1.mta.getcheckrecipient.com; Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by VE1EUR03FT053.mail.protection.outlook.com (10.152.19.198) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2665.18 via Frontend Transport; Mon, 17 Feb 2020 15:22:37 +0000 Received: ("Tessian outbound 846b976b3941:v42"); Mon, 17 Feb 2020 15:22:37 +0000 X-CR-MTA-TID: 64aa7808 Received: from 9e6cfc0e968d.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id DECB8A60-C37D-4F10-9806-C22829FB5D56.1; Mon, 17 Feb 2020 15:22:32 +0000 Received: from EUR05-DB8-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 9e6cfc0e968d.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Mon, 17 Feb 2020 15:22:32 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=dmqoKjNr3I2DlqdOJgM6fVy2HbzwIVBmkengHzAZyeloVdx4iZNP4rTv4Tyyaa62cNDzEdUr8cGr2gZAeL9AFHQX/zDb4cFvZm8/mWCHbT6qLZXe9d/o8Fs8f9+FCIfYNgZnJKfbm3q2nCSvbZ+hMuwOdZyEX+YCM5XkDiztC0IPcuNCYZC628Kr7Re4zW59NaQZzICwTWe5+yd60EmH5R8OnvhMgz/swDun8jQwWZ2OmPnAuiP6AXCgjB2JXuE9m7FzL6Dj5tblrHgZOmfuFlA5w4wntjolHss2neuKSemEOGsnoMjiCeoAH+Gkbxl8JYfRC6E2xzcvsg6UkMHRhw== 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=8KbLPAFS/svV+Ky5UmYZoVe4catFRF152jnDaAXVy5c=; b=fcO2cGyh+qPzTktXrK/1/qhwqjQ1PNIzoNhx9xkFcRJ9UiBhtnMV3Dhc/sxHICd0VcpXNTa766oHRmsxZBxm69MeEcRUEuwsWCLbZ0FuGXDeYR2m6hpqyon+TgFKKtEfmY5R9CYKE5mnskyF1V6eVgbCorjz1p46Rl+w1hXkHvJdiFZjus5Nifb5r5opsyRHbKLSYgVA9OoqejET+JBgyHWrEm0IkbwRcq7NccOZ3M0zINNTH2K+qiDC5GeV4bDCOi1HhS5JSFqJFOo3LreRR6EZe9dj5UaSQG//t3uQ/cdhi/h5sG3rrcNsZlncpipcLzoxepUtCybrMd7U/onN8g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=8KbLPAFS/svV+Ky5UmYZoVe4catFRF152jnDaAXVy5c=; b=jp48C44Z5B48zdglt3ITHcXzvMOnCuLON1iezLg/t0Vel0oyRShiCGrSCJBp8+pGRRWIkfQ0iu+oD5aAKe5EHwb2Oa6AZ1EcIQCC14kg8m9o24IzLZqJXKh7keAJlUWXM2GTa7WRN9XD1qdTyfj0x6lzZ/Wx7JXsDLcMXhTmMms= Received: from AM5PR0801MB1777.eurprd08.prod.outlook.com (10.169.246.139) by AM5PR0801MB1970.eurprd08.prod.outlook.com (10.168.157.142) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2729.24; Mon, 17 Feb 2020 15:22:30 +0000 Received: from AM5PR0801MB1777.eurprd08.prod.outlook.com ([fe80::b4c3:e06e:b199:7af3]) by AM5PR0801MB1777.eurprd08.prod.outlook.com ([fe80::b4c3:e06e:b199:7af3%3]) with mapi id 15.20.2729.032; Mon, 17 Feb 2020 15:22:30 +0000 From: "Krzysztof Koch" To: "devel@edk2.groups.io" , "liming.gao@intel.com" CC: "Ni, Ray" , "Gao, Zhichao" , Sami Mujawar , Matteo Carlini , nd Subject: Re: [edk2-devel] [PATCH v1 1/1] ShellPkg: acpiview: Prevent infinite loop if structure length is 0 Thread-Topic: [edk2-devel] [PATCH v1 1/1] ShellPkg: acpiview: Prevent infinite loop if structure length is 0 Thread-Index: AQHV4z8ODQS1EMenHEmJTXu6P/S/Oqgfgj2QgAABB6A= Date: Mon, 17 Feb 2020 15:22:30 +0000 Message-ID: References: <20200214135906.34344-1-krzysztof.koch@arm.com> In-Reply-To: Accept-Language: en-GB, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ts-tracking-id: b3b27a59-a745-42f4-8a4a-3594bdee260b.0 x-checkrecipientchecked: true Authentication-Results-Original: spf=none (sender IP is ) smtp.mailfrom=Krzysztof.Koch@arm.com; x-originating-ip: [217.140.106.55] x-ms-publictraffictype: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 773171b4-fa71-40ee-b343-08d7b3bd3891 X-MS-TrafficTypeDiagnostic: AM5PR0801MB1970:|AM5PR0801MB1970:|AM7PR08MB5351: x-ms-exchange-transport-forked: True X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true nodisclaimer: true x-ms-oob-tlc-oobclassifiers: OLM:4303;OLM:4303; x-forefront-prvs: 0316567485 X-Forefront-Antispam-Report-Untrusted: SFV:NSPM;SFS:(10009020)(4636009)(366004)(39860400002)(396003)(346002)(376002)(136003)(199004)(189003)(8936002)(81156014)(110136005)(81166006)(54906003)(316002)(52536014)(8676002)(9686003)(64756008)(66476007)(33656002)(30864003)(5660300002)(55016002)(66946007)(76116006)(71200400001)(478600001)(66446008)(66556008)(6506007)(53546011)(86362001)(966005)(2906002)(186003)(7696005)(26005)(4326008);DIR:OUT;SFP:1101;SCL:1;SRVR:AM5PR0801MB1970;H:AM5PR0801MB1777.eurprd08.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;A:1;MX:1; received-spf: None (protection.outlook.com: arm.com does not designate permitted sender hosts) X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: FTR3M76Y4T2pt4+Hhvm0S/bXfCIJhbCnedtFS2gUZRiM9x/TE+FzANhUbaBeCC6jtrUTVg9hzScI/J3o5CKwwj+pPLN4nWIoQnd7VcJbXKguwWaG+0/UoOaHc8AhgNBCRywtNhzXGCxk6gW3MDQdWj6PXHL8Inym+j3rxrGHqSdf+rxSyUUbAnsiDsoCWzdcCsnkvwSNNvcWl8qeI6PkO4X4EvencX+zKdxnvwvn8SDb6ZJHkmUVam6uVQPTwef/a97d/xoRGCn0XBZRw+PDHYPmnpz03EE0wEhoIafYYKA/UnwizPbIz9uLySjukrOvZLsX8kuvZqnSvKb1hsCwUqi8hNxYMT4uPcEprntZ/axv2RjIAQagmECb1NE8IyO/hkPQIxXIAaL6P5W3bFzeHpbbf/cT9yW5OSK7UxcWEX+/65zKpxon++QemhmUbqbeDOdoM3JvzudsjOWW1RpXDQHzNMe0NqkCi+02atfZWcICmUFuJwu7XTZEhOnwQTTACHNse4YzZ2r2gIV5V21IoA== x-ms-exchange-antispam-messagedata: 8ekWMp+OIAwxHL/tw3nHtPZwEd2OuhJLDGn3/a9DbxSW+PAKWMRgq4k3dAPeTT4ylqriZifTPClpPS33mQT4F3rL7aV/rTPCynUBZ9Myl8FbvfQ08w48kYH11Fq+NFhQHncdvz/lCnX1cp8g2FLAag== MIME-Version: 1.0 X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM5PR0801MB1970 Original-Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Krzysztof.Koch@arm.com; Return-Path: Krzysztof.Koch@arm.com X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: VE1EUR03FT053.eop-EUR03.prod.protection.outlook.com X-Forefront-Antispam-Report: CIP:63.35.35.123;IPV:CAL;SCL:-1;CTRY:IE;EFV:NLI;SFV:NSPM;SFS:(10009020)(4636009)(39860400002)(396003)(346002)(136003)(376002)(189003)(199004)(966005)(5660300002)(9686003)(356004)(30864003)(55016002)(478600001)(2906002)(26826003)(70586007)(7696005)(4326008)(54906003)(8676002)(70206006)(110136005)(81156014)(81166006)(52536014)(336012)(53546011)(33656002)(8936002)(26005)(6506007)(86362001)(316002)(186003)(36906005);DIR:OUT;SFP:1101;SCL:1;SRVR:AM7PR08MB5351;H:64aa7808-outbound-1.mta.getcheckrecipient.com;FPR:;SPF:Pass;LANG:en;PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com;MX:1;A:1; X-MS-Office365-Filtering-Correlation-Id-Prvs: f5f07850-e139-4324-199f-08d7b3bd3478 X-Forefront-PRVS: 0316567485 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: wyBQigLUFeZGsgNzj4L/69QWNS6heNgYWXEsqw+99gl+iduaY56hgY7bq3963LzYa8wdKfae2INlC9znM8kzsTFuc1PK06WrjOZPrKwY5UbCM/ho1AWA302K6c8UtWC1ny1Yl2sfKsaalVu+P7gxaPh3D008QzSBzobKTWgWejkZgioyEjCmAbRviKirOkogBXzHURULV1iUJvZ6PoZNOVFH9kTtOfp5Dn6iBVcxuZ9tssYBEimbZyvgNbiiG2pTLAs4bFaVp0JhwII4r8EfOuRBfSc6QY7P9jf6Vb5wWO92PxtODHaop57lGsUlXIOaNgkw+YWMCJMx7tFZyL9oWOKB722QZ8r4bvfKFjzrfTYXJus39m649JudmneycyCLUj5OIEZGt7Ta0DFOp5P33XhRJ3On7DUdVV3Nx78WBRxEiZaCnTOP8e1xWWakxBW1+7u2BUgcBfvmuAT5JVAE262tYOyWTBkjnA7FGwYPbUraij3mqXpFHEX9M1FQNhD3K4oxnRYtKC7NVSU0y2kW+A== X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Feb 2020 15:22:37.4097 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 773171b4-fa71-40ee-b343-08d7b3bd3891 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: AM7PR08MB5351 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Hi Liming, I haven't created a BZ yet, shall I create one? It would be great if the p= atch makes it to the stable tag. Over the last few months I added some security features to acpiview. They = make this debug tool less sensitive to exploits from ACPI tables. This patc= h completes my efforts in making the tool more reliable. Kind regards, Krzysztof -----Original Message----- From: devel@edk2.groups.io On Behalf Of Liming Gao = via Groups.Io Sent: Monday, February 17, 2020 15:11 To: devel@edk2.groups.io; Krzysztof Koch Cc: Ni, Ray ; Gao, Zhichao ; Sami= Mujawar ; Matteo Carlini ; n= d Subject: Re: [edk2-devel] [PATCH v1 1/1] ShellPkg: acpiview: Prevent infin= ite loop if structure length is 0 Krzysztof: Is there one BZ for this issue? Does this patch catch to this edk2 stabl= e tag 202002? Thanks Liming > -----Original Message----- > From: devel@edk2.groups.io On Behalf Of=20 > Krzysztof Koch > Sent: Friday, February 14, 2020 9:59 PM > To: devel@edk2.groups.io > Cc: Ni, Ray ; Gao, Zhichao ;=20 > Sami.Mujawar@arm.com; Matteo.Carlini@arm.com; nd@arm.com > Subject: [edk2-devel] [PATCH v1 1/1] ShellPkg: acpiview: Prevent=20 > infinite loop if structure length is 0 >=20 > Extend validation of ACPI structure lengths which are read from the=20 > ACPI table being parsed. Additionally check if the structure 'Length' > field value is positive. If not, stop parsing the faulting table. >=20 > Some ACPI tables define internal structures of variable size. The=20 > 'Length' field inside the substructure is used to update a pointer=20 > used for table traversal. If the byte-length of the structure is equal= =20 > to 0, acpiview can enter an infinite loop. This condition can occur=20 > if, for example, the zero-allocated ACPI table buffer is not fully popul= ated. > This is typically a bug on the ACPI table writer side. >=20 > In short, this method helps acpiview recover gracefully from a=20 > zero-valued ACPI structure length. >=20 > Signed-off-by: Krzysztof Koch > --- >=20 > Changes can be seen at:=20 > https://github.com/KrzysztofKoch1/edk2/tree/612_acpiview_prevent_inf_l > oops_v1 >=20 > Notes: > v1: > - prevent infinite loops in acpiview parsers [Krzysztof] >=20 > > ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Dbg2/Dbg2Parser.c= =20 > | 15 ++++++----- > ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Gtdt/GtdtParser.c= =20 > | 13 ++++----- > ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Iort/IortParser.c= =20 > | 14 +++++----- > ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Madt/MadtParser.c= =20 > | 28 ++++++-------------- > ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Pptt/PpttParser.c= =20 > | 15 ++++++----- > ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Srat/SratParser.c= =20 > | 14 +++++----- > 6 files changed, 47 insertions(+), 52 deletions(-) >=20 > diff --git=20 > a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Dbg2/Dbg2Parser > .c=20 > b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Dbg2/Dbg2Parser > .c index=20 > 0f730a306a94329a23fbaf54b59f1833b44616ba..9df111ecaa7d7a703a13a39c243e > d78b9f12ee97 100644 > ---=20 > a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Dbg2/Dbg2Parser > .c > +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Dbg2/Dbg2Pa > +++ rser.c > @@ -1,7 +1,7 @@ > /** @file > DBG2 table parser >=20 > - Copyright (c) 2016 - 2019, ARM Limited. All rights reserved. > + Copyright (c) 2016 - 2020, ARM Limited. All rights reserved. > SPDX-License-Identifier: BSD-2-Clause-Patent >=20 > @par Reference(s): > @@ -282,15 +282,16 @@ ParseAcpiDbg2 ( > return; > } >=20 > - // Make sure the Debug Device Information structure lies inside the= table. > - if ((Offset + *DbgDevInfoLen) > AcpiTableLength) { > + // Validate Debug Device Information Structure length > + if ((*DbgDevInfoLen =3D=3D 0) || > + ((Offset + (*DbgDevInfoLen)) > AcpiTableLength)) { > IncrementErrorCount (); > Print ( > - L"ERROR: Invalid Debug Device Information structure length. " \ > - L"DbgDevInfoLen =3D %d. RemainingTableBufferLength =3D %d. " = \ > - L"DBG2 parsing aborted.\n", > + L"ERROR: Invalid Debug Device Information Structure length. " \ > + L"Length =3D %d. Offset =3D %d. AcpiTableLength =3D %d.\n", > *DbgDevInfoLen, > - AcpiTableLength - Offset > + Offset, > + AcpiTableLength > ); > return; > } > diff --git=20 > a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Gtdt/GtdtParser > .c=20 > b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Gtdt/GtdtParser > .c index=20 > 699a55b549ec3fa61bbd156898821055dc019199..bdd30ff45c61142c071ead63a27b > abab8998721b 100644 > ---=20 > a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Gtdt/GtdtParser > .c > +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Gtdt/GtdtPa > +++ rser.c > @@ -1,7 +1,7 @@ > /** @file > GTDT table parser >=20 > - Copyright (c) 2016 - 2019, ARM Limited. All rights reserved. > + Copyright (c) 2016 - 2020, ARM Limited. All rights reserved. > SPDX-License-Identifier: BSD-2-Clause-Patent >=20 > @par Reference(s): > @@ -327,15 +327,16 @@ ParseAcpiGtdt ( > return; > } >=20 > - // Make sure the Platform Timer is inside the table. > - if ((Offset + *PlatformTimerLength) > AcpiTableLength) { > + // Validate Platform Timer Structure length > + if ((*PlatformTimerLength =3D=3D 0) || > + ((Offset + (*PlatformTimerLength)) > AcpiTableLength)) { > IncrementErrorCount (); > Print ( > L"ERROR: Invalid Platform Timer Structure length. " \ > - L"PlatformTimerLength =3D %d. RemainingTableBufferLength =3D = %d. " \ > - L"GTDT parsing aborted.\n", > + L"Length =3D %d. Offset =3D %d. AcpiTableLength =3D %d.\n", > *PlatformTimerLength, > - AcpiTableLength - Offset > + Offset, > + AcpiTableLength > ); > return; > } > diff --git=20 > a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Iort/IortParser > .c=20 > b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Iort/IortParser > .c index=20 > 9d5d937c7b2c19945ca2ad3eba644bdfc09cc3f6..9a006a01448b897865cd7cd85651 > c816933acf05 100644 > ---=20 > a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Iort/IortParser > .c > +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Iort/IortPa > +++ rser.c > @@ -1,7 +1,7 @@ > /** @file > IORT table parser >=20 > - Copyright (c) 2016 - 2019, ARM Limited. All rights reserved. > + Copyright (c) 2016 - 2020, ARM Limited. All rights reserved. > SPDX-License-Identifier: BSD-2-Clause-Patent >=20 > @par Reference(s): > @@ -687,14 +687,16 @@ ParseAcpiIort ( > return; > } >=20 > - // Make sure the IORT Node is inside the table > - if ((Offset + (*IortNodeLength)) > AcpiTableLength) { > + // Validate IORT Node length > + if ((*IortNodeLength =3D=3D 0) || > + ((Offset + (*IortNodeLength)) > AcpiTableLength)) { > IncrementErrorCount (); > Print ( > - L"ERROR: Invalid IORT node length. IortNodeLength =3D %d. " \ > - L"RemainingTableBufferLength =3D %d. IORT parsing aborted.\n"= , > + L"ERROR: Invalid IORT Node length. " \ > + L"Length =3D %d. Offset =3D %d. AcpiTableLength =3D %d.\n", > *IortNodeLength, > - AcpiTableLength - Offset > + Offset, > + AcpiTableLength > ); > return; > } > diff --git=20 > a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Madt/MadtParser > .c=20 > b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Madt/MadtParser > .c index=20 > 438905cb24f58b8b82e8fe61280e72f765d578d8..f85d2b36532cfc5db36fe7bef983 > 0cccc64969cc 100644 > ---=20 > a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Madt/MadtParser > .c > +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Madt/MadtPa > +++ rser.c > @@ -1,7 +1,7 @@ > /** @file > MADT table parser >=20 > - Copyright (c) 2016 - 2019, ARM Limited. All rights reserved. > + Copyright (c) 2016 - 2020, ARM Limited. All rights reserved. > SPDX-License-Identifier: BSD-2-Clause-Patent >=20 > @par Reference(s): > @@ -273,28 +273,16 @@ ParseAcpiMadt ( > return; > } >=20 > - // Make sure forward progress is made. > - if (*MadtInterruptControllerLength < 2) { > + // Validate Interrupt Controller Structure length > + if ((*MadtInterruptControllerLength =3D=3D 0) || > + ((Offset + (*MadtInterruptControllerLength)) >=20 > + AcpiTableLength)) { > IncrementErrorCount (); > Print ( > - L"ERROR: Structure length is too small: " \ > - L"MadtInterruptControllerLength =3D %d. " \ > - L"MadtInterruptControllerType =3D %d. MADT parsing aborted.\n= ", > + L"ERROR: Invalid Interrupt Controller Structure length. " \ > + L"Length =3D %d. Offset =3D %d. AcpiTableLength =3D %d.\n", > *MadtInterruptControllerLength, > - *MadtInterruptControllerType > - ); > - return; > - } > - > - // Make sure the MADT structure lies inside the table > - if ((Offset + *MadtInterruptControllerLength) > AcpiTableLength) { > - IncrementErrorCount (); > - Print ( > - L"ERROR: Invalid MADT structure length. " \ > - L"MadtInterruptControllerLength =3D %d. " \ > - L"RemainingTableBufferLength =3D %d. MADT parsing aborted.\n"= , > - *MadtInterruptControllerLength, > - AcpiTableLength - Offset > + Offset, > + AcpiTableLength > ); > return; > } > diff --git=20 > a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Pptt/PpttParser > .c=20 > b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Pptt/PpttParser > .c index=20 > 675ba75f02b367cd5ad9f2ac23c30ed0ab58f286..0db272c16af0ad8824c8da4c88dd > 409c8550112a 100644 > ---=20 > a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Pptt/PpttParser > .c > +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Pptt/PpttPa > +++ rser.c > @@ -1,7 +1,7 @@ > /** @file > PPTT table parser >=20 > - Copyright (c) 2019, ARM Limited. All rights reserved. > + Copyright (c) 2019 - 2020, ARM Limited. All rights reserved. > SPDX-License-Identifier: BSD-2-Clause-Patent >=20 > @par Reference(s): > @@ -425,15 +425,16 @@ ParseAcpiPptt ( > return; > } >=20 > - // Make sure the PPTT structure lies inside the table > - if ((Offset + *ProcessorTopologyStructureLength) > AcpiTableLength)= { > + // Validate Processor Topology Structure length > + if ((*ProcessorTopologyStructureLength =3D=3D 0) || > + ((Offset + (*ProcessorTopologyStructureLength)) >=20 > + AcpiTableLength)) { > IncrementErrorCount (); > Print ( > - L"ERROR: Invalid PPTT structure length. " \ > - L"ProcessorTopologyStructureLength =3D %d. " \ > - L"RemainingTableBufferLength =3D %d. PPTT parsing aborted.\n"= , > + L"ERROR: Invalid Processor Topology Structure length. " \ > + L"Length =3D %d. Offset =3D %d. AcpiTableLength =3D %d.\n", > *ProcessorTopologyStructureLength, > - AcpiTableLength - Offset > + Offset, > + AcpiTableLength > ); > return; > } > diff --git=20 > a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Srat/SratParser > .c=20 > b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Srat/SratParser > .c index=20 > 3613900ae322483fdd3d3383de4e22ba75b2128b..6f66be68cc0bed14811a0432c61a > 79fd47c54890 100644 > ---=20 > a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Srat/SratParser > .c > +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Srat/SratPa > +++ rser.c > @@ -1,7 +1,7 @@ > /** @file > SRAT table parser >=20 > - Copyright (c) 2016 - 2019, ARM Limited. All rights reserved. > + Copyright (c) 2016 - 2020, ARM Limited. All rights reserved. > SPDX-License-Identifier: BSD-2-Clause-Patent >=20 > @par Reference(s): > @@ -412,14 +412,16 @@ ParseAcpiSrat ( > return; > } >=20 > - // Make sure the SRAT structure lies inside the table > - if ((Offset + *SratRALength) > AcpiTableLength) { > + // Validate Static Resource Allocation Structure length > + if ((*SratRALength =3D=3D 0) || > + ((Offset + (*SratRALength)) > AcpiTableLength)) { > IncrementErrorCount (); > Print ( > - L"ERROR: Invalid SRAT structure length. SratRALength =3D %d. " = \ > - L"RemainingTableBufferLength =3D %d. SRAT parsing aborted.\n"= , > + L"ERROR: Invalid Static Resource Allocation Structure length. "= \ > + L"Length =3D %d. Offset =3D %d. AcpiTableLength =3D %d.\n", > *SratRALength, > - AcpiTableLength - Offset > + Offset, > + AcpiTableLength > ); > return; > } > -- > 'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)' >=20 >=20 >=20