From: greearb@candelatech.com
To: linux-wireless@vger.kernel.org
Cc: Ben Greear <greearb@candelatech.com>
Subject: [PATCH wireless-next 15/28] wifi: iwlwifi: mld: Fix use-after-free of bss_conf
Date: Wed, 11 Mar 2026 16:07:17 -0700 [thread overview]
Message-ID: <20260311230730.163348-16-greearb@candelatech.com> (raw)
In-Reply-To: <20260311230730.163348-1-greearb@candelatech.com>
From: Ben Greear <greearb@candelatech.com>
In certain failure paths, the driver is not fully configured, and
it fails to find the link object. We still need to remove pointers
to the bss_conf to keep from crashing shortly afterwards.
Search all indices for stale pointer if we cannot do the fast
lookup by ID.
Signed-off-by: Ben Greear <greearb@candelatech.com>
---
drivers/net/wireless/intel/iwlwifi/mld/link.c | 42 +++++++++++++++----
1 file changed, 34 insertions(+), 8 deletions(-)
diff --git a/drivers/net/wireless/intel/iwlwifi/mld/link.c b/drivers/net/wireless/intel/iwlwifi/mld/link.c
index b5430e8a73d6..1e4959ceb3db 100644
--- a/drivers/net/wireless/intel/iwlwifi/mld/link.c
+++ b/drivers/net/wireless/intel/iwlwifi/mld/link.c
@@ -504,23 +504,49 @@ void iwl_mld_remove_link(struct iwl_mld *mld,
struct iwl_mld_vif *mld_vif = iwl_mld_vif_from_mac80211(bss_conf->vif);
struct iwl_mld_link *link = iwl_mld_link_from_mac80211(bss_conf);
bool is_deflink = link == &mld_vif->deflink;
- u8 fw_id = link->fw_id;
+ u16 fw_id;
- if (WARN_ON(!link || link->active))
- return;
+ if (WARN_ON_ONCE(!link)) {
+ IWL_ERR(mld, "Remove nonexistent link, bss_conf: 0x%px link-id: %d\n",
+ bss_conf, bss_conf->link_id);
+ fw_id = 0xffff;
+ } else {
+ fw_id = link->fw_id;
+ }
+
+ /* Not cleaning it up seems worse than cleaning up an active link,
+ * so continue on even in warning case.
+ */
+ if (link && WARN_ON_ONCE(link->active))
+ IWL_ERR(mld, "Removing active link, id: %d\n",
+ bss_conf->link_id);
iwl_mld_rm_link_from_fw(mld, bss_conf);
/* Continue cleanup on failure */
- if (!is_deflink)
+ if (link && !is_deflink)
kfree_rcu(link, rcu_head);
+ rcu_read_lock();
RCU_INIT_POINTER(mld_vif->link[bss_conf->link_id], NULL);
- if (WARN_ON(fw_id >= mld->fw->ucode_capa.num_links))
- return;
-
- RCU_INIT_POINTER(mld->fw_id_to_bss_conf[fw_id], NULL);
+ if (fw_id >= mld->fw->ucode_capa.num_links) {
+ struct ieee80211_bss_conf *tmp_bss_conf;
+ int i;
+
+ /* Search for any existing back-pointer */
+ for (i = 0; i < ARRAY_SIZE(mld->fw_id_to_bss_conf); i++) {
+ tmp_bss_conf = rcu_dereference(mld->fw_id_to_bss_conf[i]);
+ if (tmp_bss_conf == bss_conf) {
+ IWL_ERR(mld, "WARNING: Found bss_conf in fw_id_to_bss_conf[%i], Nulling pointer.\n",
+ i);
+ RCU_INIT_POINTER(mld->fw_id_to_bss_conf[i], NULL);
+ }
+ }
+ } else {
+ RCU_INIT_POINTER(mld->fw_id_to_bss_conf[fw_id], NULL);
+ }
+ rcu_read_unlock();
}
void iwl_mld_handle_missed_beacon_notif(struct iwl_mld *mld,
--
2.42.0
next prev parent reply other threads:[~2026-03-11 23:08 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-11 23:07 [PATCH wireless-next 00/28] iwlwifi + mac80211 stability greearb
2026-03-11 23:07 ` [PATCH wireless-next 01/28] wifi: iwlwifi: mld: Check for NULL before lookup greearb
2026-03-11 23:07 ` [PATCH wireless-next 02/28] wifi: iwlwifi: mld: Fix un-set return value in error case greearb
2026-03-11 23:07 ` [PATCH wireless-next 03/28] wifi: iwlwifi: mld: Add check for null vif in stats callback greearb
2026-03-11 23:07 ` [PATCH wireless-next 04/28] wifi: mac80211: Check debugfs creation return values greearb
2026-03-11 23:07 ` [PATCH wireless-next 05/28] wifi: mac80211: do not fail taking sta to lower state greearb
2026-03-11 23:07 ` [PATCH wireless-next 06/28] wifi: mac80211: Mark sta as uploaded if single transition succeeds greearb
2026-03-11 23:07 ` [PATCH wireless-next 07/28] wifi: mac80211: Fix use-after-free of debugfs inodes greearb
2026-03-11 23:07 ` [PATCH wireless-next 08/28] wifi: mac80211: Debugfs safety checks greearb
2026-03-11 23:07 ` [PATCH wireless-next 09/28] wifi: mac80211: Use warn-on-once in drv_remove_chanctxt greearb
2026-03-11 23:07 ` [PATCH wireless-next 10/28] wifi: mac80211: Ensure sta debugfs is not double-freed greearb
2026-03-11 23:07 ` [PATCH wireless-next 11/28] wifi: iwlwifi: mld: Fix stale reference in fw_id_to_link_sta greearb
2026-03-11 23:07 ` [PATCH wireless-next 12/28] wifi: iwlwifi: mld: Improve logging in error cases greearb
2026-03-11 23:07 ` [PATCH wireless-next 13/28] wifi: iwlwifi: mld: Remove warning about BAID greearb
2026-03-11 23:07 ` [PATCH wireless-next 14/28] wifi: mac80211: Add dmesg log regarding warn-on in drv-stop greearb
2026-03-11 23:07 ` greearb [this message]
2026-03-11 23:07 ` [PATCH wireless-next 16/28] wifi: iwlwifi: mld: Check for null in iwl_mld_wait_sta_txqs_empty greearb
2026-03-11 23:07 ` [PATCH wireless-next 17/28] wifi: iwlwifi: mld: use warn-on-once in error path greearb
2026-03-11 23:07 ` [PATCH wireless-next 18/28] wifi: iwlwifi: mld: Use warn-on-once in emlsr exit logic greearb
2026-03-11 23:07 ` [PATCH wireless-next 19/28] wifi: iwlwifi: mld: Improve error message in rx path greearb
2026-03-11 23:07 ` [PATCH wireless-next 20/28] wifi: iwlwifi: mld: Improve logging message greearb
2026-03-11 23:07 ` [PATCH wireless-next 21/28] wifi: iwlwifi: mld: Protect from null mld_sta greearb
2026-03-11 23:07 ` [PATCH wireless-next 22/28] wifi: mac80211: Add force-cleanup call to driver greearb
2026-03-11 23:07 ` [PATCH wireless-next 23/28] wifi: iwlwifi: mld: Support force-cleanup op greearb
2026-03-11 23:07 ` [PATCH wireless-next 24/28] wifi: iwlwifi: mld: Fix NPE in flush logic greearb
2026-03-11 23:07 ` [PATCH wireless-next 25/28] wifi: iwlwifi: mld: Fix bad return address in tx code greearb
2026-03-11 23:07 ` [PATCH wireless-next 26/28] wifi: mac80211: Ensure link work-items are only initialized once greearb
2026-03-11 23:07 ` [PATCH wireless-next 27/28] wifi: iwlwifi: mld: Convert to WARN_ONCE in link removal path greearb
2026-03-11 23:07 ` [PATCH wireless-next 28/28] wifi: mac80211: Decrease WARN spam greearb
2026-03-12 14:25 ` [syzbot ci] Re: iwlwifi + mac80211 stability syzbot ci
2026-03-12 15:25 ` Ben Greear
2026-03-12 17:44 ` Johannes Berg
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=20260311230730.163348-16-greearb@candelatech.com \
--to=greearb@candelatech.com \
--cc=linux-wireless@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