Skip to contentSkip to conversation

wifi: rtw88: validate RX rate to prevent out-of-bound

PATCH In review Ping-Ke Shih 2 participants 3 messages Mar 24 – Mar 30 Realtek wireless driver (rtw88)

lore
Share & tools
lore

Ping-Ke Shih

author maintainer
#0 lore raw

PATCH v2 1/1 wifi: rtw88: validate RX rate to prevent out-of-bound

The reported RX rate might be unexpected, causing kernel warns:

Rate marked as a VHT rate but data is invalid: MCS: 0, NSS: 0

  WARNING: net/mac80211/rx.c:5491 at ieee80211_rx_list+0x183/0x1020 [mac80211]

As the RX rate can be index of an array under certain conditions, validate it to prevent accessing array out-of-bound potentially.

Tested on HP Notebook P3S95EA#ACB (kernel 6.19.9-1-cachyos):

- No WARNING: net/mac80211/rx.c:5491 observed after patch.
- System remains fully stable through idle, load, Bluetooth A2DP usage, and multiple suspend/resume cycles.
- Zero H2C or LPS errors in dmesg.

---
v2:
- add Tested-by collected from v1.
- add unlikely().

---
 drivers/net/wireless/realtek/rtw88/rx.c | 8 ++++++++
 1 file changed, 8 insertions(+)
drivers/net/wireless/realtek/rtw88/rx.c +8 -0
index 8b0afaaffaa0..d9e11343d498 100644
@@ -295,6 +295,14 @@ void rtw_rx_query_rx_desc(struct rtw_dev *rtwdev, void *rx_desc8,
 
 	pkt_stat->tsf_low = le32_get_bits(rx_desc->w5, RTW_RX_DESC_W5_TSFL);
 
+	if (unlikely(pkt_stat->rate >= DESC_RATE_MAX)) {
+		rtw_dbg(rtwdev, RTW_DBG_UNEXP,
+			"unexpected RX rate=0x%x\n", pkt_stat->rate);
+
+		pkt_stat->rate = DESC_RATE1M;
+		pkt_stat->bw = RTW_CHANNEL_WIDTH_20;
+	}
+
 	/* drv_info_sz is in unit of 8-bytes */
 	pkt_stat->drv_info_sz *= 8;
 

base-commit: eef6d4449e8a540fde792968a26d8aa514af8089

Signature · 1 line
2.25.1
Tested-by on v2 1/1
#1 lore raw
Quoted 7 lines · Ping-Ke Shih

The reported RX rate might be unexpected, causing kernel warns:

Rate marked as a VHT rate but data is invalid: MCS: 0, NSS: 0

  WARNING: net/mac80211/rx.c:5491 at ieee80211_rx_list+0x183/0x1020 [mac80211]

As the RX rate can be index of an array under certain conditions, validate it to prevent accessing array out-of-bound potentially.

Tested on HP Notebook P3S95EA#ACB (kernel 6.19.9-1-cachyos):

- No WARNING: net/mac80211/rx.c:5491 observed after the v2 patch.
The unexpected NSS: 0, MCS: 0 VHT rate warnings are successfully mitigated.
- The system remains fully stable through prolonged idle periods,
high network load, active Bluetooth A2DP usage, and multiple deep suspend/resume cycles.
- Zero h2c timeouts or firmware lps state errors observed in dmesg.

The v2 patch (with the added unlikely() hint) functions flawlessly.

author maintainer
#2 lore raw
In reply to Ping-Ke Shih
Quoted 15 lines · Ping-Ke Shih

The reported RX rate might be unexpected, causing kernel warns:

Rate marked as a VHT rate but data is invalid: MCS: 0, NSS: 0

  WARNING: net/mac80211/rx.c:5491 at ieee80211_rx_list+0x183/0x1020 [mac80211]

As the RX rate can be index of an array under certain conditions, validate it to prevent accessing array out-of-bound potentially.

Tested on HP Notebook P3S95EA#ACB (kernel 6.19.9-1-cachyos):

- No WARNING: net/mac80211/rx.c:5491 observed after patch.
- System remains fully stable through idle, load, Bluetooth A2DP usage, and multiple suspend/resume cycles.
- Zero H2C or LPS errors in dmesg.

Quoted 5 lines

1 patch(es) applied to rtw-next branch of rtw.git, thanks.

bf14367719fa wifi: rtw88: validate RX rate to prevent out-of-bound

---
https://github.com/pkshih/rtw.git