Linux kernel -stable discussions
 help / color / mirror / Atom feed
* [PATCH] wifi: nl80211: fix deadlock in nl80211_set_cqm_rssi (6.6.x)
@ 2023-12-10 21:39 Léo Lam
  2023-12-11  6:47 ` Greg KH
                   ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: Léo Lam @ 2023-12-10 21:39 UTC (permalink / raw)
  To: stable; +Cc: Léo Lam

Commit 4a7e92551618f3737b305f62451353ee05662f57 ("wifi: cfg80211: fix
CQM for non-range use" on 6.6.x) causes nl80211_set_cqm_rssi not to
release the wdev lock in some situations.

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, 7e7efdda6adb385fbdfd6f819d76bc68c923c394
("wifi: cfg80211: fix CQM for non-range use"), does not trigger this
issue because the wdev lock does not exist there.

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/87sf4belmm.fsf@turtle.gmx.de/

Fixes: 4a7e92551618 ("wifi: cfg80211: fix CQM for non-range use")
Cc: stable@vger.kernel.org
Signed-off-by: Léo Lam <leo@leolam.fr>
---
 net/wireless/nl80211.c | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)

diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index 6a82dd876f27..0b0dfecedc50 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -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) {
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 10+ messages in thread
* Re: [PATCH] wifi: nl80211: fix deadlock in nl80211_set_cqm_rssi (6.6.x)
@ 2023-12-12 15:54 Arnab Bose
  0 siblings, 0 replies; 10+ messages in thread
From: Arnab Bose @ 2023-12-12 15:54 UTC (permalink / raw)
  To: leo; +Cc: gregkh, johannes.berg, stable

Tested-by: Arnab Bose <hirak99@gmail.com>

I have tested the patch and confirm that it fixes the regression.

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2023-12-12 16:07 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-12-10 21:39 [PATCH] wifi: nl80211: fix deadlock in nl80211_set_cqm_rssi (6.6.x) Léo Lam
2023-12-11  6:47 ` Greg KH
2023-12-11 12:45   ` Greg KH
2023-12-11 23:07     ` Léo Lam
2023-12-11 22:57   ` Léo Lam
2023-12-11 23:15     ` Philip Müller
2023-12-11 23:59       ` Léo Lam
2023-12-11 22:41 ` Philip Müller
2023-12-12 16:07 ` Arnab Bose
  -- strict thread matches above, loose matches on Subject: below --
2023-12-12 15:54 Arnab Bose

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox