Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 6 Jun 2025 16:29:35 GMT
From:      "Bjoern A. Zeeb" <bz@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: 284af342971d - main - LinuxKPI: 802.11: place lock asserts for key operation
Message-ID:  <202506061629.556GTZx2067457@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch main has been updated by bz:

URL: https://cgit.FreeBSD.org/src/commit/?id=284af342971d102702df950a2f1e5479eaabdf0b

commit 284af342971d102702df950a2f1e5479eaabdf0b
Author:     Bjoern A. Zeeb <bz@FreeBSD.org>
AuthorDate: 2025-06-05 21:00:53 +0000
Commit:     Bjoern A. Zeeb <bz@FreeBSD.org>
CommitDate: 2025-06-06 16:27:59 +0000

    LinuxKPI: 802.11: place lock asserts for key operation
    
    Since b8dfc3ecf7031 we hold the wiphy lock over any key updates.
    Assert that on function entry.
    
    Given this invariant there is no need to recheck a kay under lock now,
    as the first lookup already is under the lock, so simplify the code.
    
    Sponsored by:   The FreeBSD Foundation
    MFC after:      3 days
---
 sys/compat/linuxkpi/common/src/linux_80211.c | 35 +++++++++++++++-------------
 1 file changed, 19 insertions(+), 16 deletions(-)

diff --git a/sys/compat/linuxkpi/common/src/linux_80211.c b/sys/compat/linuxkpi/common/src/linux_80211.c
index 921c986fcd06..e81c77d67001 100644
--- a/sys/compat/linuxkpi/common/src/linux_80211.c
+++ b/sys/compat/linuxkpi/common/src/linux_80211.c
@@ -1298,6 +1298,16 @@ lkpi_iv_key_delete(struct ieee80211vap *vap, const struct ieee80211_key *k)
 	int error;
 
 	ic = vap->iv_ic;
+	lhw = ic->ic_softc;
+	hw = LHW_TO_HW(lhw);
+	lvif = VAP_TO_LVIF(vap);
+
+	/*
+	 * Make sure we do not make it here without going through
+	 * lkpi_iv_key_update_begin() first.
+	 */
+	lockdep_assert_wiphy(hw->wiphy);
+
 	if (IEEE80211_KEY_UNDEFINED(k)) {
 		ic_printf(ic, "%s: vap %p key %p is undefined: %p %u\n",
 		    __func__, vap, k, k->wk_cipher, k->wk_keyix);
@@ -1331,18 +1341,7 @@ lkpi_iv_key_delete(struct ieee80211vap *vap, const struct ieee80211_key *k)
 		ieee80211_free_node(ni);
 		return (1);
 	}
-
 	kc = lsta->kc[k->wk_keyix];
-	/* Re-check under lock. */
-	if (kc == NULL) {
-#ifdef LINUXKPI_DEBUG_80211
-		if (linuxkpi_debug_80211 & D80211_TRACE_HW_CRYPTO)
-			ic_printf(ic, "%s: sta %6D and key information vanished, "
-			    "returning success\n", __func__, sta->addr, ":");
-#endif
-		error = 1;
-		goto out;
-	}
 
 #ifdef LINUXKPI_DEBUG_80211
 	if (linuxkpi_debug_80211 & D80211_TRACE_HW_CRYPTO)
@@ -1353,9 +1352,6 @@ lkpi_iv_key_delete(struct ieee80211vap *vap, const struct ieee80211_key *k)
 		    kc->keyidx, kc->hw_key_idx, kc->flags, IEEE80211_KEY_FLAG_BITS);
 #endif
 
-	lhw = ic->ic_softc;
-	hw = LHW_TO_HW(lhw);
-	lvif = VAP_TO_LVIF(vap);
 	vif = LVIF_TO_VIF(lvif);
 	error = lkpi_80211_mo_set_key(hw, DISABLE_KEY, vif, sta, kc);
 	if (error != 0) {
@@ -1400,6 +1396,15 @@ lkpi_iv_key_set(struct ieee80211vap *vap, const struct ieee80211_key *k)
 	int error;
 
 	ic = vap->iv_ic;
+	lhw = ic->ic_softc;
+	hw = LHW_TO_HW(lhw);
+
+	/*
+	 * Make sure we do not make it here without going through
+	 * lkpi_iv_key_update_begin() first.
+	 */
+	lockdep_assert_wiphy(hw->wiphy);
+
 	if (IEEE80211_KEY_UNDEFINED(k)) {
 		ic_printf(ic, "%s: vap %p key %p is undefined: %p %u\n",
 		    __func__, vap, k, k->wk_cipher, k->wk_keyix);
@@ -1492,8 +1497,6 @@ lkpi_iv_key_set(struct ieee80211vap *vap, const struct ieee80211_key *k)
 		    kc->keylen, kc->flags, IEEE80211_KEY_FLAG_BITS);
 #endif
 
-	lhw = ic->ic_softc;
-	hw = LHW_TO_HW(lhw);
 	lvif = VAP_TO_LVIF(vap);
 	vif = LVIF_TO_VIF(lvif);
 	error = lkpi_80211_mo_set_key(hw, SET_KEY, vif, sta, kc);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202506061629.556GTZx2067457>