From patchwork Fri Jan 27 19:16:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kees Cook X-Patchwork-Id: 49604 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp1001767wrn; Fri, 27 Jan 2023 11:19:18 -0800 (PST) X-Google-Smtp-Source: AK7set+2b0rPdWhW/WK++6bC6WKCUPh9rIlXahjDKE/csskbDCdQlPShXh8P+K/M5oPFSGX7ZLl1 X-Received: by 2002:a05:6a20:a015:b0:bc:3ae8:5a9e with SMTP id p21-20020a056a20a01500b000bc3ae85a9emr4263175pzj.39.1674847158429; Fri, 27 Jan 2023 11:19:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674847158; cv=none; d=google.com; s=arc-20160816; b=BDu5qaguOnY1R5veXvNIdWnjtgrKKUVYCcD/SmBPleslcQOuhkyv2F04udUeokduDy ryPmgvJf8/YBgSLKeyT/8uRt8/keKlTWIfYf7sOQqNIaWZ+kQ9gQ9L/zx16S7sfktNwR Vtgv7hrcvUGTfDexdLotGxWi2KRJG27TTgYfHurZXDVJ7DPOh+S9Mxpv59XfsDj/mlBO wxRRpmo2UoYS1BXucVMFrWhedeog6oO2E9cOq7x9fgusGSS3zQfM6+t7xv7y9ZU+ngNx JCUmZlI1GWWC7LCyhkdMoh7iQfqSG8aJYFevUOGKbbMdN0mTE52ft+/86kbnVPvVruxI CkIQ== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=pSndjEFPQ8hAZKvh/r+nd2nnOGer9rU0gXriWQsIEEQ=; b=eBaO55Z0SMW8xPtNtOPPSp/Xhhqzf5ZEK6H0XZ3ThMwAEdPgjiBdjwaty26xSL8ysN EVdBUPgUxg0xa7QxrEKfGz0/CjD6gk2rn0wc/JIu1QXR1EntAyP+bBKl9N+Ls2jY0asq 8K9x7OdOh+UrF2Ys9+VEEohMqQUQZv5QVesyXNAwmlIXS6Rkq0QlIF/P0F/Ua0eCHQ4Z N6IIP16+Y53akUPu5/CGpyRpAMNr6YvGx2zqlAm+bS9cDROQtPiO/RsQMh852pfaJDot Uqk+/S6s2kig6Sj9dTBoVMzvXwDJvwXA4K+op/QBnikBIDtRhFyEVkS9LU3a0oUYyOLs I/fg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=LUcZtXDP; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id o8-20020a656a48000000b004d058989ad7si5701596pgu.255.2023.01.27.11.19.06; Fri, 27 Jan 2023 11:19:18 -0800 (PST) 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; dkim=pass header.i=@chromium.org header.s=google header.b=LUcZtXDP; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231910AbjA0TQc (ORCPT + 99 others); Fri, 27 Jan 2023 14:16:32 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34078 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230414AbjA0TQb (ORCPT ); Fri, 27 Jan 2023 14:16:31 -0500 Received: from mail-pl1-x630.google.com (mail-pl1-x630.google.com [IPv6:2607:f8b0:4864:20::630]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 77E317BBD8 for ; Fri, 27 Jan 2023 11:16:30 -0800 (PST) Received: by mail-pl1-x630.google.com with SMTP id x5so2535966plr.2 for ; Fri, 27 Jan 2023 11:16:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=pSndjEFPQ8hAZKvh/r+nd2nnOGer9rU0gXriWQsIEEQ=; b=LUcZtXDPuEtFizj4Bs7VHv9wEcnEa5uELvDLcfiOt+HJ0z3U654Zhq92ouD/AvxRyJ c4WnLYzr+R+XOlzI0VTTLfmOBHry4yWAT6owaEPUbPYj6oRurSbYPeR2wm02MmeLSkZT +xbZgirrx0mRSif3xvfWmnr8a0lC4nShZYmko= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=pSndjEFPQ8hAZKvh/r+nd2nnOGer9rU0gXriWQsIEEQ=; b=poYyIN3bW37NUGGzbpCUru8nt4OhfTG5mfszLLqyJUhMO4R26cJq0McEYUpperLOc8 g8K2NtUHHALxsAHdoRNh0bu23+XQ+nua0KMm9LMEx2fk0P3YPx//PIcnAW/M4TY2gw49 iU9vxNJK6CoRU7xgopjpqkwJAfQaJqmd2aE9R54CaKcC7u79uDVp4hnL/RoBkmtYndjV l2Yy5v4gjrmNgjvBYg3grQ88tMamm9sFYAR9dXOEMJbOipU8dlb7qWGSiRaVMBRum8iy 8EHhc8mc1wFRAs6uYdnTLEbq401ApiLhLteLrkej80c5+j+a+F5Qd9wSQDjixvHagupJ yDTw== X-Gm-Message-State: AFqh2kqwjvk/LK8gxZmctoCC6DvobDEGrWqXuD0/KQzntigvkMPr/bnM ZJmPl1KjlBQVhQAlkQ2WF69DWw== X-Received: by 2002:a17:902:d650:b0:193:13fc:8840 with SMTP id y16-20020a170902d65000b0019313fc8840mr38951507plh.21.1674846989961; Fri, 27 Jan 2023 11:16:29 -0800 (PST) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id m9-20020a170902bb8900b0019488090884sm3179644pls.273.2023.01.27.11.16.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 27 Jan 2023 11:16:29 -0800 (PST) From: Kees Cook To: "Rafael J . Wysocki" Cc: Kees Cook , "Rafael J. Wysocki" , Len Brown , Robert Moore , linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org, devel@acpica.org, linux-hardening@vger.kernel.org Subject: [PATCH v2] ACPICA: Replace fake flexible arrays with flexible array members Date: Fri, 27 Jan 2023 11:16:25 -0800 Message-Id: <20230127191621.gonna.262-kees@kernel.org> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1970; h=from:subject:message-id; bh=GuYHj8k1bgoDrYd8xgMK12HekFco3rn1yc6XfKftvic=; b=owEBbQKS/ZANAwAKAYly9N/cbcAmAcsmYgBj1CMJvYoAMRsu0wMAJoD56KtcmU8zpzJsIG2mPkda Kr5gyviJAjMEAAEKAB0WIQSlw/aPIp3WD3I+bhOJcvTf3G3AJgUCY9QjCQAKCRCJcvTf3G3AJo1jEA CJ3BAb/MM8rhQFPA22R+3S7Y5SiuCw4thqyflZIJip4u3apW9Q3pq2TusNrysgAnfATXJdKwowgwt5 QaCYwkfsRjglE68wgcjA3vmcjNIEaFNEo5u49ulY0UTUC83oDdU0Yy9OGiRAIGpDd+cZpHbGreuguw qzNwxCoIRS9WATvILCYcdoj6c5qN5AOg1ZVtOiIeimIW9P03r//Vj+U5pB+XxjutDXMg8/t9KqzVlS 3VilEtucB2flo/RNPuTf3j89WIEj83C5ozYB+9UyNxbMqGn9v2IXrTY36+zPBa9r7K+8lvXm54KBc/ iA9OgrnbsuTqBS1NcxqPfqbSN2SDPiqFrniYX2oJCoHH9r+MhTh5mhkDX3UQbQsDlwpV4PoWw/whNu lCdUufowLczpB08TzO1KjGuNnZVGoTS3GZ9cgMHLUgamLS0SCBFrXRLp4IO6iiuNL7PBrh8Jqx5tEc nisX+chLSWPnPc37aYdKDJEqLPg19Cul7c5tF70ytEKprjVpGDXmTTVQFHH+YHOr4QVEC8+udGZrMQ hb0cPsdaGxGZIOB8ODlSQNcZRYMavA9nhW66okMVO1akfp6oMrXsxbefLIP3RlINcOPSQdE0nKHMam 1eLWpq52IFchwf9YjZS6vxsT+kVoacT99yKwLqcHeQx0KUtaAxcxJYBsLEzQ== X-Developer-Key: i=keescook@chromium.org; a=openpgp; fpr=A5C3F68F229DD60F723E6E138972F4DFDC6DC026 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=ham 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?1756204534334625061?= X-GMAIL-MSGID: =?utf-8?q?1756204534334625061?= One-element arrays (and multi-element arrays being treated as dynamically sized) are deprecated[1] and are being replaced with flexible array members in support of the ongoing efforts to tighten the FORTIFY_SOURCE routines on memcpy(), correctly instrument array indexing with UBSAN_BOUNDS, and to globally enable -fstrict-flex-arrays=3. Replace one-element array with flexible-array member in struct acpi_resource_extended_irq. Replace 4-byte fixed-size array with 4-byte padding in a union with a flexible-array member in struct acpi_pci_routing_table. This results in no differences in binary output. Link: https://github.com/acpica/acpica/pull/813 Signed-off-by: Kees Cook Signed-off-by: Rafael J. Wysocki --- v2: include stddef.h and switch to __DECLARE_FLEX_ARRAY() v1: https://lore.kernel.org/lkml/20221118181538.never.225-kees@kernel.org/ --- include/acpi/acrestyp.h | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/include/acpi/acrestyp.h b/include/acpi/acrestyp.h index a7fb8ddb3dc6..250046a7c870 100644 --- a/include/acpi/acrestyp.h +++ b/include/acpi/acrestyp.h @@ -10,6 +10,8 @@ #ifndef __ACRESTYP_H__ #define __ACRESTYP_H__ +#include + /* * Definitions for Resource Attributes */ @@ -332,7 +334,7 @@ struct acpi_resource_extended_irq { u8 wake_capable; u8 interrupt_count; struct acpi_resource_source resource_source; - u32 interrupts[1]; + u32 interrupts[]; }; struct acpi_resource_generic_register { @@ -679,7 +681,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 */ + __DECLARE_FLEX_ARRAY(char, source); + }; }; #endif /* __ACRESTYP_H__ */