From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f45.google.com (mail-wm1-f45.google.com [209.85.128.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5043D19C556 for ; Thu, 16 Jul 2026 00:18:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.45 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784161083; cv=none; b=sVNaRMyl4yIZdFx9C1KsXyR2WEHIYI7HhhRZkcf5vJeIVqu4ZmeaVp/Dr+7vVJz6R6Fk70uRG/ylaZXAkMqvgFEq6G43yk5mYWX0CDN4xW2Rn9hxjRlOeL2cRu5yENBKQ8hs1SLV2aLk1nFG45dHxCZs7YEGt5HXp2KTLtWk5o0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784161083; c=relaxed/simple; bh=g17dHcWS+jsSUKoyhr2RQjmSJNm6P0XrFpUqfAE87gM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=hjnOf51+w7uXJ7MPOcadMN22wa6LKXyBewu/5OiIQc86c330GJZ5h0CaNuj581VnaH5LmxzGiHKwxC7m2KklCgGG1TpeYXqsV9kf94bh3aPl8LTnhIlpImjRk1ZdbB4J8V484WpmGBYWRax9FRi6Cx/WHR5z9pKbRLOCRTooqFU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=d77tdbP3; arc=none smtp.client-ip=209.85.128.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="d77tdbP3" Received: by mail-wm1-f45.google.com with SMTP id 5b1f17b1804b1-493f25d47dcso14691725e9.1 for ; Wed, 15 Jul 2026 17:18:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1784161080; x=1784765880; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=Q2GsLfGNapFzMWQG14eqqxipuP9UERarjO5kgcBEMgo=; b=d77tdbP3hDwfcRIukQhLeQUjS3HY3SGvC8npHsXR1e+MWb3r/axB4FtYMS4qh2A66+ TzULNp7P+mJiMSXLwDQUK24is3jPfzN3qi+WIdl6ErRhBnptAzFU56p6sBfAofp+5/21 rh0ihjzUPnUnVduU7TBqUQivn5zDmeI8WK/tDkzmWJMTCSsN9s7+W10o5pVEFG/3Fem9 xFgSIeKK6Mbu7WYRENuxrsALSijHqZXsx/B5P06lf98Lm+tyWHADu+8JtfsvocLw3xNa DRIrGiw3il9y1PHafm0OO3SeYjRG7GqfUt99Acu8qccWH8cGXT5AWUXr1nQ0x74ju7ka NxFA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784161080; x=1784765880; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=Q2GsLfGNapFzMWQG14eqqxipuP9UERarjO5kgcBEMgo=; b=Ac5HBO5wXk+m6tKY0ftatuz72INH0k2m4n77Kg3a8wNYtvL8P4SILQ7ludTCOyh13c v4aehoPgHNiOuDhUpaVrvtt9iN9THLrVsYuVyMfuaUD3XVEwQcYrXFM0ih7No2WMLAvE d+/NucffQx/+k5DOduQxkVHbrDamG2VoggDWawESLp4sjtZSgIwOiNJ6DLE+yXa7luSH 3+kghEyASy7PeogV933ofe8b+b+N4NQHn/a3Z5KPcHbpzihxCCcB52YiijjI/oS0f/r1 0Gh2HtJioB4VSD3mwNX0nT22/QEjZOH3w54FBZUvNQ1b+QZAFAk77DpZ5ONL34o+BBhS Cgfg== X-Forwarded-Encrypted: i=1; AHgh+RpndBTFrYn7DmiJBdIH74tZCpPVejF4LDCQo1r7YX0dgq0fybATC+BgUl3vLprshlQNMVVINja1DtnUdKg=@vger.kernel.org X-Gm-Message-State: AOJu0YzT4f0MXWHo6j+ScV+vUcsacW89FC99KjiMIWcCBOWFBI/NArLv Hy0wFK5yUSxzuduyfahQE4i4lRb6naSd1k85+thAB8uO/z7KX6w7lrRf X-Gm-Gg: AfdE7cmX6u25f/GkWyk68Vw1HxZwjw+aecBVGUHwI/h/9kxAUrjwtHrZBsTPs8SzvFW VTeyaX4D+78SQP300RYrDcNulfij4MifXJfJpk5XmdInnnK8BCNfpUcwOaom9HXYUtkyEn2O2Zx S+hGBI9ter02rpsZTLp+boyhRRFIEmREDExJi97yW2PKEpm7i39yl8uJx2hMf+ttBi6diOgfXTH M0lOuARL8YAQRuK/dOUNCqbSlYN+c4zqx8hfw2tytY2VP4Ag/YoJeluXxPU5pX0FU8pmpoDQoSS 5vFs2skPR2PYjEwKbhMqjKZTRy4W4uf9l3fLlEIeWC7v2aO8Zf1zFct3SNem4jTxekmGBJ73B5z bkUCzRxGH6TXfunAGls0N1DHmQSr75EkbkBGgqdF/uURt4T4Fws/hIPAIyaKhPbOwrgUZ91eiAl A4j4Kqavu67o7d06W+NUU8m0ha6kKi9RzpAQ8O/AuTH6E3d2hgIfNkAaNFy/rkkiLHAg9PqqSKr 6m4nWxB X-Received: by 2002:a05:600c:2e15:b0:493:eb71:5cc6 with SMTP id 5b1f17b1804b1-493f88280bamr133149225e9.27.1784161080431; Wed, 15 Jul 2026 17:18:00 -0700 (PDT) Received: from localhost.localdomain ([151.251.240.229]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49541e9a7bbsm17503925e9.13.2026.07.15.17.17.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Jul 2026 17:18:00 -0700 (PDT) From: Georgi Valkov To: briannorris@chromium.org, kees@kernel.org Cc: francesco@dolcini.it, johannes.berg@intel.com, bhelgaas@google.com, error27@gmail.com, s.kerkmann@pengutronix.de, linux-wireless@vger.kernel.org, linux-kernel@vger.kernel.org, gvalkov@gmail.com Subject: [PATCH v3] wifi: mwifiex: replace one-element arrays with flexible array members Date: Thu, 16 Jul 2026 03:17:28 +0300 Message-ID: <20260716001728.57799-1-gvalkov@gmail.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <202607150932.F2A0836@keescook> References: <202607150932.F2A0836@keescook> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Replace deprecated one-element arrays with flexible array members. CONFIG_FORTIFY_SOURCE reports the following warning when one-element arrays are used as variable-length buffers: sta_cmd.c:1033 mwifiex_sta_prepare_cmd memcpy: detected field-spanning write (size 84) of single field "domain->triplet" at .../marvell/mwifiex/sta_cmd.c:1033 (size 3) Convert affected structs to use flexible array members. - Preserve existing wire layouts. - Use DECLARE_FLEX_ARRAY() for structs inside affected unions. Tested-on: WRT3200ACM, OpenWrt Signed-off-by: Georgi Valkov --- Thank you for your help! Please backport to 6.18 and 6.12, which are used by OpenWrt. v3: - resend, please ignore v2 (corrupted by mail client) v2: - restore the unions and use DECLARE_FLEX_ARRAY for the flexible arrays inside - restore use of sizeof(*member) instead of sizeof(struct) drivers/net/wireless/marvell/mwifiex/fw.h | 18 +++++++++--------- drivers/net/wireless/marvell/mwifiex/join.c | 8 ++++---- drivers/net/wireless/marvell/mwifiex/sta_cmd.c | 2 +- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/drivers/net/wireless/marvell/mwifiex/fw.h b/drivers/net/wireless/marvell/mwifiex/fw.h index e9e896606912..93561116959a 100644 --- a/drivers/net/wireless/marvell/mwifiex/fw.h +++ b/drivers/net/wireless/marvell/mwifiex/fw.h @@ -823,7 +823,7 @@ struct chan_band_param_set { struct mwifiex_ie_types_chan_band_list_param_set { struct mwifiex_ie_types_header header; - struct chan_band_param_set chan_band_param[1]; + struct chan_band_param_set chan_band_param[]; } __packed; struct mwifiex_ie_types_rates_param_set { @@ -886,7 +886,7 @@ struct mwifiex_ie_types_wildcard_ssid_params { #define TSF_DATA_SIZE 8 struct mwifiex_ie_types_tsf_timestamp { struct mwifiex_ie_types_header header; - u8 tsf_data[1]; + u8 tsf_data[]; } __packed; struct mwifiex_cf_param_set { @@ -903,8 +903,8 @@ struct mwifiex_ibss_param_set { struct mwifiex_ie_types_ss_param_set { struct mwifiex_ie_types_header header; union { - struct mwifiex_cf_param_set cf_param_set[1]; - struct mwifiex_ibss_param_set ibss_param_set[1]; + DECLARE_FLEX_ARRAY(struct mwifiex_cf_param_set, cf_param_set); + DECLARE_FLEX_ARRAY(struct mwifiex_ibss_param_set, ibss_param_set); } cf_ibss; } __packed; @@ -922,8 +922,8 @@ struct mwifiex_ds_param_set { struct mwifiex_ie_types_phy_param_set { struct mwifiex_ie_types_header header; union { - struct mwifiex_fh_param_set fh_param_set[1]; - struct mwifiex_ds_param_set ds_param_set[1]; + DECLARE_FLEX_ARRAY(struct mwifiex_fh_param_set, fh_param_set); + DECLARE_FLEX_ARRAY(struct mwifiex_ds_param_set, ds_param_set); } fh_ds; } __packed; @@ -1383,7 +1383,7 @@ struct host_cmd_ds_802_11_snmp_mib { __le16 query_type; __le16 oid; __le16 buf_size; - u8 value[1]; + u8 value[]; } __packed; struct mwifiex_rate_scope { @@ -1551,7 +1551,7 @@ struct mwifiex_scan_cmd_config { * TLV_TYPE_CHANLIST, mwifiex_ie_types_chan_list_param_set * WLAN_EID_SSID, mwifiex_ie_types_ssid_param_set */ - u8 tlv_buf[1]; /* SSID TLV(s) and ChanList TLVs are stored + u8 tlv_buf[]; /* SSID TLV(s) and ChanList TLVs are stored here */ } __packed; @@ -1683,7 +1683,7 @@ struct host_cmd_ds_802_11_bg_scan_query_rsp { struct mwifiex_ietypes_domain_param_set { struct mwifiex_ie_types_header header; u8 country_code[IEEE80211_COUNTRY_STRING_LEN]; - struct ieee80211_country_ie_triplet triplet[1]; + struct ieee80211_country_ie_triplet triplet[]; } __packed; struct host_cmd_ds_802_11d_domain_info { diff --git a/drivers/net/wireless/marvell/mwifiex/join.c b/drivers/net/wireless/marvell/mwifiex/join.c index 5a1a0287c1d5..a83f4d081fe2 100644 --- a/drivers/net/wireless/marvell/mwifiex/join.c +++ b/drivers/net/wireless/marvell/mwifiex/join.c @@ -421,15 +421,15 @@ int mwifiex_cmd_802_11_associate(struct mwifiex_private *priv, phy_tlv = (struct mwifiex_ie_types_phy_param_set *) pos; phy_tlv->header.type = cpu_to_le16(WLAN_EID_DS_PARAMS); - phy_tlv->header.len = cpu_to_le16(sizeof(phy_tlv->fh_ds.ds_param_set)); - memcpy(&phy_tlv->fh_ds.ds_param_set, + phy_tlv->header.len = cpu_to_le16(sizeof(*phy_tlv->fh_ds.ds_param_set)); + memcpy(phy_tlv->fh_ds.ds_param_set, &bss_desc->phy_param_set.ds_param_set.current_chan, - sizeof(phy_tlv->fh_ds.ds_param_set)); + sizeof(*phy_tlv->fh_ds.ds_param_set)); pos += sizeof(phy_tlv->header) + le16_to_cpu(phy_tlv->header.len); ss_tlv = (struct mwifiex_ie_types_ss_param_set *) pos; ss_tlv->header.type = cpu_to_le16(WLAN_EID_CF_PARAMS); - ss_tlv->header.len = cpu_to_le16(sizeof(ss_tlv->cf_ibss.cf_param_set)); + ss_tlv->header.len = cpu_to_le16(sizeof(*ss_tlv->cf_ibss.cf_param_set)); pos += sizeof(ss_tlv->header) + le16_to_cpu(ss_tlv->header.len); /* Get the common rates supported between the driver and the BSS Desc */ diff --git a/drivers/net/wireless/marvell/mwifiex/sta_cmd.c b/drivers/net/wireless/marvell/mwifiex/sta_cmd.c index 623ddde8c8e5..071f7cb305e1 100644 --- a/drivers/net/wireless/marvell/mwifiex/sta_cmd.c +++ b/drivers/net/wireless/marvell/mwifiex/sta_cmd.c @@ -108,7 +108,7 @@ static int mwifiex_cmd_802_11_snmp_mib(struct mwifiex_private *priv, "cmd: SNMP_CMD: cmd_oid = 0x%x\n", cmd_oid); cmd->command = cpu_to_le16(HostCmd_CMD_802_11_SNMP_MIB); cmd->size = cpu_to_le16(sizeof(struct host_cmd_ds_802_11_snmp_mib) - - 1 + S_DS_GEN); + + S_DS_GEN); snmp_mib->oid = cpu_to_le16((u16)cmd_oid); if (cmd_action == HostCmd_ACT_GEN_GET) { -- 2.55.0