linux/net/mac80211
Wen Gong 61304336c6 wifi: mac80211: allow transmitting EAPOL frames with tainted key
Lower layer device driver stop/wake TX by calling ieee80211_stop_queue()/
ieee80211_wake_queue() while hw scan. Sometimes hw scan and PTK rekey are
running in parallel, when M4 sent from wpa_supplicant arrive while the TX
queue is stopped, then the M4 will pending send, and then new key install
from wpa_supplicant. After TX queue wake up by lower layer device driver,
the M4 will be dropped by below call stack.

When key install started, the current key flag is set KEY_FLAG_TAINTED in
ieee80211_pairwise_rekey(), and then mac80211 wait key install complete by
lower layer device driver. Meanwhile ieee80211_tx_h_select_key() will return
TX_DROP for the M4 in step 12 below, and then ieee80211_free_txskb() called
by ieee80211_tx_dequeue(), so the M4 will not send and free, then the rekey
process failed becaue AP not receive M4. Please see details in steps below.

There are a interval between KEY_FLAG_TAINTED set for current key flag and
install key complete by lower layer device driver, the KEY_FLAG_TAINTED is
set in this interval, all packet including M4 will be dropped in this
interval, the interval is step 8~13 as below.

issue steps:
      TX thread                 install key thread
1.   stop_queue                      -idle-
2.   sending M4                      -idle-
3.   M4 pending                      -idle-
4.     -idle-                  starting install key from wpa_supplicant
5.     -idle-                  =>ieee80211_key_replace()
6.     -idle-                  =>ieee80211_pairwise_rekey() and set
                                 currently key->flags |= KEY_FLAG_TAINTED
7.     -idle-                  =>ieee80211_key_enable_hw_accel()
8.     -idle-                  =>drv_set_key() and waiting key install
                                 complete from lower layer device driver
9.   wake_queue                     -waiting state-
10.  re-sending M4                  -waiting state-
11.  =>ieee80211_tx_h_select_key()  -waiting state-
12.  drop M4 by KEY_FLAG_TAINTED    -waiting state-
13.    -idle-                   install key complete with success/fail
                                  success: clear flag KEY_FLAG_TAINTED
                                  fail: start disconnect

Hence add check in step 11 above to allow the EAPOL send out in the
interval. If lower layer device driver use the old key/cipher to encrypt
the M4, then AP received/decrypt M4 correctly, after M4 send out, lower
layer device driver install the new key/cipher to hardware and return
success.

If lower layer device driver use new key/cipher to send the M4, then AP
will/should drop the M4, then it is same result with this issue, AP will/
should kick out station as well as this issue.

issue log:
kworker/u16:4-5238  [000]  6456.108926: stop_queue:           phy1 queue:0, reason:0
wpa_supplicant-961  [003]  6456.119737: rdev_tx_control_port: wiphy_name=phy1 name=wlan0 ifindex=6 dest=ARRAY[9e, 05, 31, 20, 9b, d0] proto=36488 unencrypted=0
wpa_supplicant-961  [003]  6456.119839: rdev_return_int_cookie: phy1, returned 0, cookie: 504
wpa_supplicant-961  [003]  6456.120287: rdev_add_key:         phy1, netdev:wlan0(6), key_index: 0, mode: 0, pairwise: true, mac addr: 9e:05:31:20:9b:d0
wpa_supplicant-961  [003]  6456.120453: drv_set_key:          phy1 vif:wlan0(2) sta:9e:05:31:20:9b:d0 cipher:0xfac04, flags=0x9, keyidx=0, hw_key_idx=0
kworker/u16:9-3829  [001]  6456.168240: wake_queue:           phy1 queue:0, reason:0
kworker/u16:9-3829  [001]  6456.168255: drv_wake_tx_queue:    phy1 vif:wlan0(2) sta:9e:05:31:20:9b:d0 ac:0 tid:7
kworker/u16:9-3829  [001]  6456.168305: cfg80211_control_port_tx_status: wdev(1), cookie: 504, ack: false
wpa_supplicant-961  [003]  6459.167982: drv_return_int:       phy1 - -110

issue call stack:
nl80211_frame_tx_status+0x230/0x340 [cfg80211]
cfg80211_control_port_tx_status+0x1c/0x28 [cfg80211]
ieee80211_report_used_skb+0x374/0x3e8 [mac80211]
ieee80211_free_txskb+0x24/0x40 [mac80211]
ieee80211_tx_dequeue+0x644/0x954 [mac80211]
ath10k_mac_tx_push_txq+0xac/0x238 [ath10k_core]
ath10k_mac_op_wake_tx_queue+0xac/0xe0 [ath10k_core]
drv_wake_tx_queue+0x80/0x168 [mac80211]
__ieee80211_wake_txqs+0xe8/0x1c8 [mac80211]
_ieee80211_wake_txqs+0xb4/0x120 [mac80211]
ieee80211_wake_txqs+0x48/0x80 [mac80211]
tasklet_action_common+0xa8/0x254
tasklet_action+0x2c/0x38
__do_softirq+0xdc/0x384

Signed-off-by: Wen Gong <quic_wgong@quicinc.com>
Link: https://lore.kernel.org/r/20230801064751.25803-1-quic_wgong@quicinc.com
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2023-09-25 09:32:01 +02:00
..
aead_api.c mac80211: Check crypto_aead_encrypt for errors 2021-03-16 21:20:41 +01:00
aead_api.h
aes_ccm.h
aes_cmac.c mac80211: aes_cmac: check crypto_shash_setkey() return value 2021-04-19 12:01:40 +02:00
aes_cmac.h
aes_gcm.h
aes_gmac.c mac80211: Check crypto_aead_encrypt for errors 2021-03-16 21:20:41 +01:00
aes_gmac.h
agg-rx.c wifi: mac80211: remove support for AddBA with fragmentation 2022-10-07 15:24:31 +02:00
agg-tx.c wifi: mac80211: agg-tx: prevent start/stop race 2023-06-19 13:12:43 +02:00
airtime.c wifi: mac8021: fix possible oob access in ieee80211_get_rate_duration 2022-11-25 12:45:53 +01:00
cfg.c wifi: mac80211: work around Cisco AP 9115 VHT MPDU length 2023-09-25 08:41:27 +02:00
chan.c wifi: mac80211: add consistency check for compat chandef 2023-06-19 12:05:28 +02:00
debug.h wifi: mac80211: Add getter functions for vif MLD state 2023-06-14 12:20:08 +02:00
debugfs_key.c wifi: mac80211: reorg some iface data structs for MLD 2022-06-20 12:55:06 +02:00
debugfs_key.h mac80211: Support BIGTK configuration for Beacon protection 2020-02-24 10:35:57 +01:00
debugfs_netdev.c wifi: mac80211: Add debugfs entry to report dormant links 2023-06-19 12:05:19 +02:00
debugfs_netdev.h wifi: mac80211: add netdev per-link debugfs data and driver hook 2023-03-07 10:56:06 +01:00
debugfs_sta.c wifi: mac80211: add eht_capa debugfs field 2023-06-19 17:34:55 +02:00
debugfs_sta.h wifi: mac80211: add API to show the link STAs in debugfs 2022-10-07 15:23:41 +02:00
debugfs.c wifi: mac80211: remove return value check of debugfs_create_dir() 2023-04-20 11:46:07 +02:00
debugfs.h
driver-ops.c wifi: mac80211: add netdev per-link debugfs data and driver hook 2023-03-07 10:56:06 +01:00
driver-ops.h wifi: mac80211: stop warning after reconfig failures 2023-06-06 14:17:21 +02:00
drop.h mac80211: use the new drop reasons infrastructure 2023-04-20 20:20:49 -07:00
eht.c wifi: mac80211: add helpers to access sband iftype data 2023-06-14 11:57:29 +02:00
ethtool.c wifi: mac80211: read ethtool's sta_stats from sinfo 2022-08-26 09:56:54 +02:00
fils_aead.c wifi: mac80211: Do not include crypto/algapi.h 2023-08-24 08:42:36 +02:00
fils_aead.h
he.c wifi: mac80211: add helpers to access sband iftype data 2023-06-14 11:57:29 +02:00
ht.c wifi: mac80211: use wiphy work for SMPS 2023-06-07 19:53:22 +02:00
ibss.c wifi: mac80211: work around Cisco AP 9115 VHT MPDU length 2023-09-25 08:41:27 +02:00
ieee80211_i.h wifi: mac80211: work around Cisco AP 9115 VHT MPDU length 2023-09-25 08:41:27 +02:00
iface.c wifi: mac80211: always hold sdata lock in chanctx assign/unassign 2023-06-21 14:01:28 +02:00
Kconfig ath9k: fix build error with LEDS_CLASS=m 2021-01-28 09:29:34 +02:00
key.c wifi: mac80211: fix potential key leak 2023-09-25 08:40:07 +02:00
key.h wifi: mac80211: implement link switching 2022-09-06 10:17:20 +02:00
led.c leds: Change led_trigger_blink[_oneshot]() delay parameters to pass-by-value 2023-05-25 12:16:27 +01:00
led.h leds: Change led_trigger_blink[_oneshot]() delay parameters to pass-by-value 2023-05-25 12:16:27 +01:00
link.c wifi: mac80211: add set_active_links variant not locking sdata 2023-06-19 13:11:35 +02:00
main.c wifi: mac80211: mlme: move disconnects to wiphy work 2023-06-07 19:53:29 +02:00
Makefile wifi: mac80211: move link code to a new file 2022-09-03 17:02:25 +02:00
mesh_hwmp.c wifi: mac80211: use wiphy work for sdata->work 2023-06-07 19:53:18 +02:00
mesh_pathtbl.c wifi: mac80211: mesh fast xmit support 2023-03-22 13:31:18 +01:00
mesh_plink.c wifi: mac80211: work around Cisco AP 9115 VHT MPDU length 2023-09-25 08:41:27 +02:00
mesh_ps.c wifi: mac80211: consistently use u64 for BSS changes 2023-06-06 14:16:48 +02:00
mesh_sync.c mac80211: mesh: clean up rx_bcn_presp API 2021-09-23 16:26:33 +02:00
mesh.c wifi: mac80211: fix mesh id corruption on 32 bit systems 2023-09-13 10:14:44 +02:00
mesh.h wifi: mac80211: mesh: Remove unused function declaration mesh_ids_set_default() 2023-08-22 21:40:40 +02:00
michael.c
michael.h
mlme.c wifi: mac80211: work around Cisco AP 9115 VHT MPDU length 2023-09-25 08:41:27 +02:00
ocb.c wifi: mac80211: use wiphy work for sdata->work 2023-06-07 19:53:18 +02:00
offchannel.c wifi: mac80211: pass roc->sdata to drv_cancel_remain_on_channel() 2023-06-14 12:20:08 +02:00
pm.c mac80211: Prevent AP probing during suspend 2021-10-21 17:27:51 +02:00
rate.c wifi: mac80211: make ieee80211_check_rate_mask() link-aware 2022-07-15 11:43:21 +02:00
rate.h wifi: mac80211: make ieee80211_check_rate_mask() link-aware 2022-07-15 11:43:21 +02:00
rc80211_minstrel_ht_debugfs.c mac80211: minstrel_ht: show sampling rates in debugfs 2021-02-12 08:58:11 +01:00
rc80211_minstrel_ht.c mac80211: minstrel_ht: remove unused n_supported variable 2023-03-30 11:21:17 +02:00
rc80211_minstrel_ht.h wifi: mac80211: minstrel_ht: remove unused has_mrr member from struct minstrel_priv 2022-10-07 15:25:05 +02:00
rx.c wireless-next patches for v6.6 2023-08-25 18:35:09 -07:00
s1g.c wifi: mac80211: Set TWT Information Frame Disabled bit as 1 2022-11-02 09:50:40 +01:00
scan.c wifi: mac80211: use new inform_bss callback 2023-06-19 12:05:28 +02:00
spectmgmt.c wifi: mac80211: separate out connection downgrade flags 2022-07-15 11:43:14 +02:00
sta_info.c wifi: mac80211: avoid lockdep checking when removing deflink 2023-06-21 14:01:28 +02:00
sta_info.h wifi: mac80211: use bullet list for amsdu_mesh_control formats list 2023-03-24 10:56:23 +01:00
status.c wifi: mac80211: use wiphy work for sdata->work 2023-06-07 19:53:18 +02:00
tdls.c wifi: mac80211: Extend AID element addition for TDLS frames 2023-06-19 12:05:28 +02:00
tkip.c
tkip.h
trace_msg.h mac80211: tracing: Use the new __vstring() helper 2022-07-24 19:11:17 -04:00
trace.c
trace.h wifi: mac80211: Replace strlcpy with strscpy 2023-06-14 12:32:19 +02:00
tx.c wifi: mac80211: allow transmitting EAPOL frames with tainted key 2023-09-25 09:32:01 +02:00
util.c wifi: mac80211: fix CRC calculation for extended elems 2023-06-21 14:01:28 +02:00
vht.c wifi: mac80211: work around Cisco AP 9115 VHT MPDU length 2023-09-25 08:41:27 +02:00
wep.c
wep.h
wme.c wifi: mac80211: fix qos on mesh interfaces 2023-03-22 13:46:38 +01:00
wme.h wifi: mac80211: Drop support for TX push path 2022-10-10 11:06:14 +02:00
wpa.c wifi: mac80211: Do not include crypto/algapi.h 2023-08-24 08:42:36 +02:00
wpa.h wifi: mac80211: remove cipher scheme support 2022-06-10 15:35:53 +02:00