Linux wireless drivers development
 help / color / mirror / Atom feed
* [PATCH] wifi: mwifiex: validate scan TLV result arrays
@ 2026-07-06  9:26 Pengpeng Hou
  2026-07-15 14:17 ` Francesco Dolcini
  0 siblings, 1 reply; 2+ messages in thread
From: Pengpeng Hou @ 2026-07-06  9:26 UTC (permalink / raw)
  To: Brian Norris
  Cc: Pengpeng Hou, Francesco Dolcini, Kees Cook, linux-wireless,
	linux-kernel

mwifiex_ret_802_11_scan() indexes TSF and channel-band TLV
arrays by the reported number of BSS result sets.

Ignore TSF or channel-band TLVs whose payload length cannot provide one
entry per reported BSS set.

Signed-off-by: Pengpeng Hou <pengpeng@iscas.ac.cn>
---
 drivers/net/wireless/marvell/mwifiex/scan.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/drivers/net/wireless/marvell/mwifiex/scan.c b/drivers/net/wireless/marvell/mwifiex/scan.c
index 97c0ec3b822e..7416756ada3b 100644
--- a/drivers/net/wireless/marvell/mwifiex/scan.c
+++ b/drivers/net/wireless/marvell/mwifiex/scan.c
@@ -2165,6 +2165,15 @@ int mwifiex_ret_802_11_scan(struct mwifiex_private *priv,
 					     (struct mwifiex_ie_types_data **)
 					     &chan_band_tlv);
 
+	if (tsf_tlv &&
+	    le16_to_cpu(tsf_tlv->header.len) / TSF_DATA_SIZE <
+	    scan_rsp->number_of_sets)
+		tsf_tlv = NULL;
+	if (chan_band_tlv &&
+	    le16_to_cpu(chan_band_tlv->header.len) /
+	    sizeof(*chan_band_tlv->chan_band_param) < scan_rsp->number_of_sets)
+		chan_band_tlv = NULL;
+
 #ifdef CONFIG_PM
 	if (priv->wdev.wiphy->wowlan_config)
 		nd_config = priv->wdev.wiphy->wowlan_config->nd_config;
-- 
2.43.0


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

* Re: [PATCH] wifi: mwifiex: validate scan TLV result arrays
  2026-07-06  9:26 [PATCH] wifi: mwifiex: validate scan TLV result arrays Pengpeng Hou
@ 2026-07-15 14:17 ` Francesco Dolcini
  0 siblings, 0 replies; 2+ messages in thread
From: Francesco Dolcini @ 2026-07-15 14:17 UTC (permalink / raw)
  To: Pengpeng Hou
  Cc: Brian Norris, Francesco Dolcini, Kees Cook, linux-wireless,
	linux-kernel

On Mon, Jul 06, 2026 at 05:26:54PM +0800, Pengpeng Hou wrote:
> mwifiex_ret_802_11_scan() indexes TSF and channel-band TLV
> arrays by the reported number of BSS result sets.
> 
> Ignore TSF or channel-band TLVs whose payload length cannot provide one
> entry per reported BSS set.
> 
> Signed-off-by: Pengpeng Hou <pengpeng@iscas.ac.cn>

Was this tested?

> ---
>  drivers/net/wireless/marvell/mwifiex/scan.c | 9 +++++++++
>  1 file changed, 9 insertions(+)
> 
> diff --git a/drivers/net/wireless/marvell/mwifiex/scan.c b/drivers/net/wireless/marvell/mwifiex/scan.c
> index 97c0ec3b822e..7416756ada3b 100644
> --- a/drivers/net/wireless/marvell/mwifiex/scan.c
> +++ b/drivers/net/wireless/marvell/mwifiex/scan.c
> @@ -2165,6 +2165,15 @@ int mwifiex_ret_802_11_scan(struct mwifiex_private *priv,
>  					     (struct mwifiex_ie_types_data **)
>  					     &chan_band_tlv);
>  
> +	if (tsf_tlv &&
> +	    le16_to_cpu(tsf_tlv->header.len) / TSF_DATA_SIZE <
> +	    scan_rsp->number_of_sets)
> +		tsf_tlv = NULL;
> +	if (chan_band_tlv &&
> +	    le16_to_cpu(chan_band_tlv->header.len) /
> +	    sizeof(*chan_band_tlv->chan_band_param) < scan_rsp->number_of_sets)
> +		chan_band_tlv = NULL;
> +

If something like that happen we should return an error, and return from
the function

a few lines before we do

	if (scan_rsp->number_of_sets > MWIFIEX_MAX_AP) {
		mwifiex_dbg(adapter, ERROR,
			    "SCAN_RESP: too many AP returned (%d)\n",
			    scan_rsp->number_of_sets);
		ret = -1;
		goto check_next_scan;
	}

why not doing something similar when this buffer from the fw is
corrupted?

Francesco


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

end of thread, other threads:[~2026-07-15 14:17 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-06  9:26 [PATCH] wifi: mwifiex: validate scan TLV result arrays Pengpeng Hou
2026-07-15 14:17 ` Francesco Dolcini

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox