Linux wireless drivers development
 help / color / mirror / Atom feed
From: Johannes Berg <johannes@sipsolutions.net>
To: Devin Wittmayer <lucid_duck@justthetip.ca>,
	 linux-wireless@vger.kernel.org
Cc: Felix Fietkau <nbd@nbd.name>,
	Lorenzo Bianconi <lorenzo@kernel.org>,
	 linux-kernel@vger.kernel.org, stable@vger.kernel.org,
	Oscar Alfonso Diaz <oscar.alfonso.diaz@gmail.com>,
	fjhhz1997@gmail.com
Subject: Re: [PATCH v2 1/1] wifi: mac80211: fix monitor mode frame capture for real chanctx drivers
Date: Mon, 18 May 2026 08:42:54 +0200	[thread overview]
Message-ID: <70c49e598ffba2864c8168c7185c0abec76b59dd.camel@sipsolutions.net> (raw)
In-Reply-To: <20260518064025.96792-1-lucid_duck@justthetip.ca>

On Sun, 2026-05-17 at 23:40 -0700, Devin Wittmayer wrote:
> From: 傅继晗 <fjhhz1997@gmail.com>
> 
> Commit d594cc6f2c58 ("wifi: mac80211: restore non-chanctx injection
> behaviour") restored the monitor injection fallback for drivers using
> chanctx emulation but explicitly deferred the harder case of 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 and exactly one chanctx is
> in flight, fall back to that one. Otherwise refuse: picking
> arbitrarily across multiple chanctxs would inject onto an unrelated
> channel.
> 
> Reran the airgeddon evil-twin flow (hostapd AP + coexisting monitor
> VIF on the same phy + aireplay-ng deauth from the monitor) against
> this patch on mt7921e PCIe and mt7921u USB, across both 2.4 GHz and
> 5 GHz, and again on a Kali Linux VM with MT7921U USB-passthrough as
> the closest match to the original reporter's setup. None of those
> reproduced the hang reported against the earlier attempt at the same
> fix (<20251216111909.25076-2-johannes@sipsolutions.net>) or against
> v1 on lore in March 2026.
> 
> Cc: stable@vger.kernel.org # 6.9+
> Reported-by: Oscar Alfonso Diaz <oscar.alfonso.diaz@gmail.com>
> Tested-by: Devin Wittmayer <lucid_duck@justthetip.ca>
> Fixes: 0a44dfc07074 ("wifi: mac80211: simplify non-chanctx drivers")
> Link: https://github.com/morrownr/USB-WiFi/issues/682
> Signed-off-by: 傅继晗 <fjhhz1997@gmail.com>
> Signed-off-by: Devin Wittmayer <lucid_duck@justthetip.ca>
> ---
>  net/mac80211/tx.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/net/mac80211/tx.c b/net/mac80211/tx.c
> --- a/net/mac80211/tx.c
> +++ b/net/mac80211/tx.c
> @@ -2402,6 +2402,10 @@ netdev_tx_t ieee80211_monitor_start_xmit(struct sk_buff *skb,
>  		chandef = &chanctx_conf->def;
>  	else if (local->emulate_chanctx)
>  		chandef = &local->hw.conf.chandef;
> +	else if (list_is_singular(&local->chanctx_list))
> +		chandef = &list_first_entry(&local->chanctx_list,
> +					    struct ieee80211_chanctx,
> +					    list)->conf.def;


Quoting include/linux/rculist.h:

 * Where are list_empty_rcu() and list_first_entry_rcu()?
 *
 * They do not exist because they would lead to subtle race conditions:
 *
 * if (!list_empty_rcu(mylist)) {
 *      struct foo *bar = list_first_entry_rcu(mylist, struct foo, list_member);
 *      do_something(bar);
 * }
 *
 * The list might be non-empty when list_empty_rcu() checks it, but it
 * might have become empty by the time that list_first_entry_rcu() rereads
 * the ->next pointer, which would result in a SEGV.
 *
 * When not using RCU, it is OK for list_first_entry() to re-read that
 * pointer because both functions should be protected by some lock that
 * blocks writers.
 *
 * When using RCU, list_empty() uses READ_ONCE() to fetch the
 * RCU-protected ->next pointer and then compares it to the address of the
 * list head.  However, it neither dereferences this pointer nor provides
 * this pointer to its caller.  Thus, READ_ONCE() suffices (that is,
 * rcu_dereference() is not needed), which means that list_empty() can be
 * used anywhere you would want to use list_empty_rcu().  Just don't
 * expect anything useful to happen if you do a subsequent lockless
 * call to list_first_entry_rcu()!!!
 *
 * See list_first_or_null_rcu for an alternative.

johannes

  reply	other threads:[~2026-05-18  6:43 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-08 16:45 [PATCH] wifi: mac80211: fix monitor mode frame capture for real chanctx drivers 傅继晗
2026-03-09  6:53 ` Johannes Berg
2026-03-09 10:45   ` 傅继晗
2026-03-16 10:38     ` Johannes Berg
     [not found]       ` <CA+bbHrX+xby2_drzo0457raoz-kgQ6eTCCHU91pR5BkvzMiq_A@mail.gmail.com>
2026-03-19 11:40         ` Óscar Alfonso Díaz
2026-03-25  0:15           ` 傅继晗
2026-03-25 10:59             ` Óscar Alfonso Díaz
2026-03-26  1:37               ` [PATCH v2] wifi: mac80211: fix the issue of NULL pointer access when deleting the virtual interface 傅继晗
2026-03-26 12:16                 ` Óscar Alfonso Díaz
2026-03-29 21:55                   ` Óscar Alfonso Díaz
2026-04-02  0:06                     ` Óscar Alfonso Díaz
2026-04-21  8:50                       ` Óscar Alfonso Díaz
2026-04-24 12:08                         ` [PATCH] wifi: mac80211: restore monitor injection when coexisting with another VIF Brite
2026-04-24 12:17                           ` Greg KH
2026-04-24 13:55                           ` Johannes Berg
2026-04-24 14:17                             ` Óscar Alfonso Díaz
2026-04-24 17:22                             ` Brite
2026-04-25  0:34                             ` Brite
2026-04-25  1:47                           ` Lachlan Hodges
2026-04-25  2:43                             ` Brite
2026-04-26  9:25                               ` Óscar Alfonso Díaz
2026-05-18  6:38 ` [PATCH v2 0/1] wifi: mac80211: fix monitor mode frame capture for real chanctx drivers Devin Wittmayer
2026-05-18  6:40   ` [PATCH v2 1/1] " Devin Wittmayer
2026-05-18  6:42     ` Johannes Berg [this message]
2026-05-18 17:01 ` [PATCH v3 0/1] " Devin Wittmayer
2026-05-18 17:01   ` [PATCH v3] " Devin Wittmayer
2026-05-19  7:02     ` Johannes Berg
2026-05-19 23:56       ` Devin Wittmayer
2026-05-19 23:57   ` [PATCH v4 0/1] " Devin Wittmayer
2026-05-19 23:57     ` [PATCH v4] " Devin Wittmayer
2026-05-20  6:49       ` Óscar Alfonso Díaz
2026-05-20  7:42         ` Johannes Berg
2026-05-20  8:02           ` Óscar Alfonso Díaz
2026-05-20  8:58             ` Johannes Berg
2026-05-20  9:51               ` Óscar Alfonso Díaz
2026-05-20  9:53                 ` Johannes Berg
2026-05-20  9:55                   ` Óscar Alfonso Díaz
2026-06-02  8:29                     ` Óscar Alfonso Díaz
2026-06-03 11:54                       ` Óscar Alfonso Díaz
2026-06-03 12:09                         ` Johannes Berg
2026-06-03 12:10       ` Johannes Berg
2026-06-03 19:28     ` [PATCH v5 0/1] " Devin Wittmayer
2026-06-03 19:28       ` [PATCH v5 1/1] " Devin Wittmayer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=70c49e598ffba2864c8168c7185c0abec76b59dd.camel@sipsolutions.net \
    --to=johannes@sipsolutions.net \
    --cc=fjhhz1997@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-wireless@vger.kernel.org \
    --cc=lorenzo@kernel.org \
    --cc=lucid_duck@justthetip.ca \
    --cc=nbd@nbd.name \
    --cc=oscar.alfonso.diaz@gmail.com \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox