From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from EUR02-HE1-obe.outbound.protection.outlook.com (EUR02-HE1-obe.outbound.protection.outlook.com [40.107.1.43]) by mx.groups.io with SMTP id smtpd.web09.9175.1579518869508528229 for ; Mon, 20 Jan 2020 03:14:30 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@armh.onmicrosoft.com header.s=selector2-armh-onmicrosoft-com header.b=ff0/LeTo; spf=pass (domain: arm.com, ip: 40.107.1.43, 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=HYJ7Rw4QkZJfj5/oztsTouGVi2AIGuEnwwub7sOxLgg=; b=ff0/LeToriIAz8u/T0f3Mji6B956FDzkJe52Nka44JFW2Yuh1k8THXhfv3veT5TPBS0oteDEIiSqi1aL6wMtmr6sd4dRQqOEu7HK8IOTPR2cukTZAerl8od7NIx78/Ck1xYolcDZ6+a0FEeYsZxJ36lY5rFx6izbJIvBXqqyJWY= Received: from DB6PR0801CA0057.eurprd08.prod.outlook.com (2603:10a6:4:2b::25) by DB8PR08MB5324.eurprd08.prod.outlook.com (2603:10a6:10:11e::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2644.20; Mon, 20 Jan 2020 11:14:26 +0000 Received: from DB5EUR03FT024.eop-EUR03.prod.protection.outlook.com (2a01:111:f400:7e0a::204) by DB6PR0801CA0057.outlook.office365.com (2603:10a6:4:2b::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2644.19 via Frontend Transport; Mon, 20 Jan 2020 11:14:26 +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 DB5EUR03FT024.mail.protection.outlook.com (10.152.20.67) 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:26 +0000 Received: ("Tessian outbound ca1df68f3668:v40"); Mon, 20 Jan 2020 11:14:26 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: e3761d0607cdb898 X-CR-MTA-TID: 64aa7808 Received: from 94236c8067f8.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 647A61CB-639A-4951-96C9-6403F272CC5D.1; Mon, 20 Jan 2020 11:14:21 +0000 Received: from EUR04-VI1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 94236c8067f8.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Mon, 20 Jan 2020 11:14:21 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JQz54aUJWt0fA14v8iP3a+7clfclB1OSW4nznYTTGFkH7gPpCDRu24WdacJSrooDDGSdCG7Muzpft9pNIs8v9zXjH0RxvfaPdjePC3apLb9ZzF86M8AQv1xeJUTwxJbvEhgYKyPtDnZGhR6vmoKD9BcgtKEIWVltuJSig1KXVCQhF0V0/y9proCq5udTeeq4xN/JIvMDP+7YCFrbZz5GAO+d3eYJtAYC/fn2U8osUEi3AzxtGg/g9Jux8WtE36sjjI4ZCd1jHyXZgLtxofMVjrIhiihxZ7bnv6L8t3uOJvdXItY2EDf5g1AQtLne7X0JLiZixkSKSNhVVQlcZa/3cQ== 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=HYJ7Rw4QkZJfj5/oztsTouGVi2AIGuEnwwub7sOxLgg=; b=gKp6UGAJ+EtzQecXENVMh8RnUXpJZrxFiIaRkipX3ezVn85Ap6qpMawYG4B5V9s/G2Shgf/hDK9ZEY1+rzD183iUGc87X2SCXVp6+X7LdFlKlRLX+IJgQ8Cr4GeGPkUmR1rCpWkxmTv4S77Hsb4owfu+H5HPiJ/w44lkv3xV2sYlWwHaDs/mk1SxlyWxRi91y0aNB2jws/vlgPyI6fhLe5UipoicpRB5CKErrQ59RgsrPCFkMjtWd9UM6EN3DiUs1/W5n0NiAtIwujAhC8NXpZoxOSBsPSdDsdK7mbwfKJ5Jso5iBGE1IcfE/LWJ5qDah/tyw7iasD/ubLuHs5b/YQ== 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=HYJ7Rw4QkZJfj5/oztsTouGVi2AIGuEnwwub7sOxLgg=; b=ff0/LeToriIAz8u/T0f3Mji6B956FDzkJe52Nka44JFW2Yuh1k8THXhfv3veT5TPBS0oteDEIiSqi1aL6wMtmr6sd4dRQqOEu7HK8IOTPR2cukTZAerl8od7NIx78/Ck1xYolcDZ6+a0FEeYsZxJ36lY5rFx6izbJIvBXqqyJWY= Received: from VI1PR0802CA0023.eurprd08.prod.outlook.com (2603:10a6:800:aa::33) by VE1PR08MB5069.eurprd08.prod.outlook.com (2603:10a6:803:105::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2644.22; Mon, 20 Jan 2020 11:14:19 +0000 Received: from VE1EUR03FT059.eop-EUR03.prod.protection.outlook.com (2a01:111:f400:7e09::201) by VI1PR0802CA0023.outlook.office365.com (2603:10a6:800:aa::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2644.19 via Frontend Transport; Mon, 20 Jan 2020 11:14:19 +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 VE1EUR03FT059.mail.protection.outlook.com (10.152.19.60) 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:19 +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:07 +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:06 +0000 From: "Krzysztof Koch" To: CC: , , , , Subject: [PATCH v3 07/11] ShellPkg: acpiview: MADT: Validate global pointers before use Date: Mon, 20 Jan 2020 11:13:47 +0000 Message-ID: <20200120111351.29184-8-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)(376002)(136003)(39860400002)(396003)(346002)(189003)(199004)(426003)(2616005)(6666004)(2906002)(356004)(44832011)(7696005)(186003)(26005)(316002)(86362001)(4326008)(336012)(5660300002)(70206006)(36756003)(54906003)(70586007)(15650500001)(478600001)(81166006)(81156014)(6916009)(1076003)(8676002)(8936002);DIR:OUT;SFP:1101;SCL:1;SRVR:VE1PR08MB5069;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: f561ff3d-dd2e-4088-0947-08d79d99e93e X-MS-TrafficTypeDiagnostic: VE1PR08MB5069:|DB8PR08MB5324: X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: True X-MS-Oob-TLC-OOBClassifiers: OLM:6108;OLM:6108; X-Forefront-PRVS: 0288CD37D9 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: /MZ/L5lFDuWRVyziKwNWc5ddAFPlYW+rhjI+eipgUyHTFbWhcNRwscUfG5k+lvPuimmIjVaCdfATnAhmeewKQ70gD8l/jTVSzl0vZXnltObenUgsg2+NynYG97uzcWD4JgOJed3psCBvIdU7VMuVtes+T1eTXlE1gidXoHHtRZVRlakSancjyVmEXMWbiaNF9yHZA9J2rLYUYSv3k802N7XoL6DXub1RavpUqL0cm1KRRcnHZQaQON+5xGMrsHjK6DU3Z8m4SfuonNxtjfg9m2Bd5ecejaisIWPz+YxtWyW4utvWwjxn9dVIKqMpXuHzBHKK/vKRgqgBy3u+/tMYG2YlXZTPs86SN5WhTZbi5KK2HBS7m9r2nUF/aaB4Zk+j1ky9D+NzAJL5f3CIlgmMDlTEOd8O75CIDyXMCSWgPGRhBN9kBWO1kPtG4t/pyj/p X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR08MB5069 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: DB5EUR03FT024.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)(136003)(396003)(376002)(346002)(189003)(199004)(316002)(54906003)(81156014)(8676002)(70206006)(70586007)(36756003)(4326008)(186003)(26005)(26826003)(478600001)(1076003)(2906002)(86362001)(6916009)(2616005)(15650500001)(5660300002)(81166006)(44832011)(7696005)(336012)(6666004)(8936002)(426003);DIR:OUT;SFP:1101;SCL:1;SRVR:DB8PR08MB5324;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: 69d5b057-24f3-48e2-16fa-08d79d99e4fe X-Forefront-PRVS: 0288CD37D9 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 44dMo7agaIAi2w/hFPeTH1S+NaPLnBaT3LfLcDUzz95B2e653yy6zQgbKqDjdvSKkTk8ezLHmh1pJrjmMeot1tD4CqjFg1THL9k2n+D3K8+jkQq7Bl52c1Voq4KAhKT8uIjZTCJSQHqc2ExjiZFrT5PAhyipLUWkasjiZI3VqK8tjpEqbilaPEJRi1OVHfE+AxDqcQc4aBpuNx1QWxCiwONVgEHIroqvJ68zaEjAa0NdK9LDJDtRWVYARF6us3f/v7r+u+JMo/y70vWd7Uz8ZxIEBAQ8TdOdRbwgCsXSwL+cBzvGr4TVMyU6bP9+v/0P2AQwwzWZaqiPmtUyxKqG8Xlli9OWn1kSi+tZ5X0Okbw27fsDCcmMxRqfML/YLa1EklBk5+AZvHByxJpYsQr+EPulCmKn4J92eVxFbs5NIfb9nyiieOh5J3puQIuFYN+N X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Jan 2020 11:14:26.4398 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f561ff3d-dd2e-4088-0947-08d79d99e93e 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: DB8PR08MB5324 Content-Type: text/plain Check if the MadtInterruptControllerType and MadtInterruptControllerLength pointers have been successfully updated before they are 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/Madt/MadtParser.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Madt/MadtParser.c b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Madt/MadtParser.c index 90bdafea1970db522e8ed96de7c6e986cdaca5ba..438905cb24f58b8b82e8fe61280e72f765d578d8 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) ); + // Check if the values used to control the parsing logic have been + // successfully read. + if ((MadtInterruptControllerType == NULL) || + (MadtInterruptControllerLength == NULL)) { + IncrementErrorCount (); + Print ( + L"ERROR: Insufficient remaining table buffer length to read the " \ + L"Interrupt Controller Structure header. Length = %d.\n", + AcpiTableLength - Offset + ); + return; + } + // Make sure forward progress is made. if (*MadtInterruptControllerLength < 2) { IncrementErrorCount (); -- 'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)'