From patchwork Wed Apr 5 13:56:59 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: 79645 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp344054vqo; Wed, 5 Apr 2023 07:19:51 -0700 (PDT) X-Google-Smtp-Source: AKy350b8RNAWEz9uXN6fftO2RBo5U8BZTIJZAGUpiWBEyFvwUopu/2XJ6v4cRziPaRj8uGjQYs8l X-Received: by 2002:aa7:970d:0:b0:627:e024:98ca with SMTP id a13-20020aa7970d000000b00627e02498camr5424142pfg.32.1680704391460; Wed, 05 Apr 2023 07:19:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680704391; cv=none; d=google.com; s=arc-20160816; b=POKAYqYw/NrX8gW334wknNuzD/7Ga1nVMFtl3fXmlQgh+1Op7imj2RH87AlIiCgd6k ZfbOzaIDKJZhLJ61lWfT9ycm0W8wpqWOz59zY0rt4U0x1LhieGbZhHuZkshtqkGvAvbt X98JCkQArop+AC86hrTlTGn6vpGKQr6B5MAtwzVpa2aX4dSdGj7fn48GI2t9ugk9wTAS DMxS2EONe7akMJnp46wjIYSliw871nWzo/NCxCplQkx79f7wgLwF9HYR8dUe8CS/klad PuQjjMK0mYMiTMMONFyVOuZcWxdkdZ4DM9HtfBH22uVKqgC1EACC4He7SY03MH8Nbsoh 8npg== 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=tO+bXxw5lxVmZmAFpzL2DOv91Gl7+4UE5Bf6SNws8eQ=; b=yMZ38YMc+MUN60JjJu8huIXknSuFb+8vGziwLMGYxDbempxrxg5W6Oi+/eHvzaqRBn iqG9tQPJtcUFO6SrV+qEMCbT/5fuS5IenZZoEBUfCqyqyO3EtNlKPD+0+HxgngzWomXV ydF/4onjTa8TMJGs9IsTrz6K7EspswJEY3AZViHTa/NxX7gu7edoq3RxU9OIddpnq24/ 8zoEfQ5AG/muL/v62VCzXRfXuMQslMzbuJLUeWeLI+u3T4k/0RnLfg72xbYoiC4+brR6 /XU1Fxc8nJ/S9Hw/MRLZmQXJAx9gyiN7moDxrAd5E0y8RbBa9FctO+OOK7G6ahBiDZBI r+uw== 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 131-20020a630289000000b005139713f0ffsi13071673pgc.805.2023.04.05.07.19.38; Wed, 05 Apr 2023 07:19:51 -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 S238230AbjDEOA5 (ORCPT + 99 others); Wed, 5 Apr 2023 10:00:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41776 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238151AbjDEOAp (ORCPT ); Wed, 5 Apr 2023 10:00:45 -0400 Received: from cloudserver094114.home.pl (cloudserver094114.home.pl [79.96.170.134]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3A4E04C19; Wed, 5 Apr 2023 07:00:43 -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 1a7314477c9562e1; Wed, 5 Apr 2023 16:00:41 +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 E3CF01B4EA57; Wed, 5 Apr 2023 16:00:40 +0200 (CEST) From: "Rafael J. Wysocki" To: Linux ACPI Cc: LKML , Bob Moore , Kees Cook Subject: [PATCH 29/32] ACPICA: acpi_resource_irq: Replace 1-element arrays with flexible array Date: Wed, 05 Apr 2023 15:56:59 +0200 Message-ID: <2105135.bB369e8A3T@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?1762346287738924863?= X-GMAIL-MSGID: =?utf-8?q?1762346287738924863?= From: Kees Cook ACPICA commit bfdd3446e7caf795c85c70326c137023942972c5 Similar to "Replace one-element array with flexible-array", replace the 1-element array with a proper flexible array member as defined by C99. This allows the code to operate without tripping compile-time and run- time bounds checkers (e.g. via __builtin_object_size(), -fsanitize=bounds, and/or -fstrict-flex-arrays=3). Note that the spec requires there be at least one interrupt, so use a union to keep space allocated for this. The only binary change in .text and .data sections is some rearrangement by the compiler of acpi_dm_address_common(), but appears to be harmless. Link: https://github.com/acpica/acpica/commit/bfdd3446 Signed-off-by: Bob Moore Signed-off-by: Rafael J. Wysocki --- drivers/acpi/acpica/amlresrc.h | 5 ++++- include/acpi/acrestyp.h | 10 ++++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/drivers/acpi/acpica/amlresrc.h b/drivers/acpi/acpica/amlresrc.h index 48df447ef5bb..4e88f9fc2a28 100644 --- a/drivers/acpi/acpica/amlresrc.h +++ b/drivers/acpi/acpica/amlresrc.h @@ -261,7 +261,10 @@ struct aml_resource_address16 { struct aml_resource_extended_irq { AML_RESOURCE_LARGE_HEADER_COMMON u8 flags; u8 interrupt_count; - u32 interrupts[1]; + union { + u32 interrupt; + ACPI_FLEX_ARRAY(u32, interrupts); + }; /* res_source_index, res_source optional fields follow */ }; diff --git a/include/acpi/acrestyp.h b/include/acpi/acrestyp.h index 4c3b7b393f82..b84cd316217f 100644 --- a/include/acpi/acrestyp.h +++ b/include/acpi/acrestyp.h @@ -142,7 +142,10 @@ struct acpi_resource_irq { u8 shareable; u8 wake_capable; u8 interrupt_count; - u8 interrupts[1]; + union { + u8 interrupt; + ACPI_FLEX_ARRAY(u8, interrupts); + }; }; struct acpi_resource_dma { @@ -335,7 +338,10 @@ struct acpi_resource_extended_irq { u8 wake_capable; u8 interrupt_count; struct acpi_resource_source resource_source; - u32 interrupts[1]; + union { + u32 interrupt; + ACPI_FLEX_ARRAY(u32, interrupts); + }; }; struct acpi_resource_generic_register {