From nobody Sun Feb 18 21:11:28 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 4TdJJ10sD2z5BmTf; Sun, 18 Feb 2024 21:11:29 +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 4TdJJ05GhXz42pn; Sun, 18 Feb 2024 21:11:28 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1708290688; 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=+N5QMBT1JYarp1uxRbfd6MVEpO1kfQ32nMROg1+1J38=; b=iB2v5QKPZKyEat5qabODTO9h78L4aTtxt1utSlwnaaQ5FyRMyav8IJqqOX3yxHob2yrdD+ awKYHQFbgV8p5Xyv+kCkBL1gitubPGwO7RbPLhsmwvJfTUauUzvEsnIE80ai6IHs8i6DWR kbN+ys56zJmVdnGde7vOnZ6G48YLibxzxV34uo1cuUN22JP9B2dZhPi7jaxNXLaoJAAPd9 NzThxn73JX+XO0oAAjuXxyiuQ3I8na0YwNFkVhr7eRv1RWn01p7x0439rtxjwqaRkiSdxF LAU24JfoHvBzZ1KU/smTBC2L7gGh7HYOpjMWQz0yHHfomPBUdKg7lpcQOM0LtA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1708290688; 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=+N5QMBT1JYarp1uxRbfd6MVEpO1kfQ32nMROg1+1J38=; b=pK9gCj7EvQFQkdFbTXD3g3ojMgU65hLjLefj5Gsoy3e8pwOg19JAyyZd5ZK9aPH515ldQF bvfNv5UUH0DDt4CAlexJSwZ65vUUO510NhvYn9AXPZH02p9UBuXDeQL1u28TiBsgSZYtRl hLES4iFUB36pybYwMBNt1g0aUaIQF5VJNzMtbdQ5C7aSPPBiHJOWZ2HULfY+81yewiZGsm cvYrGImhsVWUWacDQKz7J/Wk1G3UOzVgsw44iT06xXkV8GV0dLVcPb/O0nu7porKXAUtYC oUMkfQrA+LwrEhBLIYk3lrLmjj8l6D9AjUXsGo+QKsk7bepLX15LcJki7UgOwg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1708290688; a=rsa-sha256; cv=none; b=aEKv2ejZgrg0NJIKyZgqScRItqM4MwtiYq0KnVJuQErk8G5sVJzdJ9D3SOtncNnG195siv +gJVWsMgTcZKY4w6tM0KoLh2jTvW1u5eRc+Ibz+bu+jid6azifcdVXdnYEe5cJ5PQHVpcv wzKtiMkUqekQNu87CeZZxlI41WC5qwYsg9tm6rUX84/acBIoByIaf5abelOu2T3wgv/0Ct wHpv1BsoMo9oJqcSiIDaDikQpMcM9utdTXbuFzEuWKmhBeKWCxtc6YGSu542mbWNkUcmKa LRPLPl+dLywwqjNz6R8e8cM7N74oi1ZAFQu69boaAv2rrtHq+SfMwDHXuaK50A== 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 4TdJJ04N6Pz16Z6; Sun, 18 Feb 2024 21:11:28 +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 41ILBSiO015947; Sun, 18 Feb 2024 21:11:28 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 41ILBSdq015944; Sun, 18 Feb 2024 21:11:28 GMT (envelope-from git) Date: Sun, 18 Feb 2024 21:11:28 GMT Message-Id: <202402182111.41ILBSdq015944@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: 383cbcd21b73 - stable/14 - 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/14 X-Git-Reftype: branch X-Git-Commit: 383cbcd21b73075b3863b41a3b0cc7e3dde96a38 Auto-Submitted: auto-generated The branch stable/14 has been updated by bz: URL: https://cgit.FreeBSD.org/src/commit/?id=383cbcd21b73075b3863b41a3b0cc7e3dde96a38 commit 383cbcd21b73075b3863b41a3b0cc7e3dde96a38 Author: Bjoern A. Zeeb AuthorDate: 2024-01-19 14:52:03 +0000 Commit: Bjoern A. Zeeb CommitDate: 2024-02-18 18:31:16 +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 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;