Skip to contentSkip to conversation

wifi: rtw89: update PN state only from correctly decrypted frames

PATCH In review Zhao Li 2 participants 3 messages Nov 16 – Nov 17 Realtek wireless driver (rtw89)

lore
Share & tools
lore

Zhao Li

author
#0 lore raw

PATCH v2 1/1 wifi: rtw89: update PN state only from correctly decrypted frames

rtw89_core_skb_pn_valid() records the sequence and packet numbers of hardware-decrypted QoS data frames so that it can drop frames whose sequence number goes backwards while the PN advances. It runs before mac80211 discards frames with an ICV/MIC or FCS error and requires only hw_dec, so a frame that failed decryption still updates last_sn and last_pn. Such a frame need not come from the peer. One with an advanced sequence number and a PN between the recorded PN and the peer's next one makes the check drop the peer's following valid frames until their sequence numbers catch up.

Skip frames that rtw89_core_update_rx_status() does not report to mac80211 as decrypted, or reports with an FCS error.

Found by code review and not reproduced; compile-tested only.

AI assistance was used.

Fixes bda294ed0ed0 ("wifi: rtw89: Drop malformed AMPDU frames with abnormal PN")

---
Changes in v2:
- Keep the two existing conditions in place and append the three new ones (Ping-Ke).

v1: https://lore.kernel.org/r/[email protected]

 drivers/net/wireless/realtek/rtw89/core.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/wireless/realtek/rtw89/core.c +2 -1
index 58ee5efc3b5e..ef6bb1a43cd3 100644
@@ -3950,7 +3950,8 @@ static bool rtw89_core_skb_pn_valid(struct rtw89_dev *rtwdev,
 	if (!ieee80211_is_data_qos(hdr->frame_control))
 		return true;
 
-	if (!desc_info->hw_dec || !desc_info->addr1_match)
+	if (!desc_info->hw_dec || !desc_info->addr1_match ||
+	    desc_info->sw_dec || desc_info->icv_err || desc_info->crc32_err)
 		return true;
 
 	guard(rcu)();

base-commit: 5dbf2415ca9821a611d09308e3b29d2c37e7cd77

Signature · 1 line
2.56.1
maintainer Acked-by on v2 1/1
#1 lore raw
Quoted 13 lines · Zhao Li

rtw89_core_skb_pn_valid() records the sequence and packet numbers of hardware-decrypted QoS data frames so that it can drop frames whose sequence number goes backwards while the PN advances. It runs before mac80211 discards frames with an ICV/MIC or FCS error and requires only hw_dec, so a frame that failed decryption still updates last_sn and last_pn. Such a frame need not come from the peer. One with an advanced sequence number and a PN between the recorded PN and the peer's next one makes the check drop the peer's following valid frames until their sequence numbers catch up.

Skip frames that rtw89_core_update_rx_status() does not report to mac80211 as decrypted, or reports with an FCS error.

Quoted 7 lines

Found by code review and not reproduced; compile-tested only.

AI assistance was used.

Fixes bda294ed0ed0 ("wifi: rtw89: Drop malformed AMPDU frames with abnormal PN")
maintainer
#2 lore raw
In reply to Zhao Li
Quoted 13 lines · Zhao Li

rtw89_core_skb_pn_valid() records the sequence and packet numbers of hardware-decrypted QoS data frames so that it can drop frames whose sequence number goes backwards while the PN advances. It runs before mac80211 discards frames with an ICV/MIC or FCS error and requires only hw_dec, so a frame that failed decryption still updates last_sn and last_pn. Such a frame need not come from the peer. One with an advanced sequence number and a PN between the recorded PN and the peer's next one makes the check drop the peer's following valid frames until their sequence numbers catch up.

Skip frames that rtw89_core_update_rx_status() does not report to mac80211 as decrypted, or reports with an FCS error.

Quoted 8 lines

Found by code review and not reproduced; compile-tested only.

AI assistance was used.

Fixes bda294ed0ed0 ("wifi: rtw89: Drop malformed AMPDU frames with abnormal PN")

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

4de83750b9ac wifi: rtw89: update PN state only from correctly decrypted frames

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