From: Jose Ignacio Tornos Martinez <jtornosm@redhat.com>
To: nbd@nbd.name, lorenzo@kernel.org
Cc: ryder.lee@mediatek.com, shayne.chen@mediatek.com,
linux-wireless@vger.kernel.org,
Jose Ignacio Tornos Martinez <jtornosm@redhat.com>
Subject: [PATCH] wifi: mt76: mt7996: fix NULL pointer dereference in MLD AP recovery
Date: Mon, 27 Jul 2026 18:13:53 +0200 [thread overview]
Message-ID: <20260727161353.962426-1-jtornosm@redhat.com> (raw)
During full hardware reset, mt7996_mac_reset_vif_iter() frees non-default
VIF links and mt76_reset_device() clears all WCID entries, but
mvif->valid_links is not cleared.
When ieee80211_reconfig() runs after recovery, it calls
mt76_assign_vif_chanctx() which invokes mt7996_vif_link_add(). Since
valid_links still has the stale bits set, vif_link_add() takes the early
return path and skips WCID initialization (mlink->wcid assignment and
rcu_assign_pointer to the global WCID table). Later,
ieee80211_reconfig_ap_links() calls mt7996_link_info_changed() which
invokes mt7996_mcu_add_sta() with link->mt76.wcid == NULL, causing
a NULL pointer dereference:
BUG: kernel NULL pointer dereference, address: 00000000000000b8
RIP: 0010:mt7996_mcu_add_sta+0x2fd/0x630 [mt7996e]
Call Trace:
mt7996_link_info_changed+0x105/0x3f0 [mt7996e]
ieee80211_reconfig_ap_links+0x107/0x1d0 [mac80211]
ieee80211_reconfig+0x104a/0x1270 [mac80211]
ieee80211_restart_work+0xf2/0x140 [mac80211]
Fix this by clearing valid_links and resetting deflink_id in
mt7996_mac_reset_vif_iter() so that vif_link_add() takes the full
initialization path during recovery. Also clear the per-device MLD
index masks (mld_idx_mask, mld_remap_idx_mask) in mt7996_mac_full_reset()
to prevent index leaks across resets.
Signed-off-by: Jose Ignacio Tornos Martinez <jtornosm@redhat.com>
---
Note: I will have limited availability from mid-August to
mid-September. I will address any review feedback before then
or promptly after returning.
drivers/net/wireless/mediatek/mt76/mt7996/mac.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/drivers/net/wireless/mediatek/mt76/mt7996/mac.c b/drivers/net/wireless/mediatek/mt76/mt7996/mac.c
index 0eebc8182ca9..463bec7ad732 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7996/mac.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7996/mac.c
@@ -2384,6 +2384,9 @@ mt7996_mac_reset_vif_iter(void *data, u8 *mac, struct ieee80211_vif *vif)
kfree_rcu(mlink, rcu_head);
}
rcu_read_unlock();
+
+ mvif->valid_links = 0;
+ mvif->deflink_id = IEEE80211_LINK_UNSPECIFIED;
}
static void
@@ -2423,6 +2426,9 @@ mt7996_mac_full_reset(struct mt7996_dev *dev)
mt7996_mac_reset_vif_iter, dev);
mt76_reset_device(&dev->mt76);
+ dev->mld_idx_mask = 0;
+ dev->mld_remap_idx_mask = 0;
+
INIT_LIST_HEAD(&dev->sta_rc_list);
INIT_LIST_HEAD(&dev->twt_list);
--
2.54.0
next reply other threads:[~2026-07-27 16:14 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-27 16:13 Jose Ignacio Tornos Martinez [this message]
2026-09-17 10:00 ` [PATCH] wifi: mt76: mt7996: fix NULL pointer dereference in MLD AP recovery Jose Ignacio Tornos Martinez
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=20260727161353.962426-1-jtornosm@redhat.com \
--to=jtornosm@redhat.com \
--cc=linux-wireless@vger.kernel.org \
--cc=lorenzo@kernel.org \
--cc=nbd@nbd.name \
--cc=ryder.lee@mediatek.com \
--cc=shayne.chen@mediatek.com \
/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