From: Simon Horman <horms@kernel.org>
To: omermetekaya0@gmail.com
Cc: Simon Horman <horms@kernel.org>,
linux-wireless@vger.kernel.org, johannes@sipsolutions.net,
kvalo@kernel.org, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org,
syzbot+adeb8550754921fece20@syzkaller.appspotmail.com,
syzbot+101224300649c3eb8af4@syzkaller.appspotmail.com,
syzbot+8141dcbd23a8f857798a@syzkaller.appspotmail.com,
syzbot+b0ae8f1abf7d891e0426@syzkaller.appspotmail.com,
syzbot+d6bbe0f5705cb8a5aa2b@syzkaller.appspotmail.com
Subject: Re: [PATCH v2] wifi: cfg80211: avoid holding rtnl_mutex across all cfg80211_leave() calls
Date: Sat, 5 Sep 2026 19:45:45 +0100 [thread overview]
Message-ID: <20260905184545.172168-1-horms@kernel.org> (raw)
In-Reply-To: <20260903151542.486376-2-omermetekaya0@gmail.com>
This is an AI-generated review of your patch. The human sending this
email has considered the AI review valid, or at least plausible.
Full review at: https://sashiko.dev/#/patchset/20260903151542.486376-2-omermetekaya0@gmail.com?part=1
---
wifi: cfg80211: avoid holding rtnl_mutex across all cfg80211_leave() calls
This commit changes reg_check_chans_work() to iterate over cfg80211_rdev_list
using RCU instead of holding rtnl_mutex for the entire loop. It acquires
rtnl_mutex on a per-device basis to prevent task hangs.
> diff --git a/net/wireless/reg.c b/net/wireless/reg.c
> index a8336baf85dc6..a2e0d1cf8317c 100644
> --- a/net/wireless/reg.c
> +++ b/net/wireless/reg.c
> @@ -2466,12 +2466,21 @@ static void reg_check_chans_work(struct work_struct *work)
> struct cfg80211_registered_device *rdev;
>
> pr_debug("Verifying active interfaces after reg change\n");
> - rtnl_lock();
> -
> - for_each_rdev(rdev)
> + /*
> + * Acquire rtnl per-device instead of holding it for the entire loop;
> + * cfg80211_leave() can be slow and starve other rtnl waiters otherwise.
> + * wiphy_unregister() holds rtnl across list_del_rcu() + synchronize_rcu(),
> + * so rdev cannot be freed while we hold rtnl_lock() below.
> + */
> + rcu_read_lock();
> + list_for_each_entry_rcu(rdev, &cfg80211_rdev_list, list) {
> + rcu_read_unlock();
[Severity: High]
Does dropping the RCU read lock here remove the lifetime protection of the
current rdev element while waiting for rtnl_lock()?
If a concurrent thread unregisters the device (for example, via
wiphy_unregister()), it could acquire rtnl_lock, remove the device with
list_del_rcu(), and call synchronize_rcu().
Because the RCU read lock was dropped by the work thread here,
synchronize_rcu() could complete and allow the unregister thread to free rdev
before this thread acquires the rtnl lock.
> + rtnl_lock();
> reg_leave_invalid_chans(&rdev->wiphy);
[Severity: High]
Can this regression lead to a use-after-free?
If rdev was freed during the race window while waiting for rtnl_lock(),
accessing rdev->wiphy here would read from freed memory.
> -
> - rtnl_unlock();
> + rtnl_unlock();
> + rcu_read_lock();
> + }
[Severity: High]
Will the list_for_each_entry_rcu() macro implicitly dereference
rdev->list.next to continue the iteration after the loop body finishes?
If rdev was freed while the lock was dropped, does this result in another
use-after-free when advancing to the next list element?
> + rcu_read_unlock();
> }
prev parent reply other threads:[~2026-09-05 18:45 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-03 11:13 [PATCH] wifi: cfg80211: avoid holding rtnl_mutex across all cfg80211_leave() calls Ömer Mete Kaya
2026-09-03 15:13 ` Ömer Mete Kaya
2026-09-03 15:13 ` [PATCH v2] " Ömer Mete Kaya
2026-09-05 18:45 ` Simon Horman [this message]
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=20260905184545.172168-1-horms@kernel.org \
--to=horms@kernel.org \
--cc=johannes@sipsolutions.net \
--cc=kvalo@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-wireless@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=omermetekaya0@gmail.com \
--cc=syzbot+101224300649c3eb8af4@syzkaller.appspotmail.com \
--cc=syzbot+8141dcbd23a8f857798a@syzkaller.appspotmail.com \
--cc=syzbot+adeb8550754921fece20@syzkaller.appspotmail.com \
--cc=syzbot+b0ae8f1abf7d891e0426@syzkaller.appspotmail.com \
--cc=syzbot+d6bbe0f5705cb8a5aa2b@syzkaller.appspotmail.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