Skip to contentSkip to conversation

ath10k: fix RX of frames with broken FCS in monitor mode

PATCH In review Linus Lüssing 2 participants 4 messages Nov 15, 2019 – Nov 25, 2019

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 ath10k: fix RX of frames with broken FCS in monitor mode

From: Linus Lüssing <[email protected]>

So far, frames were forwarded regardless of the FCS correctness leading to userspace applications listening on the monitor mode interface to receive potentially broken frames, even with the "fcsfail" flag unset.

By default, with the "fcsfail" flag of a monitor mode interface unset, frames with FCS errors should be dropped. With this patch, the fcsfail flag is taken into account correctly.

Cc Simon Wunderlich <[email protected]>

---
This was tested on an Open Mesh A41 device, featuring a QCA4019. And with this firmware:

https://www.candelatech.com/downloads/ath10k-4019-10-4b/firmware-5-ct-full-community-12.bin-lede.011

But from looking at the code it seems that the vanilla ath10k has the same issue, therefore submitting it here.

Changelog v2:

* removed the spinlock as only a 32 bit statistics counter is incremented

Changelog RFC->v1:

* removed "ar->monitor" check
* added a debug counter

---

 drivers/net/wireless/ath/ath10k/core.h   | 1 +
 drivers/net/wireless/ath/ath10k/debug.c  | 2 ++
 drivers/net/wireless/ath/ath10k/htt_rx.c | 7 +++++++
 3 files changed, 10 insertions(+)
drivers/net/wireless/ath/ath10k/core.h +1 -0
index af68eb5d0776..d445482fa945 100644
@@ -1180,6 +1180,7 @@ struct ath10k {
 
 	struct {
 		/* protected by data_lock */
+		u32 rx_crc_err_drop;
 		u32 fw_crash_counter;
 		u32 fw_warm_reset_counter;
 		u32 fw_cold_reset_counter;
drivers/net/wireless/ath/ath10k/debug.c +2 -0
index bd2b5628f850..5e4cd2966e6f 100644
@@ -1094,6 +1094,7 @@ static const char ath10k_gstrings_stats[][ETH_GSTRING_LEN] = {
 	"d_rts_good",
 	"d_tx_power", /* in .5 dbM I think */
 	"d_rx_crc_err", /* fcs_bad */
+	"d_rx_crc_err_drop", /* frame with FCS error, dropped late in kernel */
 	"d_no_beacon",
 	"d_tx_mpdus_queued",
 	"d_tx_msdu_queued",
@@ -1193,6 +1194,7 @@ void ath10k_debug_get_et_stats(struct ieee80211_hw *hw,
 	data[i++] = pdev_stats->rts_good;
 	data[i++] = pdev_stats->chan_tx_power;
 	data[i++] = pdev_stats->fcs_bad;
+	data[i++] = ar->stats.rx_crc_err_drop;
 	data[i++] = pdev_stats->no_beacons;
 	data[i++] = pdev_stats->mpdu_enqued;
 	data[i++] = pdev_stats->msdu_enqued;
drivers/net/wireless/ath/ath10k/htt_rx.c +7 -0
index 9f0e7b4943ec..8139c9cea1d8 100644
@@ -1285,6 +1285,13 @@ static void ath10k_process_rx(struct ath10k *ar, struct sk_buff *skb)
 
 	status = IEEE80211_SKB_RXCB(skb);
 
+	if (!(ar->filter_flags & FIF_FCSFAIL) &&
+	    status->flag & RX_FLAG_FAILED_FCS_CRC) {
+		ar->stats.rx_crc_err_drop++;
+		dev_kfree_skb_any(skb);
+		return;
+	}
+
 	ath10k_dbg(ar, ATH10K_DBG_DATA,
 		   "rx skb %pK len %u peer %pM %s %s sn %u %s%s%s%s%s%s %srate_idx %u vht_nss %u freq %u band %u flag 0x%x fcs-err %i mic-err %i amsdu-more %i\n",
 		   skb,
Signature · 1 line
2.24.0.rc2
#1 lore raw
Quoted 6 lines · Linus Lüssing

From: Linus Lüssing <[email protected]>

So far, frames were forwarded regardless of the FCS correctness leading to userspace applications listening on the monitor mode interface to receive potentially broken frames, even with the "fcsfail" flag unset.

Quoted 6 lines

By default, with the "fcsfail" flag of a monitor mode interface unset, frames with FCS errors should be dropped. With this patch, the fcsfail flag is taken into account correctly.

Cc Simon Wunderlich <[email protected]>

ath10k patches go ath-next branch, not net-next. So to avoid confusion please don't mark ath10k patches as "net-next", please.

Quoted 5 lines

---
This was tested on an Open Mesh A41 device, featuring a QCA4019. And with this firmware:

https://www.candelatech.com/downloads/ath10k-4019-10-4b/firmware-5-ct-full-community-12.bin-lede.011

I'll add this testing information to the commit log. (No need to resend just because of commit log changes)

Quoted 2 lines

But from looking at the code it seems that the vanilla ath10k has the same issue, therefore submitting it here.

So this should work with the Qualcomm firmware as well, right?

Signature · 6 lines
Kalle Valo

_______________________________________________
ath10k mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/ath10k
#2 lore raw
In reply to Linus Lüssing
Quoted 8 lines · Linus Lüssing

So far, frames were forwarded regardless of the FCS correctness leading to userspace applications listening on the monitor mode interface to receive potentially broken frames, even with the "fcsfail" flag unset.

By default, with the "fcsfail" flag of a monitor mode interface unset, frames with FCS errors should be dropped. With this patch, the fcsfail flag is taken into account correctly.

Quoted 5 lines

Tested-on: QCA4019 firmware-5-ct-full-community-12.bin-lede.011

Patch applied to ath-next branch of ath.git, thanks.

ea0c3e2a4702 ath10k: fix RX of frames with broken FCS in monitor mode

Signature · 3 lines
https://patchwork.kernel.org/patch/11246045/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches
#3 lore raw
In reply to Linus Lüssing
Quoted 8 lines · Linus Lüssing

So far, frames were forwarded regardless of the FCS correctness leading to userspace applications listening on the monitor mode interface to receive potentially broken frames, even with the "fcsfail" flag unset.

By default, with the "fcsfail" flag of a monitor mode interface unset, frames with FCS errors should be dropped. With this patch, the fcsfail flag is taken into account correctly.

Quoted 5 lines

Tested-on: QCA4019 firmware-5-ct-full-community-12.bin-lede.011

Patch applied to ath-next branch of ath.git, thanks.

ea0c3e2a4702 ath10k: fix RX of frames with broken FCS in monitor mode

Signature · 9 lines
https://patchwork.kernel.org/patch/11246045/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches


_______________________________________________
ath10k mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/ath10k