From: Johannes Berg 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. Signed-off-by: Johannes Berg --- include/net/cfg80211.h | 2 ++ net/wireless/nl80211.c | 5 +++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h index 458c474d416d..120bc91a4e79 100644 --- a/include/net/cfg80211.h +++ b/include/net/cfg80211.h @@ -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 diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c index fd70027b312a..dd66a3146097 100644 --- a/net/wireless/nl80211.c +++ b/net/wireless/nl80211.c @@ -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; -- 2.55.0