From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from EUR04-HE1-obe.outbound.protection.outlook.com (EUR04-HE1-obe.outbound.protection.outlook.com [40.107.7.44]) by mx.groups.io with SMTP id smtpd.web10.9233.1579518865455931697 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=T86xJJHP; spf=pass (domain: arm.com, ip: 40.107.7.44, 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=j/Q4b+8TcROta+SaG98GQCMbjzfxqMEwL+LSQVfg5Fg=; b=T86xJJHPEANydSeaLiIh1aUUW8+mSlpLVs1G1oAQSzidsvj9Tc1SOZFOGL4mjI3HGtgga+kCHWbl+2ZvYBxmEnScpbKqn3S5tPlBGtDIhdAfvfFhaIToLizWTZ7fa0kv/hQ+WvBuKsBiEAX641DuTRUrv4YdDp9SStvsmBpdbfc= Received: from AM6PR08CA0006.eurprd08.prod.outlook.com (2603:10a6:20b:b2::18) by DB6PR0801MB1734.eurprd08.prod.outlook.com (2603:10a6:4:31::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2644.24; Mon, 20 Jan 2020 11:14:22 +0000 Received: from VE1EUR03FT047.eop-EUR03.prod.protection.outlook.com (2a01:111:f400:7e09::209) by AM6PR08CA0006.outlook.office365.com (2603:10a6:20b:b2::18) 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: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 VE1EUR03FT047.mail.protection.outlook.com (10.152.19.218) 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 ca1df68f3668:v40"); Mon, 20 Jan 2020 11:14:21 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: cc3d1380dd3a2616 X-CR-MTA-TID: 64aa7808 Received: from b92fff37ac4f.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 93597E6D-ACBA-44FD-867D-1F581625DA16.1; Mon, 20 Jan 2020 11:14:16 +0000 Received: from EUR03-AM5-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id b92fff37ac4f.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=QAs4N1KVMcAxMDet/QWBXHZTQG9XAXk849GGBhDn/08+XRQw640QBLxgguqXyHWWmSDQKq2+/UACuCFbYThk1g0+fNNiJ6kXzPOFJN+GYFs8hSCagMFt4bL+jfTe0J0R7+eskAGsrPZzAPW75A1UJHYpKUbGlkXRb9J5fP9AhkyjE+erM9SGdugXMxFWuirvIBWIOsGfiwvFoHM7qT+mAFWMY0WN66x+105tnh2hHA1yDyLbUBomm29ZQ5t3Zr2eUIOSp3HPUfH9KfhpaEVD1DxG6r8+x3qMsCePmaH4MhGG4pjbtXbUqWiwv0vLPKMQVsSkXA2WQAyK4Uk6o+Y7KQ== 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=j/Q4b+8TcROta+SaG98GQCMbjzfxqMEwL+LSQVfg5Fg=; b=aUd9iAhpsj1H+FtfWPzmXL0lzxT5LxVGSIJqHLXKrjCF1u7p98XRCVz1yvcZd2wXPrUOeFeWygV3ZMmTbStmKUTY+yF2+L53nEei2GQPo2RaNvxPi8Hr5IINsbfFN2pRJmP1qwUQDeAXZHFOoaR4b7Is36KIWPOh1WtJhI+wRUK8hni2KArfaoWOEweER4JKlefNB/0tRII46OjmDBw+VOx2I5XqJ1jJGMzsrIW71jLv/ALi8Wlam53HSE7Xe92Gi89cqHUgI93Vjv0v5X64bAamkdHg0EsVDyuI3W5yBssSVa6p0ci4yIX+vW8m9850v0/q+Eapa4V28alaz/DbTg== 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=j/Q4b+8TcROta+SaG98GQCMbjzfxqMEwL+LSQVfg5Fg=; b=T86xJJHPEANydSeaLiIh1aUUW8+mSlpLVs1G1oAQSzidsvj9Tc1SOZFOGL4mjI3HGtgga+kCHWbl+2ZvYBxmEnScpbKqn3S5tPlBGtDIhdAfvfFhaIToLizWTZ7fa0kv/hQ+WvBuKsBiEAX641DuTRUrv4YdDp9SStvsmBpdbfc= Received: from AM6PR08CA0006.eurprd08.prod.outlook.com (2603:10a6:20b:b2::18) by AM5PR0801MB1729.eurprd08.prod.outlook.com (2603:10a6:203:3b::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2644.25; Mon, 20 Jan 2020 11:14:15 +0000 Received: from AM5EUR03FT042.eop-EUR03.prod.protection.outlook.com (2a01:111:f400:7e08::202) by AM6PR08CA0006.outlook.office365.com (2603:10a6:20b:b2::18) 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: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 AM5EUR03FT042.mail.protection.outlook.com (10.152.17.168) 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-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; Mon, 20 Jan 2020 11:14:04 +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:03 +0000 From: "Krzysztof Koch" To: CC: , , , , Subject: [PATCH v3 01/11] ShellPkg: acpiview: Set ItemPtr to NULL for unprocessed table fields Date: Mon, 20 Jan 2020 11:13:41 +0000 Message-ID: <20200120111351.29184-2-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)(136003)(376002)(346002)(39860400002)(396003)(199004)(189003)(70206006)(70586007)(4326008)(336012)(356004)(6666004)(86362001)(478600001)(44832011)(26005)(36756003)(2906002)(54906003)(5660300002)(1076003)(316002)(8676002)(81166006)(81156014)(186003)(7696005)(8936002)(2616005)(6916009)(426003);DIR:OUT;SFP:1101;SCL:1;SRVR:AM5PR0801MB1729;H:nebula.arm.com;FPR:;SPF:Pass;LANG:en;PTR:InfoDomainNonexistent;A:1;MX:1; X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 93e94995-52cf-4f74-c1e2-08d79d99e6aa X-MS-TrafficTypeDiagnostic: AM5PR0801MB1729:|DB6PR0801MB1734: X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: True X-MS-Oob-TLC-OOBClassifiers: OLM:9508;OLM:9508; X-Forefront-PRVS: 0288CD37D9 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: Y9S+3UMprA9JXdw8lz9pY7qCUedxjOxjCVWhViThX3xNup86DC941oVNDp1BK8N62ff5CBAGe0LOM0Y9OOtjkCIyX6EiqhomjNACFfViAyhqLOFms0pGUIlzjnA1YTu4iZUAwwVACByx0+/Sd0vft+seukMZx6ceNlk3AikUt6e9PrjmPL7gTL4BGrsHi8cLxnoiaRZgqlbmLe8ovNlW83y+rGs5YuKtO9AgsGmXz1Yf4t674sgnivf8NEZXSnda0Flup6EYfOsVqeiwzBvJktLDwzBcvT0Lq9zfPkDXh8kEIy15I1XoZqm7pOafRCGvrKohWgiBSD6Mr0ZyqW2BR0T28v929vB/jRqHOW3EgD4DRMXVq4JxA6y7TUfDabM+bef7tM4vVlLHshlq87fMHDckbemPFPFsSAjBIGxq+lpiBFopZuZumUPPJ3rRAphc X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM5PR0801MB1729 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: VE1EUR03FT047.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)(396003)(346002)(39860400002)(376002)(136003)(189003)(199004)(2616005)(86362001)(336012)(316002)(36906005)(54906003)(426003)(478600001)(26826003)(81156014)(8936002)(36756003)(70206006)(81166006)(2906002)(8676002)(5660300002)(70586007)(6916009)(6666004)(44832011)(1076003)(4326008)(26005)(186003)(7696005);DIR:OUT;SFP:1101;SCL:1;SRVR:DB6PR0801MB1734;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: fcfd9dd3-b491-43b1-514a-08d79d99e26b X-Forefront-PRVS: 0288CD37D9 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: veSyzP0Ij2AO2JrKMg5FhUQTGHBgTkSGO0gcI2Ec6fdIUK++L+3jdMfUjE7xbsKtvuc63rbCMIpwrmKNa6Bu7N+VZHEthFCC/NC6dlhb4DMZPYUtFVEf1/ixeX1wHUf94o30R5bhPmib11zAPcLZ4nXG/TcU13WrykOtdm/8mIL9La4e60PfS5hS8S/tJBx5ssFamSkYbxKFXursRkPFahcRluqUCxkb8dKnnwFYKXupnNIjLusKHsfOJtY/VfTGox8lUe+kwa8rfki6/rr+sb6TLZAJbLoUFYNGMgOG39Dvug7b9ZMA4qWKZLifiCj++quFEK3cmloW/lu2kc250qrLqqvSYNJi/H5F3nmMrR4I02dTem3XeCzFT0sIdydgk09jNRwzrM+k0iW3kQzeIOCLXFznVyusQ5QxTKdhT0vhaYp9SsrxVAFP23ybwTi6 X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Jan 2020 11:14:22.0671 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 93e94995-52cf-4f74-c1e2-08d79d99e6aa 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: DB6PR0801MB1734 Content-Type: text/plain 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, we will have a dangling pointer which could cause a problem later. Signed-off-by: Krzysztof Koch --- Notes: v3: - Rebase on latest master [Krzysztof] 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/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.c index 2b2ecb93cef9ee28b752e7bf2d920b059dbf7d6b..84c5f0468da55477acc96dfd0f949a5908d0f7a5 100644 --- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.c +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.c @@ -543,8 +543,15 @@ ParseAcpi ( for (Index = 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 != NULL) { + *Parser[Index].ItemPtr = NULL; + } + // We don't parse past the end of the max length specified - break; + continue; } if (GetConsistencyChecking () && -- 'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)'