From patchwork Tue Aug 27 07:49:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Berg X-Patchwork-Id: 823097 Received: from sipsolutions.net (s3.sipsolutions.net [168.119.38.16]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2D67315884D for ; Tue, 27 Aug 2024 07:49:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=168.119.38.16 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724744987; cv=none; b=Qa7GUszJ/36x4sDgYsRBKnmUrboD6+3xWnP+er3Dc2AT/Qxd08rG5FCyWNHJ8OD2Ajop0HO/GIQudcS7b4XkLChctrUwmkzFw2+LM9nGRGNVHRRbnwQrvSmgoF10N9geGTmH7eNB14Lu4gH3sH8JvfGnppzMvuVIE6HaVmS8eaI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724744987; c=relaxed/simple; bh=fXjPBZpkw76uHOpVzZbfPveywrHcaRNcOsLULPG1l7E=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=OsiwqQY1lqoUPodklSLsFMV1mL2ukJ29OTLco/zD5myIG1PM5AosREe+O/j9vZjnHYQPX1SDiyjTeoXs/J8K30kZvyuaPLODjom/mQRSqERz/biDBkodCU+7L3Mp99ChI2b0e3SR0yvrzaHf29JXzGhQHHkbwPEoSWyjiuJVc8U= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=sipsolutions.net; spf=pass smtp.mailfrom=sipsolutions.net; dkim=pass (2048-bit key) header.d=sipsolutions.net header.i=@sipsolutions.net header.b=WQxJFBLu; arc=none smtp.client-ip=168.119.38.16 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=sipsolutions.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=sipsolutions.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=sipsolutions.net header.i=@sipsolutions.net header.b="WQxJFBLu" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sipsolutions.net; s=mail; h=Content-Transfer-Encoding:MIME-Version: Message-ID:Date:Subject:Cc:To:From:Content-Type:Sender:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-To:Resent-Cc: Resent-Message-ID:In-Reply-To:References; bh=H15ozmC5XGFDwYBZ7dmHCfE3Uxdn/jqOy44YILQnA4M=; t=1724744986; x=1725954586; b=WQxJFBLu/bSypeZdD5YzDaCwz99azGcjtbjoTQnKQKkb+nvCr3abPawsmAknmLJol0mYiwyz+Vm 7QjW4gv3xaKTKuWC5xndBMjF9oUIlumuUktIZB5oIhHMPpEC1tX1q598G5Sd5O1VscLV8k+p0EoMj PXGCaarZM5XemSnIv9rS/xmcKvGHGUxl1V8Viq74UqitKlqJ73qKbcf6Rm3og+No+lhvVOyDV6El5 GqCwaFMEbOWEj29lj2r87bUaHL12et5dvG5UZ/XqyR2WUD71BF6MpldRoZZCgYy69boii6puwYKIX jVerlf8gajpS0t77iWxt3x8QOhB1h9jbO0TA==; Received: by sipsolutions.net with esmtpsa (TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.97) (envelope-from ) id 1siqxT-00000004QuI-0cAp; Tue, 27 Aug 2024 09:49:43 +0200 From: Johannes Berg To: linux-wireless@vger.kernel.org Cc: Johannes Berg , Miriam Rachel Korenblit Subject: [PATCH] wifi: mac80211: fix RCU list iterations Date: Tue, 27 Aug 2024 09:49:40 +0200 Message-ID: <20240827094939.ed8ac0b2f897.I8443c9c3c0f8051841353491dae758021b53115e@changeid> X-Mailer: git-send-email 2.46.0 Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Johannes Berg There are a number of places where RCU list iteration is used, but that aren't (always) called with RCU held. Use just list_for_each_entry() in most, and annotate iface iteration with the required locks. Reviewed-by: Miriam Rachel Korenblit Signed-off-by: Johannes Berg --- net/mac80211/chan.c | 4 +++- net/mac80211/mlme.c | 2 +- net/mac80211/scan.c | 2 +- net/mac80211/util.c | 4 +++- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/net/mac80211/chan.c b/net/mac80211/chan.c index e8567723e94d..b72e4036526b 100644 --- a/net/mac80211/chan.c +++ b/net/mac80211/chan.c @@ -286,7 +286,9 @@ ieee80211_get_max_required_bw(struct ieee80211_link_data *link) enum nl80211_chan_width max_bw = NL80211_CHAN_WIDTH_20_NOHT; struct sta_info *sta; - list_for_each_entry_rcu(sta, &sdata->local->sta_list, list) { + lockdep_assert_wiphy(sdata->local->hw.wiphy); + + list_for_each_entry(sta, &sdata->local->sta_list, list) { if (sdata != sta->sdata && !(sta->sdata->bss && sta->sdata->bss == sdata->bss)) continue; diff --git a/net/mac80211/mlme.c b/net/mac80211/mlme.c index 4779a18ab75d..b5b66feb752f 100644 --- a/net/mac80211/mlme.c +++ b/net/mac80211/mlme.c @@ -1231,7 +1231,7 @@ static bool ieee80211_add_vht_ie(struct ieee80211_sub_if_data *sdata, bool disable_mu_mimo = false; struct ieee80211_sub_if_data *other; - list_for_each_entry_rcu(other, &local->interfaces, list) { + list_for_each_entry(other, &local->interfaces, list) { if (other->vif.bss_conf.mu_mimo_owner) { disable_mu_mimo = true; break; diff --git a/net/mac80211/scan.c b/net/mac80211/scan.c index b5f2df61c7f6..2dd84fc542b2 100644 --- a/net/mac80211/scan.c +++ b/net/mac80211/scan.c @@ -504,7 +504,7 @@ static void __ieee80211_scan_completed(struct ieee80211_hw *hw, bool aborted) * the scan was in progress; if there was none this will * just be a no-op for the particular interface. */ - list_for_each_entry_rcu(sdata, &local->interfaces, list) { + list_for_each_entry(sdata, &local->interfaces, list) { if (ieee80211_sdata_running(sdata)) wiphy_work_queue(sdata->local->hw.wiphy, &sdata->work); } diff --git a/net/mac80211/util.c b/net/mac80211/util.c index ced19ce7c51a..0d6e5c51cd90 100644 --- a/net/mac80211/util.c +++ b/net/mac80211/util.c @@ -751,7 +751,9 @@ static void __iterate_interfaces(struct ieee80211_local *local, struct ieee80211_sub_if_data *sdata; bool active_only = iter_flags & IEEE80211_IFACE_ITER_ACTIVE; - list_for_each_entry_rcu(sdata, &local->interfaces, list) { + list_for_each_entry_rcu(sdata, &local->interfaces, list, + lockdep_is_held(&local->iflist_mtx) || + lockdep_is_held(&local->hw.wiphy->mtx)) { switch (sdata->vif.type) { case NL80211_IFTYPE_MONITOR: if (!(sdata->u.mntr.flags & MONITOR_FLAG_ACTIVE))