From nobody Sat Feb 3 13:56:22 2024 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4TRvLv1nbMz59RQT; Sat, 3 Feb 2024 13:56:23 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4TRvLv1HbWz45J5; Sat, 3 Feb 2024 13:56:23 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1706968583; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=oPvP1qG5Pq31wH3ETdREf0u5+pf3KkJSGXEEoQj/It0=; b=sWpcA0faK0DIPdYL0bPLKaqRMxftGYYw7c+m6SkVbe4nzzUv089iBlGnTBhvFyNKDSHNQj YruqdNMPRGOG/Ugjq9hVpcw035B6sPCBoV6U9Z1opJnbrVWEJKaee8P8h0mfKvKrT9Go3R jOe/H/lv4aEa5Et9kPaWPPaRNJafCcQT4p8pOyNRYpAFzndZSDCVDpGjiiW87dn7ETyNIQ WkJPTma2Ri39leIiy610dZnYNYPGLau/KE0I5Jt1luTlet6WhEUvLA0sPvfh6gPPE/O85H 3IfvUkbtqMxn+4SO57B/jvNU35Nnt1KGFXhkRtBiPxULSdsORo3h0SQDBhhqUg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1706968583; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=oPvP1qG5Pq31wH3ETdREf0u5+pf3KkJSGXEEoQj/It0=; b=IDtJP7hMd7f5Tc0C9oeohX+Q+izXFbfmzYwgz239WjGy8UqprhjDDew9ox/ngjJ0dKkz3l b/fudz6D9wf2gFsnHWZl5vmlygrF5fLGIapFkz0GchQDYvds8gSmVdIQTPvHp+DOY0vYxk ZjwbKUHHcr+9cH00LbZu22Y5LKkflAaJWFSYneBDbPM+EkmEDGRbSmddRBg0SpUXG1FIhG P/a8hWxpIt+TQc9wXrxyHX8TjxJh0wcsxm/ix2pNKcQ6PPIUb2T0r3PttxEUZU0wRX+/8R qvG5cyo89GK0KDYFMM+E0KWuo4YjmxydgZ4PLuYjt70r25Qy2LTBPfMuFAb0jg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1706968583; a=rsa-sha256; cv=none; b=oTZt63kkAZFzB5LubExmWuTOHrgEJAWGLjW+HOG+j5u/qpyUwa0aNq3vUdmVNpNSVuG7Zq q2zn91NQUFkIl1zMGRkMqGSZICh237oR7/yvX1M01MQNfTweKuAM0yHih2EU/LHQJ7bqql Sa1MA+11EzG+qA+Q//AQsVyTz70KeOfKjxaK7t09L+7uW652ReJBhd1hMbf50VN0mpQLZj JUXmuhQvjin3pamJH4VmQF6eIU8kmpY7A1S3GVq7RnSEaiDYxgJFqYi1HDGCFbsnjwMHXt 3Bzmd3juwXKRVHSUPtXAwXCJ6amobxoZ1O1FRvT6p9NWtyTcL/cc5nJMGf1sYQ== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4TRvLv0MDMzGWl; Sat, 3 Feb 2024 13:56:23 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 413DuM4l056392; Sat, 3 Feb 2024 13:56:22 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 413DuMJk056390; Sat, 3 Feb 2024 13:56:22 GMT (envelope-from git) Date: Sat, 3 Feb 2024 13:56:22 GMT Message-Id: <202402031356.413DuMJk056390@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: "Bjoern A. Zeeb" Subject: git: 49619f73151a - main - net80211: make sure calls to (*iv_update_bss)() are locked List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: bz X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 49619f73151aeaca4cef5adf631253da04a46e19 Auto-Submitted: auto-generated The branch main has been updated by bz: URL: https://cgit.FreeBSD.org/src/commit/?id=49619f73151aeaca4cef5adf631253da04a46e19 commit 49619f73151aeaca4cef5adf631253da04a46e19 Author: Bjoern A. Zeeb AuthorDate: 2024-01-19 14:52:03 +0000 Commit: Bjoern A. Zeeb CommitDate: 2024-02-03 13:55:29 +0000 net80211: make sure calls to (*iv_update_bss)() are locked It turned out thare various calls into (*iv_update_bss)(), that is direct changes to vap->iv_bss in the old days, happened without synchronisation. Use locking assertions to document the requirement or status quo at some callers given ic locking will eventually have to be dealt with. MFC after: 3 days Reviewed by: cc Differential Revision: https://reviews.freebsd.org/D43512 --- sys/net80211/ieee80211_node.c | 15 +++++++++++++++ sys/net80211/ieee80211_proto.c | 2 ++ 2 files changed, 17 insertions(+) diff --git a/sys/net80211/ieee80211_node.c b/sys/net80211/ieee80211_node.c index f6bb4245f543..8f8dc5f378b8 100644 --- a/sys/net80211/ieee80211_node.c +++ b/sys/net80211/ieee80211_node.c @@ -171,6 +171,10 @@ ieee80211_node_vattach(struct ieee80211vap *vap) void ieee80211_node_latevattach(struct ieee80211vap *vap) { + + /* XXX should ieee80211_vap_attach(), our only caller hold the lock? */ + IEEE80211_UNLOCK_ASSERT(vap->iv_ic); + if (vap->iv_opmode == IEEE80211_M_HOSTAP) { /* XXX should we allow max aid to be zero? */ if (vap->iv_max_aid < IEEE80211_AID_MIN) { @@ -191,7 +195,9 @@ ieee80211_node_latevattach(struct ieee80211vap *vap) } } + IEEE80211_LOCK(vap->iv_ic); ieee80211_reset_bss(vap); + IEEE80211_UNLOCK(vap->iv_ic); vap->iv_auth = ieee80211_authenticator_get(vap->iv_bss->ni_authmode); } @@ -201,11 +207,16 @@ ieee80211_node_vdetach(struct ieee80211vap *vap) { struct ieee80211com *ic = vap->iv_ic; + /* XXX should ieee80211_vap_detach(), our only caller hold the lock? */ + IEEE80211_UNLOCK_ASSERT(vap->iv_ic); + ieee80211_node_table_reset(&ic->ic_sta, vap); + IEEE80211_LOCK(ic); if (vap->iv_bss != NULL) { ieee80211_free_node(vap->iv_bss); vap->iv_update_bss(vap, NULL); } + IEEE80211_UNLOCK(ic); if (vap->iv_aid_bitmap != NULL) { IEEE80211_FREE(vap->iv_aid_bitmap, M_80211_NODE); vap->iv_aid_bitmap = NULL; @@ -455,6 +466,8 @@ ieee80211_reset_bss(struct ieee80211vap *vap) struct ieee80211com *ic = vap->iv_ic; struct ieee80211_node *ni, *obss; + IEEE80211_LOCK_ASSERT(ic); + ieee80211_node_table_reset(&ic->ic_sta, vap); /* XXX multi-bss: wrong */ ieee80211_vap_reset_erp(vap); @@ -854,7 +867,9 @@ ieee80211_sta_join1(struct ieee80211_node *selbs) /* * Committed to selbs, setup state. */ + IEEE80211_LOCK(ic); /* XXX may recurse here, check callers. */ obss = vap->iv_update_bss(vap, selbs); /* NB: caller assumed to bump refcnt */ + IEEE80211_UNLOCK(ic); /* * Check if old+new node have the same address in which * case we can reassociate when operating in sta mode. diff --git a/sys/net80211/ieee80211_proto.c b/sys/net80211/ieee80211_proto.c index a3a2e6a5d027..c0f24344a982 100644 --- a/sys/net80211/ieee80211_proto.c +++ b/sys/net80211/ieee80211_proto.c @@ -826,6 +826,8 @@ vap_update_bss(struct ieee80211vap *vap, struct ieee80211_node *ni) { struct ieee80211_node *obss; + IEEE80211_LOCK_ASSERT(vap->iv_ic); + obss = vap->iv_bss; vap->iv_bss = ni;