[next] wifi: mt76: mt7996: Use DECLARE_FLEX_ARRAY() and fix -Warray-bounds warnings
Message ID | ZVaCNAohuieMmdq9@work |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9910:0:b0:403:3b70:6f57 with SMTP id i16csp110580vqn; Thu, 16 Nov 2023 12:57:54 -0800 (PST) X-Google-Smtp-Source: AGHT+IFjHgDgI1tWcqaFe+OldWKgkqh7Wc1/IAgwuhMqofDOYKvLJPpd8GUhzq8I2PAciAQ0NdQa X-Received: by 2002:a17:902:dad0:b0:1cc:ab06:e6c8 with SMTP id q16-20020a170902dad000b001ccab06e6c8mr11892065plx.19.1700168274533; Thu, 16 Nov 2023 12:57:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700168274; cv=none; d=google.com; s=arc-20160816; b=vNP32gbx+3htG1zaot1M6g7IrcqT8avarc/PkrTsVZY/tvj4PweLEsSsDWapBPzP7B Vxokbc6RJUxPqPMLa+9Rh1cPHNvlCNYYDlYcPMCZKoMfeC5mpmRWHeBRknUbaYjb8L38 eVxjg38mRIrbpBPi6cpEMv4pU6up6xDB9GyN8hp7D6BN7tlXM2Mr9Lb3Q7fBksZ4VJ4i NNCsZmwpbFI+y2H4padBzPFcml0gCNFGHY7+xiY2JkS5gV5Zc45rMuTR+KTykIu6ON2w Cbgo0OX7chVjfndP0sWuKEUy5PnBweHIpkd28K6ssu5qfkk5POiZ8AYFdWbe1kTRT7U/ m7qg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-disposition:mime-version:message-id :subject:cc:to:from:date:dkim-signature; bh=qpSxMQD02TbsUjTC1Qh5tk5c3aZ2Y6bmVsRYWu1ctPE=; fh=7fJJzRs3oTDjU7TQgWN/mreKhtkabzaQXCCLPhdjZws=; b=gs7V6RZgGFCd4SDBODUuwxUS1Q4/8Ij5sUXrml1CCoURrHjEVxl/5EEUzZY5zPtzet oJPb7KMNBnAcW2fV53Qr1dmqoybmOs+2PzzBzv8hF5IYjQlVSMxx+hcYOr7EnxvZjcU+ XO+QDjNVwSzlArp8qsaNrGSMz1GmpcFllGkmZTfubaFkhcdE4FUv4fTk65Qwiq39x/TD mGjkMDTBVKLThMBS4D3mBpVaphT5nV7n6RAbL9jzkTk/ST7we0cFKDu80D/HjvA3+lnk T/Pqb2CaC/I6KO/CDWWEWqR1oPf8mvLfeMp31j1ydYvFW21IeKtyQ51WzO0wdEN4dpV0 K9Cw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=PMUVa2AI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id a24-20020a170902b59800b001c60c109ce7si206878pls.295.2023.11.16.12.57.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Nov 2023 12:57:54 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=PMUVa2AI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id E0B90809C173; Thu, 16 Nov 2023 12:57:47 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229667AbjKPU5c (ORCPT <rfc822;jaysivo@gmail.com> + 30 others); Thu, 16 Nov 2023 15:57:32 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58430 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229379AbjKPU5b (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Thu, 16 Nov 2023 15:57:31 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C0ADDD4A; Thu, 16 Nov 2023 12:57:28 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id ECB93C433C7; Thu, 16 Nov 2023 20:57:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1700168248; bh=EjMKx5nsjR7WnKWGm9tsxjc3r1t11YJJEx0o24R8FgU=; h=Date:From:To:Cc:Subject:From; b=PMUVa2AIRiGi8EJ9pjFjU+974IoHgg3yEfJ31Q9eTjA5HYvoe/4QP4QL2J9Tenblg 5FJZRhqYP3RWZ47tL7qcdk86sP+MG/N68JJSpgBITaZCaL4u2XJD3hoyQ8OmoUFH3V PfBT1Z4KSpHLm75VCOe7WRYrDcFtVAimRoIy3l7MqTJR+ZygB6jkZl3egpJ0iD1O2M LIGs67TT1sWFvI9fzCfybzPrXyytxkGjPQnYIO0qiXtkBNS5Uo3FfSIBSWoig8xcJ9 wWRMUUL/LbjCZS/zA53qqnm+OsCno8mT/vBa1PQu13Q+yLWPTMzAp+izmKxXO9XRfO zmU8iEHtVjnxw== Date: Thu, 16 Nov 2023 14:57:24 -0600 From: "Gustavo A. R. Silva" <gustavoars@kernel.org> To: Felix Fietkau <nbd@nbd.name>, Lorenzo Bianconi <lorenzo@kernel.org>, Ryder Lee <ryder.lee@mediatek.com>, Shayne Chen <shayne.chen@mediatek.com>, Sean Wang <sean.wang@mediatek.com>, Kalle Valo <kvalo@kernel.org>, Matthias Brugger <matthias.bgg@gmail.com>, AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com> Cc: linux-wireless@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, "Gustavo A. R. Silva" <gustavoars@kernel.org>, linux-hardening@vger.kernel.org Subject: [PATCH][next] wifi: mt76: mt7996: Use DECLARE_FLEX_ARRAY() and fix -Warray-bounds warnings Message-ID: <ZVaCNAohuieMmdq9@work> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Spam-Status: No, score=-1.3 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Thu, 16 Nov 2023 12:57:48 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1782755648838523799 X-GMAIL-MSGID: 1782755648838523799 |
Series |
[next] wifi: mt76: mt7996: Use DECLARE_FLEX_ARRAY() and fix -Warray-bounds warnings
|
|
Commit Message
Gustavo A. R. Silva
Nov. 16, 2023, 8:57 p.m. UTC
Transform zero-length arrays `adm_stat` and `msdu_cnt` into proper
flexible-array members in anonymous union in `struct
mt7996_mcu_all_sta_info_event` via the DECLARE_FLEX_ARRAY()
helper; and fix multiple -Warray-bounds warnings:
drivers/net/wireless/mediatek/mt76/mt7996/mcu.c:483:61: warning: array subscript <unknown> is outside array bounds of 'struct <anonymous>[0]' [-Warray-bounds=]
drivers/net/wireless/mediatek/mt76/mt7996/mcu.c:490:58: warning: array subscript <unknown> is outside array bounds of 'struct <anonymous>[0]' [-Warray-bounds=]
drivers/net/wireless/mediatek/mt76/mt7996/mcu.c:492:58: warning: array subscript <unknown> is outside array bounds of 'struct <anonymous>[0]' [-Warray-bounds=]
drivers/net/wireless/mediatek/mt76/mt7996/mcu.c:469:61: warning: array subscript <unknown> is outside array bounds of 'struct <anonymous>[0]' [-Warray-bounds=]
drivers/net/wireless/mediatek/mt76/mt7996/mcu.c:477:66: warning: array subscript <unknown> is outside array bounds of 'struct <anonymous>[0]' [-Warray-bounds=]
drivers/net/wireless/mediatek/mt76/mt7996/mcu.c:479:66: warning: array subscript <unknown> is outside array bounds of 'struct <anonymous>[0]' [-Warray-bounds=]
This results in no differences in binary output, helps with the ongoing
efforts to globally enable -Warray-bounds.
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
---
drivers/net/wireless/mediatek/mt76/mt7996/mcu.h | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
Comments
On Thu, Nov 16, 2023 at 02:57:24PM -0600, Gustavo A. R. Silva wrote: > Transform zero-length arrays `adm_stat` and `msdu_cnt` into proper > flexible-array members in anonymous union in `struct > mt7996_mcu_all_sta_info_event` via the DECLARE_FLEX_ARRAY() > helper; and fix multiple -Warray-bounds warnings: > > drivers/net/wireless/mediatek/mt76/mt7996/mcu.c:483:61: warning: array subscript <unknown> is outside array bounds of 'struct <anonymous>[0]' [-Warray-bounds=] > drivers/net/wireless/mediatek/mt76/mt7996/mcu.c:490:58: warning: array subscript <unknown> is outside array bounds of 'struct <anonymous>[0]' [-Warray-bounds=] > drivers/net/wireless/mediatek/mt76/mt7996/mcu.c:492:58: warning: array subscript <unknown> is outside array bounds of 'struct <anonymous>[0]' [-Warray-bounds=] > drivers/net/wireless/mediatek/mt76/mt7996/mcu.c:469:61: warning: array subscript <unknown> is outside array bounds of 'struct <anonymous>[0]' [-Warray-bounds=] > drivers/net/wireless/mediatek/mt76/mt7996/mcu.c:477:66: warning: array subscript <unknown> is outside array bounds of 'struct <anonymous>[0]' [-Warray-bounds=] > drivers/net/wireless/mediatek/mt76/mt7996/mcu.c:479:66: warning: array subscript <unknown> is outside array bounds of 'struct <anonymous>[0]' [-Warray-bounds=] > > This results in no differences in binary output, helps with the ongoing > efforts to globally enable -Warray-bounds. > > Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org> The syntax looks a little funny initially, but yeah, that's how we need to fix it for now. Reviewed-by: Kees Cook <keescook@chromium.org>
On Thu, Nov 16, 2023 at 02:57:24PM -0600, Gustavo A. R. Silva wrote: > Transform zero-length arrays `adm_stat` and `msdu_cnt` into proper > flexible-array members in anonymous union in `struct > mt7996_mcu_all_sta_info_event` via the DECLARE_FLEX_ARRAY() > helper; and fix multiple -Warray-bounds warnings: > > drivers/net/wireless/mediatek/mt76/mt7996/mcu.c:483:61: warning: array subscript <unknown> is outside array bounds of 'struct <anonymous>[0]' [-Warray-bounds=] > drivers/net/wireless/mediatek/mt76/mt7996/mcu.c:490:58: warning: array subscript <unknown> is outside array bounds of 'struct <anonymous>[0]' [-Warray-bounds=] > drivers/net/wireless/mediatek/mt76/mt7996/mcu.c:492:58: warning: array subscript <unknown> is outside array bounds of 'struct <anonymous>[0]' [-Warray-bounds=] > drivers/net/wireless/mediatek/mt76/mt7996/mcu.c:469:61: warning: array subscript <unknown> is outside array bounds of 'struct <anonymous>[0]' [-Warray-bounds=] > drivers/net/wireless/mediatek/mt76/mt7996/mcu.c:477:66: warning: array subscript <unknown> is outside array bounds of 'struct <anonymous>[0]' [-Warray-bounds=] > drivers/net/wireless/mediatek/mt76/mt7996/mcu.c:479:66: warning: array subscript <unknown> is outside array bounds of 'struct <anonymous>[0]' [-Warray-bounds=] > > This results in no differences in binary output, helps with the ongoing > efforts to globally enable -Warray-bounds. > > Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org> *thread ping* Can wireless folks please pick this patch up? -Kees > --- > drivers/net/wireless/mediatek/mt76/mt7996/mcu.h | 8 ++++---- > 1 file changed, 4 insertions(+), 4 deletions(-) > > diff --git a/drivers/net/wireless/mediatek/mt76/mt7996/mcu.h b/drivers/net/wireless/mediatek/mt76/mt7996/mcu.h > index a88f6af323da..9f516f796d63 100644 > --- a/drivers/net/wireless/mediatek/mt76/mt7996/mcu.h > +++ b/drivers/net/wireless/mediatek/mt76/mt7996/mcu.h > @@ -163,19 +163,19 @@ struct mt7996_mcu_all_sta_info_event { > u8 rsv3[2]; > > union { > - struct { > + DECLARE_FLEX_ARRAY(struct { > __le16 wlan_idx; > u8 rsv[2]; > __le32 tx_bytes[IEEE80211_NUM_ACS]; > __le32 rx_bytes[IEEE80211_NUM_ACS]; > - } adm_stat[0]; > + }, adm_stat); > > - struct { > + DECLARE_FLEX_ARRAY(struct { > __le16 wlan_idx; > u8 rsv[2]; > __le32 tx_msdu_cnt; > __le32 rx_msdu_cnt; > - } msdu_cnt[0]; > + }, msdu_cnt); > }; > } __packed; > > -- > 2.34.1 >
Kees Cook <keescook@chromium.org> writes: > On Thu, Nov 16, 2023 at 02:57:24PM -0600, Gustavo A. R. Silva wrote: > >> Transform zero-length arrays `adm_stat` and `msdu_cnt` into proper >> flexible-array members in anonymous union in `struct >> mt7996_mcu_all_sta_info_event` via the DECLARE_FLEX_ARRAY() >> helper; and fix multiple -Warray-bounds warnings: >> >> drivers/net/wireless/mediatek/mt76/mt7996/mcu.c:483:61: warning: >> array subscript <unknown> is outside array bounds of 'struct >> <anonymous>[0]' [-Warray-bounds=] >> drivers/net/wireless/mediatek/mt76/mt7996/mcu.c:490:58: warning: >> array subscript <unknown> is outside array bounds of 'struct >> <anonymous>[0]' [-Warray-bounds=] >> drivers/net/wireless/mediatek/mt76/mt7996/mcu.c:492:58: warning: >> array subscript <unknown> is outside array bounds of 'struct >> <anonymous>[0]' [-Warray-bounds=] >> drivers/net/wireless/mediatek/mt76/mt7996/mcu.c:469:61: warning: >> array subscript <unknown> is outside array bounds of 'struct >> <anonymous>[0]' [-Warray-bounds=] >> drivers/net/wireless/mediatek/mt76/mt7996/mcu.c:477:66: warning: >> array subscript <unknown> is outside array bounds of 'struct >> <anonymous>[0]' [-Warray-bounds=] >> drivers/net/wireless/mediatek/mt76/mt7996/mcu.c:479:66: warning: >> array subscript <unknown> is outside array bounds of 'struct >> <anonymous>[0]' [-Warray-bounds=] >> >> This results in no differences in binary output, helps with the ongoing >> efforts to globally enable -Warray-bounds. >> >> Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org> > > *thread ping* > > Can wireless folks please pick this patch up? Ok, I assigned this to me on patchwork now. Felix, please let me know if you prefer to take this to your tree instead.
"Gustavo A. R. Silva" <gustavoars@kernel.org> wrote: > Transform zero-length arrays `adm_stat` and `msdu_cnt` into proper > flexible-array members in anonymous union in `struct > mt7996_mcu_all_sta_info_event` via the DECLARE_FLEX_ARRAY() > helper; and fix multiple -Warray-bounds warnings: > > drivers/net/wireless/mediatek/mt76/mt7996/mcu.c:483:61: warning: array subscript <unknown> is outside array bounds of 'struct <anonymous>[0]' [-Warray-bounds=] > drivers/net/wireless/mediatek/mt76/mt7996/mcu.c:490:58: warning: array subscript <unknown> is outside array bounds of 'struct <anonymous>[0]' [-Warray-bounds=] > drivers/net/wireless/mediatek/mt76/mt7996/mcu.c:492:58: warning: array subscript <unknown> is outside array bounds of 'struct <anonymous>[0]' [-Warray-bounds=] > drivers/net/wireless/mediatek/mt76/mt7996/mcu.c:469:61: warning: array subscript <unknown> is outside array bounds of 'struct <anonymous>[0]' [-Warray-bounds=] > drivers/net/wireless/mediatek/mt76/mt7996/mcu.c:477:66: warning: array subscript <unknown> is outside array bounds of 'struct <anonymous>[0]' [-Warray-bounds=] > drivers/net/wireless/mediatek/mt76/mt7996/mcu.c:479:66: warning: array subscript <unknown> is outside array bounds of 'struct <anonymous>[0]' [-Warray-bounds=] > > This results in no differences in binary output, helps with the ongoing > efforts to globally enable -Warray-bounds. > > Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org> > Reviewed-by: Kees Cook <keescook@chromium.org> Fails to apply, please rebase on top of wireless-next. Recorded preimage for 'drivers/net/wireless/mediatek/mt76/mt7996/mcu.h' error: Failed to merge in the changes. hint: Use 'git am --show-current-patch=diff' to see the failed patch Applying: wifi: mt76: mt7996: Use DECLARE_FLEX_ARRAY() and fix -Warray-bounds warnings Using index info to reconstruct a base tree... M drivers/net/wireless/mediatek/mt76/mt7996/mcu.h Falling back to patching base and 3-way merge... Auto-merging drivers/net/wireless/mediatek/mt76/mt7996/mcu.h CONFLICT (content): Merge conflict in drivers/net/wireless/mediatek/mt76/mt7996/mcu.h Patch failed at 0001 wifi: mt76: mt7996: Use DECLARE_FLEX_ARRAY() and fix -Warray-bounds warnings Patch set to Changes Requested.
diff --git a/drivers/net/wireless/mediatek/mt76/mt7996/mcu.h b/drivers/net/wireless/mediatek/mt76/mt7996/mcu.h index a88f6af323da..9f516f796d63 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7996/mcu.h +++ b/drivers/net/wireless/mediatek/mt76/mt7996/mcu.h @@ -163,19 +163,19 @@ struct mt7996_mcu_all_sta_info_event { u8 rsv3[2]; union { - struct { + DECLARE_FLEX_ARRAY(struct { __le16 wlan_idx; u8 rsv[2]; __le32 tx_bytes[IEEE80211_NUM_ACS]; __le32 rx_bytes[IEEE80211_NUM_ACS]; - } adm_stat[0]; + }, adm_stat); - struct { + DECLARE_FLEX_ARRAY(struct { __le16 wlan_idx; u8 rsv[2]; __le32 tx_msdu_cnt; __le32 rx_msdu_cnt; - } msdu_cnt[0]; + }, msdu_cnt); }; } __packed;