wifi: cfg80211: fix CQM for non-range use
Subsystems (2)
PATCH 1/2 wifi: cfg80211: fix CQM for non-range use
From: Johannes Berg <[email protected]>
commit 7e7efdda6adb385fbdfd6f819d76bc68c923c394 upstream.
[note: this is commit 4a7e92551618f3737b305f62451353ee05662f57 reapplied; that commit had been reverted in 6.6.6 because it caused regressions, see
https://lore.kernel.org/stable/2023121450-habitual-transpose-68a1@gregkh/
for details]
My prior race fix here broke CQM when ranges aren't used, as the reporting worker now requires the cqm_config to be set in the wdev, but isn't set when there's no range configured.
Rather than continuing to special-case the range version, set the cqm_config always and configure accordingly, also tracking if range was used or not to be able to clear the configuration appropriately with the same API, which was actually not right if both were implemented by a driver for some reason, as is the case with mac80211 (though there the implementations are equivalent so it doesn't matter.)
Also, the original multiple-RSSI commit lost checking for the callback, so might have potentially crashed if a driver had neither implementation, and userspace tried to use it despite not being advertised as supported.
--- net/wireless/core.h | 1 + net/wireless/nl80211.c | 50 ++++++++++++++++++++++++++---------------- 2 files changed, 32 insertions(+), 19 deletions(-)
net/wireless/core.h +1 -0
@@ -299,6 +299,7 @@ struct cfg80211_cqm_config {u32 rssi_hyst;s32 last_rssi_event_value;enum nl80211_cqm_rssi_threshold_event last_rssi_event_type; +bool use_range_api;int n_rssi_thresholds; s32 rssi_thresholds[] __counted_by(n_rssi_thresholds); };
net/wireless/nl80211.c +31 -19
88 lines not on this page · raw message
Signature · 1 line
2.43.0
PATCH 2/2 wifi: nl80211: fix deadlock in nl80211_set_cqm_rssi (6.6.x)
Commit 008afb9f3d57 ("wifi: cfg80211: fix CQM for non-range use" backported to 6.6.x) causes nl80211_set_cqm_rssi not to release the wdev lock in some of the error paths.
Of course, the ensuing deadlock causes userland network managers to break pretty badly, and on typical systems this also causes lockups on on suspend, poweroff and reboot. See [1], [2], [3] for example reports.
The upstream commit 7e7efdda6adb ("wifi: cfg80211: fix CQM for non-range use"), committed in November 2023, is completely fine because there was another commit in August 2023 that removed the wdev lock:
see commit 076fc8775daf ("wifi: cfg80211: remove wdev mutex").
The reason things broke in 6.6.5 is that commit 4338058f6009 was applied without also applying 076fc8775daf.
Commit 076fc8775daf ("wifi: cfg80211: remove wdev mutex") is a rather large commit; adjusting the error handling (which is what this commit does) yields a much simpler patch and was tested to work properly.
Fix the deadlock by releasing the lock before returning.
[1] https://bugzilla.kernel.org/show_bug.cgi?id=218247
[2] https://bbs.archlinux.org/viewtopic.php?id=290976
[3] https://lore.kernel.org/all/[email protected]/
--- net/wireless/nl80211.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-)
net/wireless/nl80211.c +12 -6
@@ -12906,17 +12906,23 @@ static int nl80211_set_cqm_rssi(struct genl_info *info, lockdep_is_held(&wdev->mtx));/* if already disabled just succeed */ -if (!n_thresholds && !old) -return 0 ; +if (!n_thresholds && !old) { + err =0 ; + goto unlock; + }if (n_thresholds >1 ) {if (!wiphy_ext_feature_isset (&rdev->wiphy,NL80211_EXT_FEATURE_CQM_RSSI_LIST ) || - !rdev->ops->set_cqm_rssi_range_config) -return -EOPNOTSUPP ; + !rdev->ops->set_cqm_rssi_range_config) { + err = -EOPNOTSUPP ; + goto unlock; + } }else { -if (!rdev->ops->set_cqm_rssi_config) -return -EOPNOTSUPP ; +if (!rdev->ops->set_cqm_rssi_config) { + err = -EOPNOTSUPP ; + goto unlock; + } }if (n_thresholds) {
Signature · 1 line
2.43.0
Greg KH
maintainerRe: [PATCH 2/2] wifi: nl80211: fix deadlock in nl80211_set_cqm_rssi (6.6.x)
Quoted 33 lines · Léo Lam
Commit
008afb9f3d57("wifi: cfg80211: fix CQM for non-range use" backported to 6.6.x) causesnl80211_set_cqm_rssinot to release the wdev lock in some of the error paths.Of course, the ensuing deadlock causes userland network managers to break pretty badly, and on typical systems this also causes lockups on on suspend, poweroff and reboot. See [1], [2], [3] for example reports.
The upstream commit
7e7efdda6adb("wifi: cfg80211: fix CQM for non-range use"), committed in November 2023, is completely fine because there was another commit in August 2023 that removed the wdev lock:
see commit076fc8775daf("wifi: cfg80211: remove wdev mutex").The reason things broke in 6.6.5 is that commit
4338058f6009was applied without also applying076fc8775daf.Commit
076fc8775daf("wifi: cfg80211: remove wdev mutex") is a rather large commit; adjusting the error handling (which is what this commit does) yields a much simpler patch and was tested to work properly.Fix the deadlock by releasing the lock before returning.
[1] https://bugzilla.kernel.org/show_bug.cgi?id=218247
[2] https://bbs.archlinux.org/viewtopic.php?id=290976
[3] https://lore.kernel.org/all/[email protected]/Fixes 008afb9f3d57 ("wifi: cfg80211: fix CQM for non-range use")Tested-by Léo Lam <[email protected]>Tested-by Philip Müller <[email protected]>Cc Johannes Berg <[email protected]>Signed-off-by Léo Lam <[email protected]>
Quoted 3 lines
--- net/wireless/nl80211.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-)
Both now queued up, thanks.
greg k-h
Re: [PATCH 2/2] wifi: nl80211: fix deadlock in nl80211_set_cqm_rssi (6.6.x)
Quoted 38 lines · Greg KH
Quoted 33 lines · Léo Lam
Commit
008afb9f3d57("wifi: cfg80211: fix CQM for non-range use" backported to 6.6.x) causesnl80211_set_cqm_rssinot to release the wdev lock in some of the error paths.Of course, the ensuing deadlock causes userland network managers to break pretty badly, and on typical systems this also causes lockups on on suspend, poweroff and reboot. See [1], [2], [3] for example reports.
The upstream commit
7e7efdda6adb("wifi: cfg80211: fix CQM for non-range use"), committed in November 2023, is completely fine because there was another commit in August 2023 that removed the wdev lock:
see commit076fc8775daf("wifi: cfg80211: remove wdev mutex").The reason things broke in 6.6.5 is that commit
4338058f6009was applied without also applying076fc8775daf.Commit
076fc8775daf("wifi: cfg80211: remove wdev mutex") is a rather large commit; adjusting the error handling (which is what this commit does) yields a much simpler patch and was tested to work properly.Fix the deadlock by releasing the lock before returning.
[1] https://bugzilla.kernel.org/show_bug.cgi?id=218247
[2] https://bbs.archlinux.org/viewtopic.php?id=290976
[3] https://lore.kernel.org/all/[email protected]/Fixes 008afb9f3d57 ("wifi: cfg80211: fix CQM for non-range use")Tested-by Léo Lam <[email protected]>Tested-by Philip Müller <[email protected]>Cc Johannes Berg <[email protected]>Signed-off-by Léo Lam <[email protected]>Quoted 3 lines
--- net/wireless/nl80211.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-)
Quoted 3 lines
Both now queued up, thanks.
greg k-h
Hi Greg,
seems only for 6.1.x series. Still don't see it for 6.6.x ...
Signature · 1 line
Best, Philip