From patchwork Wed Apr 5 13:54:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Rafael J. Wysocki" X-Patchwork-Id: 79608 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp330850vqo; Wed, 5 Apr 2023 07:04:20 -0700 (PDT) X-Google-Smtp-Source: AKy350bC8ZT/MOq+YSDkspEGnoDDAUZFlUBq0O3jRe2pbdiajy5KCM9SRXNXs0lXYqVsD08lpiMm X-Received: by 2002:a17:906:f1d5:b0:870:d9a:9ebb with SMTP id gx21-20020a170906f1d500b008700d9a9ebbmr3491589ejb.38.1680703460091; Wed, 05 Apr 2023 07:04:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680703460; cv=none; d=google.com; s=arc-20160816; b=zxRvK0BLZxHg65Q5kpM6rDfo4buGQ3AP+Oq42k1zU7Q2mZgN2S2nxZGOpv+xYXEtMb khEaV1ytgXkRswAPa4Bmjesrk9nMKMlHzskmlKwfUsvs/mWuxFT8yMswZxN+F2aa4GIR GgzMNgKG8t5kJdWGA5A+/sCO7FJkoape2bV0jXtaTZZukRF+J/1Monwri4Pwe4PS5xpp sTFYDNK/UTDLynvpuSpGmSMVDDOHbli6t/gNfoXpeF1tu7civ16Kyugy0Tw8E7CW+y/v QRd5WL6/ggJQcz6+G6OynqIrPY9h7a9TSNeiDmMv9WjKUqAh+ubBFzDq+wVLIcYmijPk fOjA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=HYSMPMeHX/0HLWIE1l4pijnGU+H8cea/XdX8cwt5ORk=; b=PdEnqYa4HOmXsHWTPRrMNuGYYy2yYklOC6sYULz1FZ24WvgvD9Oze+TX36G8zTGxgk ATT/lY7RXD0tkmFJu7CaDs4f6jmcNdD4CfmjSWQ9ipzvSVOdEuNZm1dqLlm9DAs3DXPh 4yGOVmr4YJ4xEQwkmUtycAFETFI/ln+MhlJIaEZuwtXm6G4NxBFn2fU5XgiDa4OP2miF w2mJC1KJ1w8Oh2A62wJW6YjNKOPhtjpGpLpfLiJ8YY3E61P9lgrLWbEHSUJtmYE9tN01 +bbVZ29rluyDxeyB6ObBgp9GTj0q0gaH9VfVo+8DQIrNY5+8tfTOS6RyRyhEBM+yXPo+ OWaQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id kw7-20020a170907770700b0093959594e50si2691436ejc.248.2023.04.05.07.03.47; Wed, 05 Apr 2023 07:04:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237872AbjDEOBH (ORCPT + 99 others); Wed, 5 Apr 2023 10:01:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42206 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237860AbjDEOAz (ORCPT ); Wed, 5 Apr 2023 10:00:55 -0400 Received: from cloudserver094114.home.pl (cloudserver094114.home.pl [79.96.170.134]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E45F5525D; Wed, 5 Apr 2023 07:00:47 -0700 (PDT) Received: from localhost (127.0.0.1) (HELO v370.home.net.pl) by /usr/run/smtp (/usr/run/postfix/private/idea_relay_lmtp) via UNIX with SMTP (IdeaSmtpServer 5.1.0) id 5d14c08f8e88d672; Wed, 5 Apr 2023 16:00:46 +0200 Received: from kreacher.localnet (unknown [213.134.163.219]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by v370.home.net.pl (Postfix) with ESMTPSA id 911C91B4EA5B; Wed, 5 Apr 2023 16:00:45 +0200 (CEST) From: "Rafael J. Wysocki" To: Linux ACPI Cc: LKML , Bob Moore , Kees Cook Subject: [PATCH 26/32] ACPICA: acpi_pci_routing_table: Replace fixed-size array with flex array member Date: Wed, 05 Apr 2023 15:54:25 +0200 Message-ID: <2656292.X9hSmTKtgW@kreacher> In-Reply-To: <4845957.31r3eYUQgx@kreacher> References: <4845957.31r3eYUQgx@kreacher> MIME-Version: 1.0 X-CLIENT-IP: 213.134.163.219 X-CLIENT-HOSTNAME: 213.134.163.219 X-VADE-SPAMSTATE: clean X-VADE-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedvhedrvdejuddgjeduucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecujffqoffgrffnpdggtffipffknecuuegrihhlohhuthemucduhedtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjughrpefhvfevufffkfgjfhgggfgtsehtufertddttdejnecuhfhrohhmpedftfgrfhgrvghlucflrdcuhgihshhotghkihdfuceorhhjfiesrhhjfiihshhotghkihdrnhgvtheqnecuggftrfgrthhtvghrnhepledtieekkeekveeikeetgffgteeuteefjeevjeegudelvdduheeiuedvieehieevnecuffhomhgrihhnpehgihhthhhusgdrtghomhenucfkphepvddufedrudefgedrudeifedrvdduleenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepihhnvghtpedvudefrddufeegrdduieefrddvudelpdhhvghlohepkhhrvggrtghhvghrrdhlohgtrghlnhgvthdpmhgrihhlfhhrohhmpedftfgrfhgrvghlucflrdcuhgihshhotghkihdfuceorhhjfiesrhhjfiihshhotghkihdrnhgvtheqpdhnsggprhgtphhtthhopeegpdhrtghpthhtoheplhhinhhugidqrggtphhisehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqkhgvrhhnvghlsehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtoheprhhosggvrhhtrdhmohhorhgvsehinhhtvghlrdgtohhmpdhrtghpthhtohepkhgvvghssehouhht fhhluhigrdhnvght X-DCC--Metrics: v370.home.net.pl 1024; Body=4 Fuz1=4 Fuz2=4 X-Spam-Status: No, score=0.0 required=5.0 tests=SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1762345311482203369?= X-GMAIL-MSGID: =?utf-8?q?1762345311482203369?= From: Kees Cook ACPICA commit f4a3afd78c28dede0907f47951f0b73c9a776d4e The "Source" array is actually a dynamically sized array, but it is defined as a fixed-size 4 byte array. This results in tripping both compile-time and run-time bounds checkers (e.g. via either __builtin_object_size() or -fsanitize=bounds). To retain the padding, create a union with an unused Pad variable of size 4, and redefine Source as a proper flexible array member. No binary changes appear in the .text nor .data sections. Link: https://github.com/acpica/acpica/commit/f4a3afd7 Signed-off-by: Bob Moore Signed-off-by: Rafael J. Wysocki --- include/acpi/acrestyp.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/include/acpi/acrestyp.h b/include/acpi/acrestyp.h index 52e82d65016b..4c3b7b393f82 100644 --- a/include/acpi/acrestyp.h +++ b/include/acpi/acrestyp.h @@ -693,7 +693,10 @@ struct acpi_pci_routing_table { u32 pin; u64 address; /* here for 64-bit alignment */ u32 source_index; - char source[4]; /* pad to 64 bits so sizeof() works in all cases */ + union { + char pad[4]; /* pad to 64 bits so sizeof() works in all cases */ + ACPI_FLEX_ARRAY(char, source); + }; }; #endif /* __ACRESTYP_H__ */