]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
wifi: mac80211: fix monitor mode frame capture for real chanctx drivers
author傅继晗 <fjhhz1997@gmail.com>
Wed, 3 Jun 2026 19:28:54 +0000 (12:28 -0700)
committerJohannes Berg <johannes.berg@intel.com>
Thu, 4 Jun 2026 11:04:10 +0000 (13:04 +0200)
Commit d594cc6f2c58 ("wifi: mac80211: restore non-chanctx injection
behaviour") restored the monitor injection fallback for drivers using
chanctx emulation but explicitly deferred drivers that transitioned
to real chanctx ops. mt76 falls in that category and still drops
every injected frame when monitor coexists with another interface.

When the monitor has no chanctx of its own, fall back to the only
chanctx in flight if there is exactly one. Refuse if multiple are
present: picking arbitrarily would inject on an unrelated channel.
Emulated and real chanctx drivers both flow through this fallback,
since emulation always presents zero or one chanctx in
local->chanctx_list.

Reran the airgeddon evil-twin flow (hostapd AP + coexisting monitor
VIF on the same phy + aireplay-ng deauth from the monitor) on
mt7921e PCIe and mt7921u USB across 2.4 GHz and 5 GHz, and on a
Kali VM with MT7921U passthrough as the closest match to the
original reporter's setup. None reproduced the hang seen against
the earlier attempt at this fix
(<20251216111909.25076-2-johannes@sipsolutions.net>) or against v1
on lore in March.

Cc: <stable+noautosel@kernel.org> # causes some older drivers to crash
Reported-by: Oscar Alfonso Diaz <oscar.alfonso.diaz@gmail.com>
Closes: https://github.com/morrownr/USB-WiFi/issues/682
Tested-by: Devin Wittmayer <lucid_duck@justthetip.ca>
Fixes: 0a44dfc07074 ("wifi: mac80211: simplify non-chanctx drivers")
Signed-off-by: 傅继晗 <fjhhz1997@gmail.com>
Signed-off-by: Devin Wittmayer <lucid_duck@justthetip.ca>
Link: https://patch.msgid.link/5c2760bd9bc34616bf7892848872522254dd1ce5.1780513445.git.lucid_duck@justthetip.ca
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
net/mac80211/tx.c

index 933c86ca21c385e41d7d29dcfeb6d72f824aa024..cf336e92c072edd7726bb23ee1961e258b9f7abc 100644 (file)
@@ -2407,10 +2407,20 @@ netdev_tx_t ieee80211_monitor_start_xmit(struct sk_buff *skb,
                                rcu_dereference(tmp_sdata->vif.bss_conf.chanctx_conf);
        }
 
+       if (!chanctx_conf) {
+               struct ieee80211_chanctx *ctx;
+               bool first = true;
+
+               list_for_each_entry_rcu(ctx, &local->chanctx_list, list) {
+                       if (!first)
+                               goto fail_rcu;
+                       chanctx_conf = &ctx->conf;
+                       first = false;
+               }
+       }
+
        if (chanctx_conf)
                chandef = &chanctx_conf->def;
-       else if (local->emulate_chanctx)
-               chandef = &local->hw.conf.chandef;
        else
                goto fail_rcu;