linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] wifi: brcmfmac: cyw: Fix __counted_by to be LE variant
@ 2025-07-21 18:18 Kees Cook
  2025-07-21 19:03 ` Gustavo A. R. Silva
  2025-07-23  9:41 ` Arend van Spriel
  0 siblings, 2 replies; 3+ messages in thread
From: Kees Cook @ 2025-07-21 18:18 UTC (permalink / raw)
  To: Johannes Berg
  Cc: Kees Cook, Chung-Hsien Hsu, Chi-hsien Lin, James Prestwood,
	Arend van Spriel, Gustavo A. R. Silva, Ting-Ying Li,
	linux-wireless, brcm80211, brcm80211-dev-list.pdl,
	linux-hardening, linux-kernel

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")
Signed-off-by: Kees Cook <kees@kernel.org>
---
Cc: Johannes Berg <johannes.berg@intel.com>
Cc: Chung-Hsien Hsu <chung-hsien.hsu@infineon.com>
Cc: Chi-hsien Lin <chi-hsien.lin@infineon.com>
Cc: James Prestwood <prestwoj@gmail.com>
Cc: Arend van Spriel <arend.vanspriel@broadcom.com>
Cc: "Gustavo A. R. Silva" <gustavoars@kernel.org>
Cc: Ting-Ying Li <tingying.li@cypress.com>
Cc: <linux-wireless@vger.kernel.org>
Cc: <brcm80211@lists.linux.dev>
Cc: <brcm80211-dev-list.pdl@broadcom.com>
Cc: <linux-hardening@vger.kernel.org>
---
 .../net/wireless/broadcom/brcm80211/brcmfmac/cyw/fwil_types.h   | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cyw/fwil_types.h b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cyw/fwil_types.h
index 08c69142495a..669564382e32 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cyw/fwil_types.h
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cyw/fwil_types.h
@@ -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_ */
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] wifi: brcmfmac: cyw: Fix __counted_by to be LE variant
  2025-07-21 18:18 [PATCH] wifi: brcmfmac: cyw: Fix __counted_by to be LE variant Kees Cook
@ 2025-07-21 19:03 ` Gustavo A. R. Silva
  2025-07-23  9:41 ` Arend van Spriel
  1 sibling, 0 replies; 3+ messages in thread
From: Gustavo A. R. Silva @ 2025-07-21 19:03 UTC (permalink / raw)
  To: Kees Cook, Johannes Berg
  Cc: Chung-Hsien Hsu, Chi-hsien Lin, James Prestwood, Arend van Spriel,
	Gustavo A. R. Silva, Ting-Ying Li, linux-wireless, brcm80211,
	brcm80211-dev-list.pdl, linux-hardening, linux-kernel



On 21/07/25 12:18, Kees Cook wrote:
> 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")
> Signed-off-by: Kees Cook <kees@kernel.org>

Reviewed-by: Gustavo A. R. Silva <gustavoars@kernel.org>

Thanks!
-Gustavo

> ---
> Cc: Johannes Berg <johannes.berg@intel.com>
> Cc: Chung-Hsien Hsu <chung-hsien.hsu@infineon.com>
> Cc: Chi-hsien Lin <chi-hsien.lin@infineon.com>
> Cc: James Prestwood <prestwoj@gmail.com>
> Cc: Arend van Spriel <arend.vanspriel@broadcom.com>
> Cc: "Gustavo A. R. Silva" <gustavoars@kernel.org>
> Cc: Ting-Ying Li <tingying.li@cypress.com>
> Cc: <linux-wireless@vger.kernel.org>
> Cc: <brcm80211@lists.linux.dev>
> Cc: <brcm80211-dev-list.pdl@broadcom.com>
> Cc: <linux-hardening@vger.kernel.org>
> ---
>   .../net/wireless/broadcom/brcm80211/brcmfmac/cyw/fwil_types.h   | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cyw/fwil_types.h b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cyw/fwil_types.h
> index 08c69142495a..669564382e32 100644
> --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cyw/fwil_types.h
> +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cyw/fwil_types.h
> @@ -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_ */


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] wifi: brcmfmac: cyw: Fix __counted_by to be LE variant
  2025-07-21 18:18 [PATCH] wifi: brcmfmac: cyw: Fix __counted_by to be LE variant Kees Cook
  2025-07-21 19:03 ` Gustavo A. R. Silva
@ 2025-07-23  9:41 ` Arend van Spriel
  1 sibling, 0 replies; 3+ messages in thread
From: Arend van Spriel @ 2025-07-23  9:41 UTC (permalink / raw)
  To: Kees Cook, Johannes Berg
  Cc: Chung-Hsien Hsu, Chi-hsien Lin, James Prestwood,
	Gustavo A. R. Silva, Ting-Ying Li, linux-wireless, brcm80211,
	brcm80211-dev-list.pdl, linux-hardening, linux-kernel

On 7/21/2025 8:18 PM, Kees Cook wrote:
> 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")

Thanks for fixing this.

Acked-by: Arend van Spriel <arend.vanspriel@broadcom.com>> 
Signed-off-by: Kees Cook <kees@kernel.org>
> ---
> Cc: Johannes Berg <johannes.berg@intel.com>
> Cc: Chung-Hsien Hsu <chung-hsien.hsu@infineon.com>
> Cc: Chi-hsien Lin <chi-hsien.lin@infineon.com>
> Cc: James Prestwood <prestwoj@gmail.com>
> Cc: Arend van Spriel <arend.vanspriel@broadcom.com>
> Cc: "Gustavo A. R. Silva" <gustavoars@kernel.org>
> Cc: Ting-Ying Li <tingying.li@cypress.com>
> Cc: <linux-wireless@vger.kernel.org>
> Cc: <brcm80211@lists.linux.dev>
> Cc: <brcm80211-dev-list.pdl@broadcom.com>
> Cc: <linux-hardening@vger.kernel.org>
> ---
>   .../net/wireless/broadcom/brcm80211/brcmfmac/cyw/fwil_types.h   | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-07-23  9:41 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-21 18:18 [PATCH] wifi: brcmfmac: cyw: Fix __counted_by to be LE variant Kees Cook
2025-07-21 19:03 ` Gustavo A. R. Silva
2025-07-23  9:41 ` Arend van Spriel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).