wifi: nl80211: read WMM reg rule under RCU

freq_reg_info() returns a pointer into the current regdomain,
so we need RTNL, cfg80211_mutex or RCU, but I want to remove
the RTNL, so just use RCU here.

Also document that this is required, we didn't say when the
function could be used at all.

Link: https://patch.msgid.link/20261006120655.c6fce71ad991.I07ae7ed37bc8ff6d75c87e19d77e4c5379a8e167@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
This commit is contained in:
Johannes Berg 2026-10-06 12:04:14 +02:00
parent 04655cc0d2
commit 17a3455f15
2 changed files with 5 additions and 2 deletions

View File

@ -8197,6 +8197,8 @@ void wiphy_apply_custom_regulatory(struct wiphy *wiphy,
* it wants to follow we respect that unless a country IE has been received
* and processed already.
*
* Must be called within an RCU read-side critical section.
*
* Return: A valid pointer, or, when an error occurs, for example if no rule
* can be found, the return value is encoded using ERR_PTR(). Use IS_ERR() to
* check and PTR_ERR() to obtain the numeric return value. The numeric return

View File

@ -1540,9 +1540,10 @@ static int nl80211_msg_put_channel(struct sk_buff *msg, struct wiphy *wiphy,
goto nla_put_failure;
if (large) {
const struct ieee80211_reg_rule *rule =
freq_reg_info(wiphy, MHZ_TO_KHZ(chan->center_freq));
const struct ieee80211_reg_rule *rule;
guard(rcu)();
rule = freq_reg_info(wiphy, MHZ_TO_KHZ(chan->center_freq));
if (!IS_ERR_OR_NULL(rule) && rule->has_wmm) {
if (nl80211_msg_put_wmm_rules(msg, rule))
goto nla_put_failure;