* [PATCH wireless v2] wifi: mac80211: check for a NULL link in the MLD station RX loop
@ 2026-11-16 19:37 Joas Antonio dos Santos via B4 Relay
2026-11-16 19:38 ` Johannes Berg
0 siblings, 1 reply; 3+ messages in thread
From: Joas Antonio dos Santos via B4 Relay @ 2026-11-16 19:37 UTC (permalink / raw)
To: Johannes Berg, Benjamin Berg, joasantonio108; +Cc: linux-wireless, linux-kernel
From: Joas Antonio dos Santos <joasantonio108@gmail.com>
Since commit 6d531b9af16e ("wifi: mac80211: rework RX packet handling"),
__ieee80211_rx_handle_packet() looks up the link of each MLD station
that matches addr2 and passes it straight to ieee80211_rx_valid_freq(),
which dereferences link->sdata and link->conf whenever status->freq is
set. The non-MLD loop and the interface loop below it check the link,
this one does not.
The link can be NULL there. ieee80211_vif_update_links() clears
sdata->link[link_id] for a removed link first, and only later, after
ieee80211_tear_down_links() (including its synchronize_rcu()) and
drv_change_vif_links(), calls ieee80211_sta_remove_link(), which takes
the link station out of the hash. RX runs under RCU only, so a data
frame from that link's address arriving in this window finds the link
station but a NULL link, and the kernel oopses in softirq context. A
link is removed this way for example when an associated AP announces
removal of one of its links (ieee80211_ml_reconf_work()), and the
frames only need a matching transmitter address, before any crypto.
Before the rework, ieee80211_rx_data_set_link() returned false for a
NULL link and the frame was skipped. Skip it again.
Fixes: 6d531b9af16e ("wifi: mac80211: rework RX packet handling")
Signed-off-by: Joas Antonio dos Santos <joasantonio108@gmail.com>
---
Found by LLM-assisted code review of the RX rework and confirmed by
reading the link removal path by hand. I have not reproduced the oops
at runtime.
v1 got no replies but is marked "Changes Requested" in patchwork, so I
am not sure what is expected. Please let me know if something else is
wanted here.
---
Changes in v2:
- Rebased on wireless/for-next (763b13f622e2), no code changes.
- Link to v1: https://lore.kernel.org/r/20261102-mac80211-rx-null-link-v1-1-3330b6b18c76@gmail.com
---
net/mac80211/rx.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/mac80211/rx.c b/net/mac80211/rx.c
index f8cfd04c0c6c..a1db6488e4bc 100644
--- a/net/mac80211/rx.c
+++ b/net/mac80211/rx.c
@@ -5505,7 +5505,7 @@ static void __ieee80211_rx_handle_packet(struct ieee80211_hw *hw,
sdata = sta->sdata;
link = rcu_dereference(sdata->link[link_sta->link_id]);
- if (!ieee80211_rx_valid_freq(status->freq, link))
+ if (!link || !ieee80211_rx_valid_freq(status->freq, link))
continue;
if (rx_data_pending) {
---
base-commit: 763b13f622e2758726e8e3ecaef819db8fa0430a
change-id: 20261102-mac80211-rx-null-link-6f2e0b50f6bb
Best regards,
--
Joas Antonio dos Santos <joasantonio108@gmail.com>
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH wireless v2] wifi: mac80211: check for a NULL link in the MLD station RX loop
2026-11-16 19:37 [PATCH wireless v2] wifi: mac80211: check for a NULL link in the MLD station RX loop Joas Antonio dos Santos via B4 Relay
@ 2026-11-16 19:38 ` Johannes Berg
2026-11-16 20:15 ` Joas Antonio
0 siblings, 1 reply; 3+ messages in thread
From: Johannes Berg @ 2026-11-16 19:38 UTC (permalink / raw)
To: joasantonio108, Benjamin Berg; +Cc: linux-wireless, linux-kernel
On Mon, 2026-11-16 at 19:37 +0000, Joas Antonio dos Santos via B4 Relay
wrote:
> From: Joas Antonio dos Santos <joasantonio108@gmail.com>
>
> Since commit 6d531b9af16e ("wifi: mac80211: rework RX packet handling"),
> __ieee80211_rx_handle_packet() looks up the link of each MLD station
> that matches addr2 and passes it straight to ieee80211_rx_valid_freq(),
> which dereferences link->sdata and link->conf whenever status->freq is
> set. The non-MLD loop and the interface loop below it check the link,
> this one does not.
>
> The link can be NULL there. ieee80211_vif_update_links() clears
> sdata->link[link_id] for a removed link first, and only later, after
> ieee80211_tear_down_links() (including its synchronize_rcu()) and
> drv_change_vif_links(), calls ieee80211_sta_remove_link(), which takes
> the link station out of the hash. RX runs under RCU only, so a data
> frame from that link's address arriving in this window finds the link
> station but a NULL link, and the kernel oopses in softirq context. A
> link is removed this way for example when an associated AP announces
> removal of one of its links (ieee80211_ml_reconf_work()), and the
> frames only need a matching transmitter address, before any crypto.
>
> Before the rework, ieee80211_rx_data_set_link() returned false for a
> NULL link and the frame was skipped. Skip it again.
>
> Fixes: 6d531b9af16e ("wifi: mac80211: rework RX packet handling")
> Signed-off-by: Joas Antonio dos Santos <joasantonio108@gmail.com>
> ---
> Found by LLM-assisted code review of the RX rework and confirmed by
> reading the link removal path by hand. I have not reproduced the oops
> at runtime.
>
> v1 got no replies but is marked "Changes Requested" in patchwork, so I
> am not sure what is expected. Please let me know if something else is
> wanted here.
>
I've said this pretty generally before - don't send me raw LLM output,
read it and make it make sense.
johannes
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH wireless v2] wifi: mac80211: check for a NULL link in the MLD station RX loop
2026-11-16 19:38 ` Johannes Berg
@ 2026-11-16 20:15 ` Joas Antonio
0 siblings, 0 replies; 3+ messages in thread
From: Joas Antonio @ 2026-11-16 20:15 UTC (permalink / raw)
To: Johannes Berg; +Cc: Benjamin Berg, linux-wireless, linux-kernel
My apologies; I sent this via an automation b4 tool, and the message
contained the raw output from the LLM.
A summary of the issue: 'ieee80211_vif_update_links()' sets
'sdata->link[link_id]' to 'NULL' before removing the STA from the link
hash table. During this interval, an incoming frame might still
encounter the STA for that link within the 'for_each_link_sta_info()'
loop in
'__ieee80211_rx_handle_packet()'. Subsequently,
'ieee80211_rx_valid_freq()' may end up dereferencing a null pointer.
I discovered this while reading the code, though I have not been able
to reproduce the issue. If you agree that this is indeed a problem, I
can submit a V3—or you may proceed without one. If I have overlooked
something, please feel free to discard the patch.
Em seg., 16 de nov. de 2026 às 16:38, Johannes Berg
<johannes@sipsolutions.net> escreveu:
>
> On Mon, 2026-11-16 at 19:37 +0000, Joas Antonio dos Santos via B4 Relay
> wrote:
> > From: Joas Antonio dos Santos <joasantonio108@gmail.com>
> >
> > Since commit 6d531b9af16e ("wifi: mac80211: rework RX packet handling"),
> > __ieee80211_rx_handle_packet() looks up the link of each MLD station
> > that matches addr2 and passes it straight to ieee80211_rx_valid_freq(),
> > which dereferences link->sdata and link->conf whenever status->freq is
> > set. The non-MLD loop and the interface loop below it check the link,
> > this one does not.
> >
> > The link can be NULL there. ieee80211_vif_update_links() clears
> > sdata->link[link_id] for a removed link first, and only later, after
> > ieee80211_tear_down_links() (including its synchronize_rcu()) and
> > drv_change_vif_links(), calls ieee80211_sta_remove_link(), which takes
> > the link station out of the hash. RX runs under RCU only, so a data
> > frame from that link's address arriving in this window finds the link
> > station but a NULL link, and the kernel oopses in softirq context. A
> > link is removed this way for example when an associated AP announces
> > removal of one of its links (ieee80211_ml_reconf_work()), and the
> > frames only need a matching transmitter address, before any crypto.
> >
> > Before the rework, ieee80211_rx_data_set_link() returned false for a
> > NULL link and the frame was skipped. Skip it again.
> >
> > Fixes: 6d531b9af16e ("wifi: mac80211: rework RX packet handling")
> > Signed-off-by: Joas Antonio dos Santos <joasantonio108@gmail.com>
> > ---
> > Found by LLM-assisted code review of the RX rework and confirmed by
> > reading the link removal path by hand. I have not reproduced the oops
> > at runtime.
> >
> > v1 got no replies but is marked "Changes Requested" in patchwork, so I
> > am not sure what is expected. Please let me know if something else is
> > wanted here.
> >
>
> I've said this pretty generally before - don't send me raw LLM output,
> read it and make it make sense.
>
> johannes
--
Joas Antonio dos Santos
Cyber Security Specialist and Ethical Hacker
joasantonio108@gmail.com
LinkedIn
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-11-16 20:15 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-16 19:37 [PATCH wireless v2] wifi: mac80211: check for a NULL link in the MLD station RX loop Joas Antonio dos Santos via B4 Relay
2026-11-16 19:38 ` Johannes Berg
2026-11-16 20:15 ` Joas Antonio
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®