[PATCH wireless] wifi: mac80211: avoid u8 overflow in ieee80211_parse_tx_radiotap()
From: Enver Ikromov
Date: Thu Nov 26 2026 - 04:11:07 EST
In ieee80211_parse_tx_radiotap(), rate_retries is a u8 parsed from
IEEE80211_RADIOTAP_DATA_RETRIES (0..255). Computing the attempt count
via min_t(u8, rate_retries + 1, local->hw.max_rate_tries) truncates
rate_retries + 1 to u8 before the comparison, so a radiotap header
with DATA_RETRIES = 255 wraps 255 + 1 to 0 and sets
info->control.rates[0].count = 0 instead of clamping to
local->hw.max_rate_tries.
For injected frames with a valid rate (IEEE80211_TX_CTRL_RATE_INJECT),
ieee80211_tx_h_rate_ctrl() returns early and passes rates[0].count = 0
directly to the driver. Drivers that check rates[0].count silently
ignore the requested retry limit, while drivers that compute
rates[0].count - 1 (such as rt2x00, rtl8180, and rtl8187) underflow.
Use min_t(u16, ...) so rate_retries + 1 is compared without 8-bit
truncation and properly clamped to local->hw.max_rate_tries.
Fixes: dfdfc2beb0dd ("mac80211: Parse legacy and HT rate in injected frames")
Cc: stable@xxxxxxxxxxxxxxx
Signed-off-by: Enver Ikromov <owner@xxxxxxxxxxxxxx>
---
net/mac80211/tx.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/mac80211/tx.c b/net/mac80211/tx.c
index 77d03251f6..230b9d13e2 100644
--- a/net/mac80211/tx.c
+++ b/net/mac80211/tx.c
@@ -2426,7 +2426,7 @@ bool ieee80211_parse_tx_radiotap(struct sk_buff *skb,
info->control.flags &= ~IEEE80211_TX_CTRL_RATE_INJECT;
info->control.rates[0].flags = rate_flags;
- info->control.rates[0].count = min_t(u8, rate_retries + 1,
+ info->control.rates[0].count = min_t(u16, rate_retries + 1,
local->hw.max_rate_tries);
}
base-commit: 35c42b20ac87165c054c582380aa0ff0de8aeb4a
--
2.53.0