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

From: Pengpeng <pengpeng@iscas.ac.cn>

mwifiex_ret_tx_rate_cfg() verifies that a TLV stays within the command
response, then parses RATE_SCOPE as struct mwifiex_rate_scope. The
type-specific parser also needs to prove that the declared TLV payload
covers the bitmap fields that it reads.

Check the RATE_SCOPE payload length before copying the legacy bitmaps,
and require the VHT bitmap area only for firmware API version 15 where
it is consumed.

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

diff --git a/drivers/net/wireless/marvell/mwifiex/sta_cmdresp.c b/drivers/net/wireless/marvell/mwifiex/sta_cmdresp.c
index 85512f526c5f..5b7399038d5d 100644
--- a/drivers/net/wireless/marvell/mwifiex/sta_cmdresp.c
+++ b/drivers/net/wireless/marvell/mwifiex/sta_cmdresp.c
@@ -260,6 +260,7 @@ static int mwifiex_ret_tx_rate_cfg(struct mwifiex_private *priv,
 	struct mwifiex_rate_scope *rate_scope;
 	struct mwifiex_ie_types_header *head;
 	u16 tlv, tlv_buf_len, tlv_buf_left;
+	size_t rate_scope_len;
 	u8 *tlv_buf;
 	u32 i;
 
@@ -276,6 +277,14 @@ static int mwifiex_ret_tx_rate_cfg(struct mwifiex_private *priv,
 
 		switch (tlv) {
 		case TLV_TYPE_RATE_SCOPE:
+			rate_scope_len = offsetof(struct mwifiex_rate_scope,
+						  vht_mcs_rate_bitmap) - sizeof(*head);
+			if (priv->adapter->fw_api_ver == MWIFIEX_FW_V15)
+				rate_scope_len = sizeof(*rate_scope) - sizeof(*head);
+
+			if (tlv_buf_len < rate_scope_len)
+				break;
+
 			rate_scope = (struct mwifiex_rate_scope *) tlv_buf;
 			priv->bitmap_rates[0] =
 				le16_to_cpu(rate_scope->hr_dsss_rate_bitmap);
-- 
2.43.0


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

end of thread, other threads:[~2026-07-15 14:01 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:13 [PATCH] wifi: mwifiex: validate rate scope TLV length Pengpeng Hou
2026-07-15 14:01 ` Francesco Dolcini

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