From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from EUR02-VE1-obe.outbound.protection.outlook.com (EUR02-VE1-obe.outbound.protection.outlook.com [40.107.2.77]) by mx.groups.io with SMTP id smtpd.web12.9144.1579518866403786189 for ; Mon, 20 Jan 2020 03:14:26 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@armh.onmicrosoft.com header.s=selector2-armh-onmicrosoft-com header.b=hKLvWFas; spf=pass (domain: arm.com, ip: 40.107.2.77, 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=XaoP7PGdC4nfO7YPTVVZApY8pwYthFX3+/wAyaXnU3Y=; b=hKLvWFasy0q8iNDzmx82zc8lZUkbV94k9f6jzUw0oeZr3KUnVlME6q/dcHJANElfvNbNA6BFR3qVu99xKHgj32PKxx23+jNT1dkR00g+Hzie6Fm3rpHynMg4ZNOSO9vs/zQfNBSA2HqrO3fmv8pkXAh8zvTe04WcN9FWllWgcxM= Received: from DB6PR0801CA0050.eurprd08.prod.outlook.com (2603:10a6:4:2b::18) by VI1PR0801MB2000.eurprd08.prod.outlook.com (2603:10a6:800:8e::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2644.23; Mon, 20 Jan 2020 11:14:22 +0000 Received: from VE1EUR03FT055.eop-EUR03.prod.protection.outlook.com (2a01:111:f400:7e09::206) by DB6PR0801CA0050.outlook.office365.com (2603:10a6:4:2b::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2644.20 via Frontend Transport; Mon, 20 Jan 2020 11:14:22 +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 VE1EUR03FT055.mail.protection.outlook.com (10.152.19.158) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2644.23 via Frontend Transport; Mon, 20 Jan 2020 11:14:22 +0000 Received: ("Tessian outbound 0eaff1016ea4:v40"); Mon, 20 Jan 2020 11:14:22 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 19923e20d1790223 X-CR-MTA-TID: 64aa7808 Received: from 7bf45c6a4cb8.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id F5F5139B-418F-4E13-9169-D0C81D5A7AC6.1; Mon, 20 Jan 2020 11:14:16 +0000 Received: from EUR05-DB8-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 7bf45c6a4cb8.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Mon, 20 Jan 2020 11:14:16 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=N7HvZInm+3wKtFIbUh14ckzs8zyVCCCpLlwcvezIOilJaM7fTMcXEZKupT0EGHAF/VXT1OWGJ73EtpsMatVDhTB28wpV3zcEe0gbXu0aM3IaQTWBeeAZJIRIufgFWbOQZE6HYqssmdxR0Rw0orlfDGRjLkPXX58qHep6t+vCZ+mQs7tXA9JM7ZNFopJ4vEL9sNUNtLuQlPE7soVZSjImhn/+Td0G5aM177LnsVVlICE16CUVSdApreJA5D7wGcyZVCc2yQ3jNJxQoGwZ1HbiR8+WF0ppDwKj/YHKinRSxotPDl60nfTofdbAFFiwk6C2i29SqetkoSSkUf0Pp3MqaQ== 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=XaoP7PGdC4nfO7YPTVVZApY8pwYthFX3+/wAyaXnU3Y=; b=BLFYaKg4UO5fZICMyGW4fp1Alt0+xBkIS1H+RfXrv9+Wqe9LWw2Odjnf0yj3z4UanX9i8t1XNxlHAiJ6jAuit+18BwTfOVXHYMAom7/kQZL2yksijCRsUsT0QFRsaaBHgd139WAz33nAXk/d/MxQmnans5adHOqfYHN9q3fEa4XCQVNjB/v0GBbkchoSHT40F/QHP03U7aUY6Aan4eJR4ytG9erm+cb9TXF1+YuWZk0pdhV99Z99pKmtYoxi+UVkoL2/Enlf9/FzTfc0r4Z8NAvyFYJ1fPNj0unYpf71KgvCrcx7ZCbOWGcKIWYFa48Id99C9OlNCBqBHMKHoY2ZHQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 40.67.248.234) smtp.rcpttodomain=edk2.groups.io smtp.mailfrom=arm.com; dmarc=bestguesspass 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=XaoP7PGdC4nfO7YPTVVZApY8pwYthFX3+/wAyaXnU3Y=; b=hKLvWFasy0q8iNDzmx82zc8lZUkbV94k9f6jzUw0oeZr3KUnVlME6q/dcHJANElfvNbNA6BFR3qVu99xKHgj32PKxx23+jNT1dkR00g+Hzie6Fm3rpHynMg4ZNOSO9vs/zQfNBSA2HqrO3fmv8pkXAh8zvTe04WcN9FWllWgcxM= Received: from DB6PR0801CA0049.eurprd08.prod.outlook.com (2603:10a6:4:2b::17) by VI1PR08MB4016.eurprd08.prod.outlook.com (2603:10a6:803:ed::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2644.19; Mon, 20 Jan 2020 11:14:15 +0000 Received: from VE1EUR03FT041.eop-EUR03.prod.protection.outlook.com (2a01:111:f400:7e09::207) by DB6PR0801CA0049.outlook.office365.com (2603:10a6:4:2b::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2644.18 via Frontend Transport; Mon, 20 Jan 2020 11:14:15 +0000 Authentication-Results-Original: spf=pass (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=bestguesspass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 40.67.248.234 as permitted sender) receiver=protection.outlook.com; client-ip=40.67.248.234; helo=nebula.arm.com; Received: from nebula.arm.com (40.67.248.234) by VE1EUR03FT041.mail.protection.outlook.com (10.152.19.163) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.2644.23 via Frontend Transport; Mon, 20 Jan 2020 11:14:15 +0000 Received: from AZ-NEU-EX04.Arm.com (10.251.24.32) by AZ-NEU-EX04.Arm.com (10.251.24.32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1415.2; Mon, 20 Jan 2020 11:14:05 +0000 Received: from E119924.Arm.com (10.37.9.56) by mail.arm.com (10.251.24.32) with Microsoft SMTP Server id 15.1.1415.2 via Frontend Transport; Mon, 20 Jan 2020 11:14:05 +0000 From: "Krzysztof Koch" To: CC: , , , , Subject: [PATCH v3 04/11] ShellPkg: acpiview: SLIT: Validate global pointer before use Date: Mon, 20 Jan 2020 11:13:44 +0000 Message-ID: <20200120111351.29184-5-krzysztof.koch@arm.com> X-Mailer: git-send-email 2.16.2.windows.1 In-Reply-To: <20200120111351.29184-1-krzysztof.koch@arm.com> References: <20200120111351.29184-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:;CTRY:IE;EFV:NLI;SFV:NSPM;SFS:(10009020)(4636009)(396003)(346002)(136003)(376002)(39860400002)(189003)(199004)(2616005)(8936002)(478600001)(4326008)(7696005)(86362001)(2906002)(44832011)(81166006)(54906003)(336012)(426003)(186003)(81156014)(70206006)(316002)(8676002)(1076003)(6916009)(70586007)(26005)(356004)(15650500001)(6666004)(5660300002)(36756003);DIR:OUT;SFP:1101;SCL:1;SRVR:VI1PR08MB4016;H:nebula.arm.com;FPR:;SPF:Pass;LANG:en;PTR:InfoDomainNonexistent;MX:1;A:1; X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 37a7d3aa-efdd-4bc5-b19f-08d79d99e6f2 X-MS-TrafficTypeDiagnostic: VI1PR08MB4016:|VI1PR0801MB2000: X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: True X-MS-Oob-TLC-OOBClassifiers: OLM:6430;OLM:6430; X-Forefront-PRVS: 0288CD37D9 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: 9kni4DD/1qN9CekvaMU7ClGx2C9m2gQaVlqXIFMrBmdqCIAVxIs1kTEG7P6vMB3vc+sT/7MEJo4JDGxfel7P9voyZzScjaTFN0Uj8EVY88caoJ1LHXg0stvkq3LkwdDuw2tGzYtFQoaRaLQL5I/4M3fnt9FI4p+79tXGY5LKFU/XAFP4+8wAIdm/dFB3/thP98nOA2tDZtfJoE0kcvAyR+Hz6Mo86SA032iy2Dr1xshXwGibyvko/D7ucDXnWj6mvBZ5Fykny/ZwXcst4oKx3E5DU0A3yAUWjEmcb/BZ+VFfLkgSl8DXWmsH/MP6xrLhDOo2kJN8WoJ7kjUJqDucIsh6FFjiUMziBKfuDo0bhjNM65kqywmy1FIyGXrYe7E3oKTkA9b3bjwmcWNNHdFkbwbg7B316Gn3Uz+ooKF4XiaNw/0oPA34ijFKosV0eTrm X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR08MB4016 Original-Authentication-Results: spf=pass (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=bestguesspass action=none header.from=arm.com; Return-Path: Krzysztof.Koch@arm.com X-MS-Exchange-Transport-CrossTenantHeadersStripped: VE1EUR03FT055.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)(346002)(396003)(136003)(39860400002)(189003)(199004)(426003)(2616005)(6666004)(186003)(2906002)(26005)(44832011)(7696005)(316002)(86362001)(4326008)(26826003)(336012)(5660300002)(36906005)(70586007)(70206006)(36756003)(54906003)(15650500001)(478600001)(81156014)(81166006)(6916009)(1076003)(8936002)(8676002);DIR:OUT;SFP:1101;SCL:1;SRVR:VI1PR0801MB2000;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: b454141d-0340-4404-e7de-08d79d99e26f X-Forefront-PRVS: 0288CD37D9 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: wJgDE+ZiNAhsfHh+HDsSS3+HYjXIMvTNMi0hdTtKAD/JAtnuMNtE1NA4wKSftMZysz4iGw23BJQeXPtk0dzDqvBfwsBWjkr+wzV6qnb66jMZAmo42NcorWJ7ljCz2fRADDQAjt17YOr9OKBO0/ZbzjzyAsYU2nqflUiX0r+wcJQpAECLeEzwgbRMImA4w7JB82nRLfxF20gDSO8IvhE204P2k4pyN2YjjihgqBlPkXA7LljN8TZQHAIiGqRqbSdoEYKSMWIgoUZqEE6QDuLpgeu97rfm7doM16+ir3H8kDAssfzQpaiBdWVjJhRMH4ZEeOcZfW+rR3nv0nzGz/sWpUKRvrn0JUUm/q86SJY91MUuIXrK13LIuyn45Q0k0RjQR8zG59UjJNUByW4J9z2WsoOx+0SS5+aLiRah1RyoyLEfH9HBbLedwMcc/SQUQNr0 X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Jan 2020 11:14:22.5365 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 37a7d3aa-efdd-4bc5-b19f-08d79d99e6f2 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: VI1PR0801MB2000 Content-Type: text/plain Check if SlitSystemLocalityCount pointer has been successfully updated before it is used for further table parsing. Signed-off-by: Krzysztof Koch --- Notes: v3: - Rebase on latest master [Krzysztof] v1: - Test against NULL pointers [Krzysztof] ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Slit/SlitParser.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Slit/SlitParser.c b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Slit/SlitParser.c index ca2808db526b1bbb79aeb21ccfc0ae6c79b2dfd8..17e2166a09d8615b714e0c51d4d93d293fcdf601 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 - 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 @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 == NULL) { + IncrementErrorCount (); + Print ( + L"ERROR: Insufficient table length. AcpiTableLength = %d.\n", + AcpiTableLength + ); + return; + } + LocalityPtr = Ptr + Offset; - LocalityCount = *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)'