ieee80211_do_stop() releases the channel of a monitor, but leaves its chanreq filled. When the monitor comes back up it has no channel, yet the RX path still filters on the old chanreq and drops all frames received on other frequencies. Only keep the chanreq filled while a channel is set on the monitor. Fixes: f92e0cf19ae0 ("wifi: mac80211: filter on monitor interfaces based on configured channel") Signed-off-by: Felix Fietkau --- v2: drop unnecessary condition for memset net/mac80211/cfg.c | 5 ++++- net/mac80211/iface.c | 2 ++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c index 9608c07bcea7..64e2bd0cf124 100644 --- a/net/mac80211/cfg.c +++ b/net/mac80211/cfg.c @@ -1165,8 +1165,11 @@ static int ieee80211_set_monitor_channel(struct wiphy *wiphy, ieee80211_link_release_channel(&sdata->deflink); ret = ieee80211_link_use_channel(&sdata->deflink, &chanreq, IEEE80211_CHANCTX_SHARED); - if (ret) + if (ret) { + memset(&sdata->vif.bss_conf.chanreq, 0, + sizeof(sdata->vif.bss_conf.chanreq)); return ret; + } done: local->monitor_chanreq = chanreq; return 0; diff --git a/net/mac80211/iface.c b/net/mac80211/iface.c index 63a371c79183..79739b142398 100644 --- a/net/mac80211/iface.c +++ b/net/mac80211/iface.c @@ -758,6 +758,8 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata, bool going_do break; ieee80211_link_release_channel(&sdata->deflink); + memset(&sdata->vif.bss_conf.chanreq, 0, + sizeof(sdata->vif.bss_conf.chanreq)); fallthrough; default: if (!going_down) -- 2.47.3 A monitor with its own channel keeps its channel context across suspend, which triggers the warning in __ieee80211_suspend() about remaining channel contexts. Release the channel on suspend and acquire it again on resume, like for the virtual monitor. Fixes: 9d40f7e32774 ("wifi: mac80211: add flag to opt out of virtual monitor support") Signed-off-by: Felix Fietkau --- net/mac80211/pm.c | 2 ++ net/mac80211/util.c | 26 ++++++++++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/net/mac80211/pm.c b/net/mac80211/pm.c index f63676c44853..de0d7b093520 100644 --- a/net/mac80211/pm.c +++ b/net/mac80211/pm.c @@ -151,7 +151,9 @@ int __ieee80211_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan, continue; switch (sdata->vif.type) { case NL80211_IFTYPE_AP_VLAN: + continue; case NL80211_IFTYPE_MONITOR: + ieee80211_link_release_channel(&sdata->deflink); continue; case NL80211_IFTYPE_STATION: ieee80211_mgd_quiesce(sdata); diff --git a/net/mac80211/util.c b/net/mac80211/util.c index 44feb80274c6..34402200baec 100644 --- a/net/mac80211/util.c +++ b/net/mac80211/util.c @@ -1748,6 +1748,30 @@ static void ieee80211_assign_chanctx(struct ieee80211_local *local, } } +static void ieee80211_reconfig_monitors(struct ieee80211_local *local) +{ + struct ieee80211_sub_if_data *sdata; + + lockdep_assert_wiphy(local->hw.wiphy); + + list_for_each_entry(sdata, &local->interfaces, list) { + struct ieee80211_chan_req chanreq = sdata->vif.bss_conf.chanreq; + + if (sdata->vif.type != NL80211_IFTYPE_MONITOR || + !chanreq.oper.chan || + rcu_access_pointer(sdata->deflink.conf->chanctx_conf)) + continue; + + if (!ieee80211_link_use_channel(&sdata->deflink, &chanreq, + IEEE80211_CHANCTX_SHARED)) + continue; + + sdata_info(sdata, "failed to restore monitor channel\n"); + memset(&sdata->vif.bss_conf.chanreq, 0, + sizeof(sdata->vif.bss_conf.chanreq)); + } +} + static void ieee80211_reconfig_stations(struct ieee80211_sub_if_data *sdata) { struct ieee80211_local *local = sdata->local; @@ -2382,6 +2406,8 @@ int ieee80211_reconfig(struct ieee80211_local *local) local->virt_monitors == local->open_count) ieee80211_add_virtual_monitor(local, NULL); + ieee80211_reconfig_monitors(local); + if (!suspended) return 0; -- 2.47.3 With NO_VIRTUAL_MONITOR, ieee80211_reconfig() adds running monitors to the driver on resume, but __ieee80211_suspend() does not remove them. Each resume without WoWLAN thus adds an interface that the driver already has. Remove these monitors on suspend, like all other interfaces that ieee80211_reconfig() adds. Fixes: 9d40f7e32774 ("wifi: mac80211: add flag to opt out of virtual monitor support") Signed-off-by: Felix Fietkau --- net/mac80211/pm.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/net/mac80211/pm.c b/net/mac80211/pm.c index de0d7b093520..24989ded2830 100644 --- a/net/mac80211/pm.c +++ b/net/mac80211/pm.c @@ -154,7 +154,9 @@ int __ieee80211_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan, continue; case NL80211_IFTYPE_MONITOR: ieee80211_link_release_channel(&sdata->deflink); - continue; + if (!ieee80211_hw_check(hw, NO_VIRTUAL_MONITOR)) + continue; + break; case NL80211_IFTYPE_STATION: ieee80211_mgd_quiesce(sdata); break; -- 2.47.3 With NO_VIRTUAL_MONITOR, ieee80211_set_monitor_channel() applies the channel to the interface of the request. While a monitor is running, nl80211_set_wiphy() can send a request without an interface, and sdata is then invalid. A request for another monitor that is down triggers the warning in check_sdata_in_driver(). Reject both requests, since the channel can only be applied to a running monitor. Fixes: 9d40f7e32774 ("wifi: mac80211: add flag to opt out of virtual monitor support") Signed-off-by: Felix Fietkau --- net/mac80211/cfg.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c index 64e2bd0cf124..62f8cf88f8f4 100644 --- a/net/mac80211/cfg.c +++ b/net/mac80211/cfg.c @@ -1155,6 +1155,10 @@ static int ieee80211_set_monitor_channel(struct wiphy *wiphy, sdata = wiphy_dereference(wiphy, local->monitor_sdata); if (!sdata) goto done; + } else if (!dev) { + return -EOPNOTSUPP; + } else if (!ieee80211_sdata_running(sdata)) { + return -ENETDOWN; } if (rcu_access_pointer(sdata->deflink.conf->chanctx_conf) && -- 2.47.3