From nobody Mon Feb 19 08:07:57 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 4TdZsT4J9Dz5B30C; Mon, 19 Feb 2024 08:07:57 +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 4TdZsT2jF5z4KhD; Mon, 19 Feb 2024 08:07:57 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1708330077; 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=YgrBXB6aGw/VV63/FLrWiPRSi3p58jGXU9ni93k+Z8M=; b=Ef6LB4wWDza2jJ/EREPX5fEV+SH7svtKUJZ40tmKWJ2VS4DDEiEpsp4YLa/2K8jwdt4gA/ CkbvndXG8TbxnN4h36q/ix1CTRnArEMmXoCn+0EkYNe9hB1d2sNRFcD+iV1CBQ1Mkpza+/ VEaUlNTg1Y6zcqkGeDBCGZS5RINdu+mqWUo0tv49Dp5YFiFauIJpsm3TNE3s+TJXgfv+vq QJfPfT1M80PTUL21TF1So5PObS1MiFIEDmZkdBHPu7WNMAx6z0shSIswIEU1XbheNz5epA IDZ/TZ+g/lMMqL/KK4DyD02K9lr2NStPMue+rorlp7SbC4/fBmVq/8QWO7yd5g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1708330077; 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=YgrBXB6aGw/VV63/FLrWiPRSi3p58jGXU9ni93k+Z8M=; b=jZoPHS/9MewcLa3xloR5WNhz2RVymZHgmcpANI1JMwCIWC8yOltvWlHuMQ4Vx9/jPmgXXZ vA9cKL5mZ7FOH2m2HH9xH8/e1C5jJ58/Xfcad7Pvvf/5lzabZIlGnDdwzLJtl0kjsNavh0 RZdoQd571WraSQHLGkc4Px3qw1nfLc7GiisULPBbMe+LZ1GMs8jvQyERqxAkaVCNLVRSPC Qri+F+e+B6AYY/YakHhnLL42WJfVqhbxQjOH5/c24NPdXQ6YJr2HanBQthzylyrK4gNs9v AafPHE0KxTKAio5LqPeUsh6I7enuOoZe3ZwXcgjphbbS0Ztda7RTffm1d2Sz1g== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1708330077; a=rsa-sha256; cv=none; b=U/TmAE6fYEfqfqdC+C0tsd5v89GMCGji9Jd6gQNvxO6Pz15Zp03CoUyu5s8ZEkVeF3oHMy sqjWQSOUteE173auKEO/rrX/DeXYD6AasAXRJlrrdkwFmer833aqwzwvdh5HRtfNg4Ns2v exxzOzV1Vsb7k7ygd0ZuTBV25kzmDmGhJSIwgk0mp76zB3YAdhX1aZE7PXcbVaCwdLRRTo KJpGRQH+ltgXVWiUL9T/B2qMgEu9NylK9pp+Dox6aUKBCZ4NOCp62UQWAToXhoKhPUlaNp U8/aS9IuwGGNdq33oSvxcohF+7w1MoySs3WPBNuTnsUlTrpkKnpuSnDWeelLUw== 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 4TdZsT1qL0zRGj; Mon, 19 Feb 2024 08:07:57 +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 41J87vTK016195; Mon, 19 Feb 2024 08:07:57 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 41J87vLs016192; Mon, 19 Feb 2024 08:07:57 GMT (envelope-from git) Date: Mon, 19 Feb 2024 08:07:57 GMT Message-Id: <202402190807.41J87vLs016192@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: "Bjoern A. Zeeb" Subject: git: f8ec03794357 - stable/13 - 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/stable/13 X-Git-Reftype: branch X-Git-Commit: f8ec0379435745d800ec149f9289401c792e61bb Auto-Submitted: auto-generated The branch stable/13 has been updated by bz: URL: https://cgit.FreeBSD.org/src/commit/?id=f8ec0379435745d800ec149f9289401c792e61bb commit f8ec0379435745d800ec149f9289401c792e61bb Author: Bjoern A. Zeeb AuthorDate: 2024-01-19 14:52:03 +0000 Commit: Bjoern A. Zeeb CommitDate: 2024-02-19 08:02:01 +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. Reviewed by: cc Differential Revision: https://reviews.freebsd.org/D43512 (cherry picked from commit 49619f73151aeaca4cef5adf631253da04a46e19) --- 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 090c8c50c600..37bbe07ef430 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 cf467c08462c..5ed9f2e3f50e 100644 --- a/sys/net80211/ieee80211_proto.c +++ b/sys/net80211/ieee80211_proto.c @@ -830,6 +830,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;