Linux wireless drivers development
 help / color / mirror / Atom feed
* [PATCH wireless-next] wifi: mac80211: reject invalid VHT rate combinations in radiotap
@ 2026-12-02 22:23 Ahmet Zeren via B4 Relay
  2026-12-03 16:31 ` Luka Gejak
  0 siblings, 1 reply; 2+ messages in thread
From: Ahmet Zeren via B4 Relay @ 2026-12-02 22:23 UTC (permalink / raw)
  To: Johannes Berg; +Cc: linux-wireless, Luka Gejak, Ahmet Zeren

From: Ahmet Zeren <niko3x@proton.me>

ieee80211_parse_tx_radiotap() checks a radiotap VHT rate only against
the TX MCS map, which doesn't depend on the bandwidth. Some MCS, NSS and
bandwidth combinations are not valid in 802.11ac, e.g. MCS 9 with one
stream at 20 MHz, but they are still passed to the driver as the rate
of the injected frame.

Check the combination as well, so that such frames are handled like
other frames with an unsupported radiotap rate. The invalid combinations
are the ones minstrel_get_valid_vht_rates() excludes, plus MCS 9 with
three streams at 160 MHz.

Tested with mac80211_hwsim at 20, 40 and 80 MHz: frames with an invalid
combination are no longer sent at the requested rate (hwsim sent them at
6 Mbit/s), the others still are.

Reported-by: Luka Gejak <luka.gejak@linux.dev>
Closes: https://lore.kernel.org/linux-wireless/179610495595.388673.1196096326230618192.rtw88-v3-reply-1@linux.dev/
Signed-off-by: Ahmet Zeren <niko3x@proton.me>
---
Luka noticed this while reviewing rtw88 injection patches, which now
program the radiotap rate of injected frames as a fixed rate, and asked
for 160 MHz to be covered too:
https://lore.kernel.org/linux-wireless/179614018753.510251.8580890911440773532.rtw88-v3-patch-1-followup@linux.dev/

The list of invalid combinations also matches the VHT validity table in
Wireshark's radiotap dissector. A VHT field without a known bandwidth is
checked as 20 MHz, the width the parser already gives it. The hwsim test used a 7.3.4 mac80211
with this check added; 160 MHz could not be tested there, as hwsim's
only 160 MHz range needs DFS, which blocks injection.

AI tool use (Documentation/process/generated-content.rst): the patch was
written with help from Claude Code (Claude Opus 5.5). It was asked to
fix the issue Luka reported, check the invalid combinations against
minstrel and the 802.11ac tables, and test it with mac80211_hwsim. I
have reviewed and tested the change and take responsibility for it.
---
 net/mac80211/tx.c | 20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)

diff --git a/net/mac80211/tx.c b/net/mac80211/tx.c
index cb9ecac25a9..a4eb43d430a 100644
--- a/net/mac80211/tx.c
+++ b/net/mac80211/tx.c
@@ -2196,6 +2196,23 @@ ieee80211_vht_tx_rate_supported(const struct ieee80211_sta_vht_cap *vht_cap,
 	}
 }
 
+/*
+ * Some VHT MCS, NSS and bandwidth combinations are not valid, as Ndbps / Nes
+ * is not an integer for them, see also minstrel_get_valid_vht_rates()
+ */
+static bool ieee80211_vht_mcs_valid(u16 rate_flags, u8 mcs, u8 nss)
+{
+	if (rate_flags & IEEE80211_TX_RC_160_MHZ_WIDTH)
+		return !(mcs == 9 && nss == 3);
+	if (rate_flags & IEEE80211_TX_RC_80_MHZ_WIDTH)
+		return !(mcs == 6 && (nss == 3 || nss == 7)) &&
+		       !(mcs == 9 && nss == 6);
+	if (rate_flags & IEEE80211_TX_RC_40_MHZ_WIDTH)
+		return true;
+
+	return mcs != 9 || nss == 3 || nss == 6;
+}
+
 bool ieee80211_parse_tx_radiotap(struct sk_buff *skb,
 				 struct net_device *dev,
 				 const struct cfg80211_chan_def *chandef,
@@ -2403,7 +2420,8 @@ bool ieee80211_parse_tx_radiotap(struct sk_buff *skb,
 
 			if (sband &&
 			    ieee80211_vht_tx_rate_supported(&sband->vht_cap,
-							    vht_mcs, vht_nss))
+							    vht_mcs, vht_nss) &&
+			    ieee80211_vht_mcs_valid(rate_flags, vht_mcs, vht_nss))
 				ieee80211_rate_set_vht(info->control.rates,
 						       vht_mcs, vht_nss);
 		} else if (sband) {

---
base-commit: 59b2054f5e1d7f845a07df1504977a05a0c34e8a
change-id: 20261203-mac80211-vht-valid-74e0564bf89f

Best regards,
--  
Ahmet Zeren <niko3x@proton.me>



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

end of thread, other threads:[~2026-12-03 16:31 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-02 22:23 [PATCH wireless-next] wifi: mac80211: reject invalid VHT rate combinations in radiotap Ahmet Zeren via B4 Relay
2026-12-03 16:31 ` Luka Gejak

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