Frames on a TXQ keep the AP_VLAN they were sent on in info->control.vif, which ieee80211_tx_dequeue() uses to find the sdata. When an AP_VLAN goes down, ieee80211_txq_remove_vlan() drops its frames from the AP's TXQ but not from the TXQs of stations. The frames of a station that was moved to another AP_VLAN (NL80211_CMD_SET_STATION with NL80211_ATTR_STA_VLAN) stay queued, for example while an aggregation session holds the TXQ, and are dequeued after the AP_VLAN's sub_if_data is freed: BUG: KASAN: use-after-free in ieee80211_tx_h_select_key (net/mac80211/tx.c:635) Read of size 8 at addr ff11000012725890 by task test/114 ieee80211_tx_h_select_key (net/mac80211/tx.c:635) ieee80211_tx_dequeue (net/mac80211/tx.c:4056) ieee80211_hwsim_wake_tx_queue (drivers/net/wireless/virtual/mac80211_hwsim_main.c:2318) ieee80211_agg_start_txq (net/mac80211/driver-ops.h:1384 net/mac80211/driver-ops.h:1391 net/mac80211/agg-tx.c:220) ieee80211_stop_tx_ba_cb (net/mac80211/agg-tx.c:942) ieee80211_sta_tear_down_BA_sessions (net/mac80211/ht.c:318) __sta_info_destroy_part1 (net/mac80211/sta_info.c:1348) sta_info_destroy_addr_bss (net/mac80211/sta_info.c:1622 net/mac80211/sta_info.c:1652) nl80211_del_station (net/wireless/rdev-ops.h:224 net/wireless/nl80211.c:10246) Drop the AP_VLAN's frames from the TXQs of the AP's stations as well. Fixes: 531682159092 ("mac80211: fix VLAN handling with TXQs") Assisted-by: Claude:claude-opus-5-5 Signed-off-by: Kyuwon Cho --- The issue was found by an LLM-guided test generator that we are developing as a research prototype. We reproduce it with a mac80211_hwsim radio in a user and network namespace: an AP with two AP_VLANs, an HT station added on the AP and moved to the first AP_VLAN, a burst of frames to it while its first aggregation session is being set up, then the station moved to the second AP_VLAN, the first one deleted and the station deleted. Without the patch, deleting the station triggers the report above; with it, nothing shows up. The reproducer is available on request. Found and tested on mainline 9437ee8b6cf6 (v7.4-rc4-571, with KASAN); the patch applies to wireless (35c42b20ac87) as is. net/mac80211/tx.c | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/net/mac80211/tx.c b/net/mac80211/tx.c index 6e70e2046d1a..cc3e6f425613 100644 --- a/net/mac80211/tx.c +++ b/net/mac80211/tx.c @@ -1541,24 +1541,30 @@ void ieee80211_txq_remove_vlan(struct ieee80211_local *local, struct ieee80211_sub_if_data *sdata) { struct fq *fq = &local->fq; - struct txq_info *txqi; - struct fq_tin *tin; struct ieee80211_sub_if_data *ap; + struct sta_info *sta; + int i; if (WARN_ON(sdata->vif.type != NL80211_IFTYPE_AP_VLAN)) return; ap = container_of(sdata->bss, struct ieee80211_sub_if_data, u.ap); - if (!ap->vif.txq) - return; - - txqi = to_txq_info(ap->vif.txq); - tin = &txqi->tin; - spin_lock_bh(&fq->lock); - fq_tin_filter(fq, tin, fq_vlan_filter_func, &sdata->vif, - fq_skb_free_func); + if (ap->vif.txq) + fq_tin_filter(fq, &to_txq_info(ap->vif.txq)->tin, + fq_vlan_filter_func, &sdata->vif, + fq_skb_free_func); + + list_for_each_entry(sta, &local->sta_list, list) { + if (sta->sdata->bss != sdata->bss) + continue; + for (i = 0; i < ARRAY_SIZE(sta->sta.txq); i++) + if (sta->sta.txq[i]) + fq_tin_filter(fq, &to_txq_info(sta->sta.txq[i])->tin, + fq_vlan_filter_func, &sdata->vif, + fq_skb_free_func); + } spin_unlock_bh(&fq->lock); } -- 2.43.0