From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: mx.groups.io; dkim=pass header.i=@armh.onmicrosoft.com header.s=selector2-armh-onmicrosoft-com header.b=8812Z0+L; spf=pass (domain: arm.com, ip: 40.107.8.77, mailfrom: krzysztof.koch@arm.com) 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 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=yhei8kaicYL43eJ5pXFMrpXkMmcjvOFP3zeK1lpgBWg=; b=8812Z0+LploPJk6F2slKJGaBVWRmP+YDob93dY7h9ChBHGUMZkx9egPtD3pQzEjMOlzoua9tOhoWWH2HNx5DUojt55hT039NcaYPXt6iNMA/lFILtkkFh7FDlPD1Jnk0rllDsz+zfOyMVxJ8mdz6itF0xFShmGV9wIElPpkrf14= 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 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 Authentication-Results: spf=temperror (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; edk2.groups.io; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;edk2.groups.io; dmarc=temperror action=none header.from=arm.com; Received-SPF: TempError (protection.outlook.com: error in processing during lookup of arm.com: DNS Timeout) Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by 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 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 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 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 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=yhei8kaicYL43eJ5pXFMrpXkMmcjvOFP3zeK1lpgBWg=; b=8812Z0+LploPJk6F2slKJGaBVWRmP+YDob93dY7h9ChBHGUMZkx9egPtD3pQzEjMOlzoua9tOhoWWH2HNx5DUojt55hT039NcaYPXt6iNMA/lFILtkkFh7FDlPD1Jnk0rllDsz+zfOyMVxJ8mdz6itF0xFShmGV9wIElPpkrf14= 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 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) 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 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 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: [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> X-Mailer: git-send-email 2.16.2.windows.1 In-Reply-To: <20190815131121.52644-1-krzysztof.koch@arm.com> References: <20190815131121.52644-1-krzysztof.koch@arm.com> MIME-Version: 1.0 X-EOPAttributedMessage: 1 X-MS-Office365-Filtering-HT: Tenant X-Forefront-Antispam-Report-Untrusted: CIP:40.67.248.234;IPV:NLI;CTRY:IE;EFV:NLI;SFV:NSPM;SFS:(10009020)(4636009)(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-Forefront-PRVS: 01304918F3 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; Return-Path: Krzysztof.Koch@arm.com X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM5EUR03FT052.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)(376002)(39860400002)(346002)(396003)(136003)(2980300002)(199004)(189003)(6666004)(16586007)(316002)(76176011)(36906005)(54906003)(63350400001)(63370400001)(426003)(11346002)(70206006)(70586007)(446003)(186003)(7696005)(336012)(51416003)(26005)(6916009)(305945005)(22756006)(8676002)(486006)(76130400001)(44832011)(476003)(2616005)(126002)(2351001)(50466002)(4326008)(478600001)(81156014)(81166006)(15650500001)(48376002)(26826003)(5660300002)(50226002)(47776003)(2906002)(8936002)(36756003)(53416004)(86362001)(1076003);DIR:OUT;SFP:1101;SCL:1;SRVR:AM6PR08MB4949;H:64aa7808-outbound-1.mta.getcheckrecipient.com;FPR:;SPF:TempError;LANG:en;PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com;A:1;MX:1; X-MS-Office365-Filtering-Correlation-Id-Prvs: e4fa2b51-0f41-4155-d4f8-08d721821a62 X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600148)(710020)(711020)(4605104)(1401327)(2017052603328);SRVR:AM6PR08MB4949; NoDisclaimer: True X-Forefront-PRVS: 01304918F3 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 Content-Type: text/plain Check if SratRAType and SratRALength pointers have been successfully updated before they are used for further table parsing. Signed-off-by: Krzysztof Koch --- Notes: v1: - Test against NULL pointers [Krzysztof] ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Srat/SratParser.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Srat/SratParser.c b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Srat/SratParser.c index a8aa420487bb6bf29fc38221d0b221573c64b8b3..e09a7db8f5c92b44c96b6c37a44a39693352b442 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) ); + // Check if the values used to control the parsing logic have been + // successfully read. + if ((SratRAType == NULL) || + (SratRALength == NULL)) { + IncrementErrorCount (); + Print ( + L"ERROR: Insufficient remaining table buffer length to read the " \ + L"Static Resource Allocation structure header. Length = %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)'