Skip to contentSkip to conversation

wifi: brcmfmac: cyw: Fix __counted_by to be LE variant

PATCH In review Kees Cook 3 participants 3 messages Jul 21, 2025 – Jul 23, 2025 Broadcom BRCM80211 IEEE802.11 wireless drivers

lore
Share & tools
lore

Kees Cook

author
#0 lore raw

PATCH 1/1 wifi: brcmfmac: cyw: Fix __counted_by to be LE variant

In brcmf_cyw_mgmt_tx() the "len" counter of the struct brcmf_mf_params_le::data flexible array is stored as little-endian via cpu_to_le16() so the __counted_by_le() variant must be used:

	struct brcmf_mf_params_le *mf_params;
	...
	mf_params_len = offsetof(struct brcmf_mf_params_le, data) +
			(len - DOT11_MGMT_HDR_LEN);
	mf_params = kzalloc(mf_params_len, GFP_KERNEL);
	...
        mf_params->len = cpu_to_le16(len - DOT11_MGMT_HDR_LEN);
Fixes 66f909308a7c ("wifi: brcmfmac: cyw: support external SAE authentication in station mode")

---
Cc: Johannes Berg <[email protected]>
Cc: Chung-Hsien Hsu <[email protected]>
Cc: Chi-hsien Lin <[email protected]>
Cc: James Prestwood <[email protected]>
Cc: Arend van Spriel <[email protected]>
Cc: "Gustavo A. R. Silva" <[email protected]>
Cc: Ting-Ying Li <[email protected]>
Cc: <[email protected]>
Cc: <[email protected]>
Cc: <[email protected]>
Cc: <[email protected]>

---
 .../net/wireless/broadcom/brcm80211/brcmfmac/cyw/fwil_types.h   | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/broadcom/brcm80211/brcmfmac/cyw/fwil_types.h +1 -1
index 08c69142495a..669564382e32 100644
@@ -80,7 +80,7 @@ struct brcmf_mf_params_le {
 	u8 da[ETH_ALEN];
 	u8 bssid[ETH_ALEN];
 	__le32 packet_id;
-	u8 data[] __counted_by(len);
+	u8 data[] __counted_by_le(len);
 };
 
 #endif /* CYW_FWIL_TYPES_H_ */
Signature · 1 line
2.34.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 12 lines · Kees Cook

In brcmf_cyw_mgmt_tx() the "len" counter of the struct brcmf_mf_params_le::data flexible array is stored as little-endian via cpu_to_le16() so the __counted_by_le() variant must be used:

	struct brcmf_mf_params_le *mf_params;
	...
	mf_params_len = offsetof(struct brcmf_mf_params_le, data) +
			(len - DOT11_MGMT_HDR_LEN);
	mf_params = kzalloc(mf_params_len, GFP_KERNEL);
	...
         mf_params->len = cpu_to_le16(len - DOT11_MGMT_HDR_LEN);
Quoted 2 lines
Fixes 66f909308a7c ("wifi: brcmfmac: cyw: support external SAE authentication in station mode")

Thanks!
-Gustavo

Quoted 29 lines

---
Cc: Johannes Berg <[email protected]>
Cc: Chung-Hsien Hsu <[email protected]>
Cc: Chi-hsien Lin <[email protected]>
Cc: James Prestwood <[email protected]>
Cc: Arend van Spriel <[email protected]>
Cc: "Gustavo A. R. Silva" <[email protected]>
Cc: Ting-Ying Li <[email protected]>
Cc: <[email protected]>
Cc: <[email protected]>
Cc: <[email protected]>
Cc: <[email protected]>

---
  .../net/wireless/broadcom/brcm80211/brcmfmac/cyw/fwil_types.h   | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/broadcom/brcm80211/brcmfmac/cyw/fwil_types.h +1 -1
index 08c69142495a..669564382e32 100644
@@ -80,7 +80,7 @@ struct brcmf_mf_params_le {
  	u8 da[ETH_ALEN];
  	u8 bssid[ETH_ALEN];
  	__le32 packet_id;
-	u8 data[] __counted_by(len);
+	u8 data[] __counted_by_le(len);
  };
 
  #endif /* CYW_FWIL_TYPES_H_ */
maintainer Acked-by on v1 1/1
#2 lore raw
In reply to Kees Cook
Quoted 12 lines · Kees Cook

In brcmf_cyw_mgmt_tx() the "len" counter of the struct brcmf_mf_params_le::data flexible array is stored as little-endian via cpu_to_le16() so the __counted_by_le() variant must be used:

	struct brcmf_mf_params_le *mf_params;
	...
	mf_params_len = offsetof(struct brcmf_mf_params_le, data) +
			(len - DOT11_MGMT_HDR_LEN);
	mf_params = kzalloc(mf_params_len, GFP_KERNEL);
	...
         mf_params->len = cpu_to_le16(len - DOT11_MGMT_HDR_LEN);
Quoted 1 line
Fixes 66f909308a7c ("wifi: brcmfmac: cyw: support external SAE authentication in station mode")

Thanks for fixing this.

Quoted 15 lines

---
Cc: Johannes Berg <[email protected]>
Cc: Chung-Hsien Hsu <[email protected]>
Cc: Chi-hsien Lin <[email protected]>
Cc: James Prestwood <[email protected]>
Cc: Arend van Spriel <[email protected]>
Cc: "Gustavo A. R. Silva" <[email protected]>
Cc: Ting-Ying Li <[email protected]>
Cc: <[email protected]>
Cc: <[email protected]>
Cc: <[email protected]>
Cc: <[email protected]>

---
  .../net/wireless/broadcom/brcm80211/brcmfmac/cyw/fwil_types.h   | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)