Message ID | 20221118211146.never.395-kees@kernel.org |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp410730wrr; Fri, 18 Nov 2022 13:12:35 -0800 (PST) X-Google-Smtp-Source: AA0mqf4Rn6v1JysUrobjhjEMXraWFrx50wvEZB0xJl34lGX+z0oo3s1POpXyFt7/7ShasdNv/B7W X-Received: by 2002:a17:90b:2744:b0:218:7675:ba83 with SMTP id qi4-20020a17090b274400b002187675ba83mr8982151pjb.61.1668805955151; Fri, 18 Nov 2022 13:12:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668805955; cv=none; d=google.com; s=arc-20160816; b=cWdpQUR/GAey/yxVqm71jINmfvMuB3uXgHobPrYFB6whkvdexAzCEi24vfd0Kv+0+g YdDn907Lyl1/TXfE03QMdUGgWrS/bIZE1ReaUGNtYffeb4y8t30bqku0r0l2/ZK43S7c ypx1n0IZm6RdrihKQZpb4E7m4g9JyMjZyXeGfjsBF87bXSIR/ZyCTECgCu0JdRVvephE t2YU0PDuWwdOpCltqPBM22sqbQuJ+t8xak8K9smmiUklBX0LUSHLflduzyyisFWv+OtE s+0cQFVZmSbTP1ljsHooRYi11T0RqLVUgO97C42Kf6uZg9iw+lLIhiH5A1+YGPujAXUg sNlQ== 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=HS164PT1thWPX3+gJIUevbDgvzJj6XIx86U2ombNC6E=; b=mzH9vWNkrK3GRwD7ShiQQfmsBTw7mrKSa+wGkqoovqqs9dYOIChNmvvW1lmq5GlJfG 6ROJ8sEmJLAnbFrDI1jO2CFyGVlRgIB2w/0/gDTno64nfABApppgMIsi/ztoy3Jgo49J qDQTZbQ6mOD3wyW2casRtlMKVGhj2og6wRPU0yuwDqIXseMoJYuNiP/NOXRYlTMpY1nx qGQllb1yv0bIeTrrDnsVn4Z3C8FIeNp3SuyMQNk7fu4un412n3uyAl2rPpu9VokMl7w6 S1xvHcjpB4Wo4Pq2LaYVyzArY0qG27xPBaVFWEf37X/m+HiNZv57qWJVTxIhr6Equ0Ot X9Jg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b="V/10M61B"; 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 z1-20020a1709028f8100b00176b7b8cf2esi4022433plo.586.2022.11.18.13.12.17; Fri, 18 Nov 2022 13:12:35 -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="V/10M61B"; 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 S230088AbiKRVLx (ORCPT <rfc822;kkmonlee@gmail.com> + 99 others); Fri, 18 Nov 2022 16:11:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57716 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229506AbiKRVLu (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Fri, 18 Nov 2022 16:11:50 -0500 Received: from mail-pj1-x1030.google.com (mail-pj1-x1030.google.com [IPv6:2607:f8b0:4864:20::1030]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 129F07CBA9 for <linux-kernel@vger.kernel.org>; Fri, 18 Nov 2022 13:11:50 -0800 (PST) Received: by mail-pj1-x1030.google.com with SMTP id d13-20020a17090a3b0d00b00213519dfe4aso6196501pjc.2 for <linux-kernel@vger.kernel.org>; Fri, 18 Nov 2022 13:11:50 -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=HS164PT1thWPX3+gJIUevbDgvzJj6XIx86U2ombNC6E=; b=V/10M61BAwjqfgwtW4m6+OLQQQVNW5qdkveInE2+NDix/ZB0ARQlpjaAePjf5krNjS MfLKsZzwmVtauIFxprl09NW9We65OAoxeJWj7HCzZ/aVDrFkBYTHh1dkZ6nuM9dC16uU ucPcJeE0B3y0t2RAv5Of1RObH4YoSyPsD1+cQ= 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=HS164PT1thWPX3+gJIUevbDgvzJj6XIx86U2ombNC6E=; b=zU4trdxIvz73b6MP1QRXou/GfLTrsAHrbmEYe9D4h4wgt5ZFBXYXWu3QRMVyqH+Vw0 DN6/VvX6nrV9rfCEXxzwsjAjwxbHQfeuo3tWNg3PG0P5mVv1z7jrOo3wZkvq2BvViBWK NL31XfIXDP1/MBd89a5mmnkFCDKeXAhvKMHGLmBXmbphUlf3uwsIyIrzCU3jnDFOeS2q orasR+nq3Cc3A7i7crPa2XuLRYryGbcNpV3KtS9fTn1cpGQ2H3X3i0zqh3WNPld+bokg OdEfiS7k5sv15NZq0cDnHyUBCl3inNPDln5bAHG0hs4yazQKrk7FvbF5rOxb5IarLdLR FPbQ== X-Gm-Message-State: ANoB5pm8nBFepq5XPC9DpEytVY+pqJHk80raI5X4Fi5wKLeeY0jfnPRW C2wV+xS0vrS4XCwSr+73uZyzNg== X-Received: by 2002:a17:902:e385:b0:178:7040:9917 with SMTP id g5-20020a170902e38500b0017870409917mr1179204ple.109.1668805909571; Fri, 18 Nov 2022 13:11:49 -0800 (PST) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id c6-20020a170902d48600b001782aab6318sm4262797plg.68.2022.11.18.13.11.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Nov 2022 13:11:49 -0800 (PST) From: Kees Cook <keescook@chromium.org> To: Christian Lamparter <chunkeey@googlemail.com> Cc: Kees Cook <keescook@chromium.org>, Kalle Valo <kvalo@kernel.org>, "David S. Miller" <davem@davemloft.net>, Eric Dumazet <edumazet@google.com>, Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>, "Gustavo A. R. Silva" <gustavoars@kernel.org>, linux-wireless@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org Subject: [PATCH] carl9170: Replace zero-length array of trailing structs with flex-array Date: Fri, 18 Nov 2022 13:11:47 -0800 Message-Id: <20221118211146.never.395-kees@kernel.org> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1483; h=from:subject:message-id; bh=9oKJHA3pSUUlk2XRtoon41DyXm9EC5lRgSnJeNNG7Nk=; b=owEBbQKS/ZANAwAKAYly9N/cbcAmAcsmYgBjd/USLIkMsbwjhdEbLcOY3U5QPGKPBFNJ6YbZMJoZ 0ZDGQQyJAjMEAAEKAB0WIQSlw/aPIp3WD3I+bhOJcvTf3G3AJgUCY3f1EgAKCRCJcvTf3G3AJpHOD/ wKY0GQZ2A8TAEq1UQ7FG9SLArIMDJDDT3g0EpAw5ve8vW+sMh1nv5jJPGd8MQerkzsujTsSPrh2G0c iPQbn+HlI6aQaDOuiuSEdMKJGqqOc/1WP87GGY3OOXa5shhaD6q8AQkfHE6oyrEuK33xeOmJVICKgY Av32wZ2kSTKy2HDZi+GdBlSzpoqkUFdB9AcQgajJ2V+ZbLWqvvWgQCUoU74qjujZDjsXqYuZJcBYdl CdsXdbJ7sYziQAXJB4p8ssHBg1rEfjeVaCx1066DHscGXgYa/if5SgIsCF5IE9pDxAKsUUEOGTYQPc ZsR+njBItdiDY8DYJSUCrstNR6hEmyJpA0u4cUsgH2uakYnt8hL43yIF4DTsNOpTqWDWUpoZpN14dh O4EHhbIrbHblUcz5TeFZgsg22MghgJlJMpsvW11AbpPtSH5rIwy5r7djol/fdNUeybVldBD5ZKVXCj 38UdKomgY//3Q+0O0D0SRKiTDgz3BJSRXrBAjSlu87cdhpNwXUvqoDeYsEcHi09tMwV8+46jUCZsEg SbDJFy4ZTezHATrffDLbWweDBK+LQo2UkP+WZVkah2C5E/Lj9wTIsoY1SXjbp1Bfv1U84zLoXOdpx8 fUksnNUWfZKOxTivJKSp1hVpry3W82obZcOz5rsCc6xdn67sycGb5AKyWgHw== X-Developer-Key: i=keescook@chromium.org; a=openpgp; fpr=A5C3F68F229DD60F723E6E138972F4DFDC6DC026 Content-Transfer-Encoding: 8bit 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749869873380894688?= X-GMAIL-MSGID: =?utf-8?q?1749869873380894688?= |
Series |
carl9170: Replace zero-length array of trailing structs with flex-array
|
|
Commit Message
Kees Cook
Nov. 18, 2022, 9:11 p.m. UTC
Zero-length arrays 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 zero-length array with flexible-array member.
This results in no differences in binary output.
[1] https://github.com/KSPP/linux/issues/78
Cc: Christian Lamparter <chunkeey@googlemail.com>
Cc: Kalle Valo <kvalo@kernel.org>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Eric Dumazet <edumazet@google.com>
Cc: Jakub Kicinski <kuba@kernel.org>
Cc: Paolo Abeni <pabeni@redhat.com>
Cc: "Gustavo A. R. Silva" <gustavoars@kernel.org>
Cc: linux-wireless@vger.kernel.org
Cc: netdev@vger.kernel.org
Signed-off-by: Kees Cook <keescook@chromium.org>
---
drivers/net/wireless/ath/carl9170/fwcmd.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
Comments
On Fri, Nov 18, 2022 at 01:11:47PM -0800, Kees Cook wrote: > Zero-length arrays 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 zero-length array with flexible-array member. > > This results in no differences in binary output. > > [1] https://github.com/KSPP/linux/issues/78 > > Cc: Christian Lamparter <chunkeey@googlemail.com> > Cc: Kalle Valo <kvalo@kernel.org> > Cc: "David S. Miller" <davem@davemloft.net> > Cc: Eric Dumazet <edumazet@google.com> > Cc: Jakub Kicinski <kuba@kernel.org> > Cc: Paolo Abeni <pabeni@redhat.com> > Cc: "Gustavo A. R. Silva" <gustavoars@kernel.org> > Cc: linux-wireless@vger.kernel.org > Cc: netdev@vger.kernel.org > Signed-off-by: Kees Cook <keescook@chromium.org> Another sneaky one. :p Reviewed-by: Gustavo A. R. Silva <gustavoars@kernel.org> Thanks! -- Gustavo > --- > drivers/net/wireless/ath/carl9170/fwcmd.h | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/drivers/net/wireless/ath/carl9170/fwcmd.h b/drivers/net/wireless/ath/carl9170/fwcmd.h > index 4a500095555c..ff4b3b50250c 100644 > --- a/drivers/net/wireless/ath/carl9170/fwcmd.h > +++ b/drivers/net/wireless/ath/carl9170/fwcmd.h > @@ -118,10 +118,10 @@ struct carl9170_reg_list { > } __packed; > > struct carl9170_write_reg { > - struct { > + DECLARE_FLEX_ARRAY(struct { > __le32 addr; > __le32 val; > - } regs[0] __packed; > + } __packed, regs); > } __packed; > > struct carl9170_write_reg_byte { > -- > 2.34.1 >
On 11/18/22 22:11, Kees Cook wrote: > Zero-length arrays 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 zero-length array with flexible-array member. > > This results in no differences in binary output. > > [1] https://github.com/KSPP/linux/issues/78 > > Cc: Christian Lamparter <chunkeey@googlemail.com> > Cc: Kalle Valo <kvalo@kernel.org> > Cc: "David S. Miller" <davem@davemloft.net> > Cc: Eric Dumazet <edumazet@google.com> > Cc: Jakub Kicinski <kuba@kernel.org> > Cc: Paolo Abeni <pabeni@redhat.com> > Cc: "Gustavo A. R. Silva" <gustavoars@kernel.org> > Cc: linux-wireless@vger.kernel.org > Cc: netdev@vger.kernel.org > Signed-off-by: Kees Cook <keescook@chromium.org> Acked-by: Christian Lamparter <chunkeey@gmail.com> > --- > drivers/net/wireless/ath/carl9170/fwcmd.h | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/drivers/net/wireless/ath/carl9170/fwcmd.h b/drivers/net/wireless/ath/carl9170/fwcmd.h > index 4a500095555c..ff4b3b50250c 100644 > --- a/drivers/net/wireless/ath/carl9170/fwcmd.h > +++ b/drivers/net/wireless/ath/carl9170/fwcmd.h > @@ -118,10 +118,10 @@ struct carl9170_reg_list { > } __packed; > > struct carl9170_write_reg { > - struct { > + DECLARE_FLEX_ARRAY(struct { > __le32 addr; > __le32 val; > - } regs[0] __packed; > + } __packed, regs); > } __packed; > > struct carl9170_write_reg_byte {
Kees Cook <keescook@chromium.org> writes: > Zero-length arrays 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 zero-length array with flexible-array member. > > This results in no differences in binary output. > > [1] https://github.com/KSPP/linux/issues/78 > > Cc: Christian Lamparter <chunkeey@googlemail.com> > Cc: Kalle Valo <kvalo@kernel.org> > Cc: "David S. Miller" <davem@davemloft.net> > Cc: Eric Dumazet <edumazet@google.com> > Cc: Jakub Kicinski <kuba@kernel.org> > Cc: Paolo Abeni <pabeni@redhat.com> > Cc: "Gustavo A. R. Silva" <gustavoars@kernel.org> > Cc: linux-wireless@vger.kernel.org > Cc: netdev@vger.kernel.org > Signed-off-by: Kees Cook <keescook@chromium.org> Nowadays we include "wifi:" in the subject, but I can add that. But please use this in the future for all wireless patches.
On Sat, Nov 19, 2022 at 08:39:11AM +0200, Kalle Valo wrote: > Kees Cook <keescook@chromium.org> writes: > > > Zero-length arrays 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 zero-length array with flexible-array member. > > > > This results in no differences in binary output. > > > > [1] https://github.com/KSPP/linux/issues/78 > > > > Cc: Christian Lamparter <chunkeey@googlemail.com> > > Cc: Kalle Valo <kvalo@kernel.org> > > Cc: "David S. Miller" <davem@davemloft.net> > > Cc: Eric Dumazet <edumazet@google.com> > > Cc: Jakub Kicinski <kuba@kernel.org> > > Cc: Paolo Abeni <pabeni@redhat.com> > > Cc: "Gustavo A. R. Silva" <gustavoars@kernel.org> > > Cc: linux-wireless@vger.kernel.org > > Cc: netdev@vger.kernel.org > > Signed-off-by: Kees Cook <keescook@chromium.org> > > Nowadays we include "wifi:" in the subject, but I can add that. But > please use this in the future for all wireless patches. Okay, thanks! I use a recency/frequency prefix guesser, but I've updated it to include "wifi: " if "linux-wireless@vger.kernel.org" is in CC. :)
Kees Cook <keescook@chromium.org> wrote: > Zero-length arrays 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 zero-length array with flexible-array member. > > This results in no differences in binary output. > > [1] https://github.com/KSPP/linux/issues/78 > > Cc: Christian Lamparter <chunkeey@googlemail.com> > Cc: Kalle Valo <kvalo@kernel.org> > Cc: "David S. Miller" <davem@davemloft.net> > Cc: Eric Dumazet <edumazet@google.com> > Cc: Jakub Kicinski <kuba@kernel.org> > Cc: Paolo Abeni <pabeni@redhat.com> > Cc: "Gustavo A. R. Silva" <gustavoars@kernel.org> > Cc: linux-wireless@vger.kernel.org > Cc: netdev@vger.kernel.org > Signed-off-by: Kees Cook <keescook@chromium.org> > Reviewed-by: Gustavo A. R. Silva <gustavoars@kernel.org> > Acked-by: Christian Lamparter <chunkeey@gmail.com> > Signed-off-by: Kalle Valo <quic_kvalo@quicinc.com> Patch applied to ath-next branch of ath.git, thanks. 7256f28767fa wifi: carl9170: Replace zero-length array of trailing structs with flex-array
diff --git a/drivers/net/wireless/ath/carl9170/fwcmd.h b/drivers/net/wireless/ath/carl9170/fwcmd.h index 4a500095555c..ff4b3b50250c 100644 --- a/drivers/net/wireless/ath/carl9170/fwcmd.h +++ b/drivers/net/wireless/ath/carl9170/fwcmd.h @@ -118,10 +118,10 @@ struct carl9170_reg_list { } __packed; struct carl9170_write_reg { - struct { + DECLARE_FLEX_ARRAY(struct { __le32 addr; __le32 val; - } regs[0] __packed; + } __packed, regs); } __packed; struct carl9170_write_reg_byte {