From nobody Fri Apr 18 14:37:22 2025 X-Original-To: dev-commits-src-branches@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 4ZfHR73Zm9z5sthX; Fri, 18 Apr 2025 14:37: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 "R10" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4ZfHR668bMz3KyQ; Fri, 18 Apr 2025 14:37:22 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1744987042; 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=7F3S/vpFKQdbtxAbRg9w4ma9iNoCbr2bYaumAz0O/mw=; b=iX5QwwK2eTnbs9uS3l5VakLJLn8L4XFWhcSSN6E114IeuiJC32Gw6BdmSAvPkISOpMYYCd rJ2cDqKqAEuumq6DfuV/2vrTH6avAL9S15i7DQjdbV/tX/fR/H2OPpnrydZBZu8Hz3dMxZ V1NP9HVXFWh7Oti+eM9D6ZBuQOcPyfJqziqSOR3XDuYPbIt6iDyz5r4Pnqs+PtxIc70aFq 3qExcwiLyZDWp7AJ4rjFCp3zaWC+flnRjMf41hFbJavkKQLX1IxXphE7UrzjvqZeMgWXUP CyuWmlO6dC95cug6s7vdabmH9H/vWDVXeqYN6DFxE3y1g8Nzse7FPYGhJTTx7w== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1744987042; a=rsa-sha256; cv=none; b=LdCB1z6QIrj7FXyPO16aLqYwZS2vXBPK9AvFA1VM+lKXVAOLJwBi9pDo+g8ygZL2VAn+hh mdAgJwHL47UtR8jC+s/7leYDk7202GvWoPnNeRMlGQLqshbsO/bSQSFFoYj/XsnY4CHHoB AjesI+0WwmF7/5yAvx4Tp88mKFNyd8InZ8vLIjPkSFwNERB0zDXEei7T+vdQYTdWZvOJzs bzPXXuZlBPG4N9jl1qCGptD4TOkDZ+O9bEueELe3Capo+11QWFZIiK85DQrTqhlAV3/DlU Q4mU1S/afl3V7lOfQFUxLcZuV43VJF4YWjhIEOpgEHcAxjZ4Y6y8GUwN5SeKKQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1744987042; 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=7F3S/vpFKQdbtxAbRg9w4ma9iNoCbr2bYaumAz0O/mw=; b=kyhwUV87m7boAjjW1j6c6/R+i0zFSJuLpw/fTGjx/Fo2gr1sco4eCf5TYaT2IIFCNK7ntA bk7i6K08V7iqWBvH10Q3SUMr2fJ2Puv9oxRuDLq1lBE1AuFupEwSImzHCP6TOwg3m9PK7W H53wpgOLLCO+ui7aXcjSCzQka/Z6D5Lpda0ZKm0sEoaNz5wUQuhDg0l2xO24nYwz+VgwDS hPYiRbnyjEwEBBBjAbj8xyIQA7Z8nNiCGI4nIM5O4Gae3K5Gku3Zeipn8trccIMG5AjmHg nlUhzjVEpcKtHHvkW208f+oGvzkuDyvtvnUPArCmHyPU/1KtYYIFQ+wmlT7saA== 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 4ZfHR65lXCzdmf; Fri, 18 Apr 2025 14:37:22 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 53IEbMoK092137; Fri, 18 Apr 2025 14:37:22 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 53IEbMMC092134; Fri, 18 Apr 2025 14:37:22 GMT (envelope-from git) Date: Fri, 18 Apr 2025 14:37:22 GMT Message-Id: <202504181437.53IEbMMC092134@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: 9bd4391f4ce0 - stable/14 - LinuxKPI: 802.11: further locking workarounds fro crypto updates List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-branches@freebsd.org Sender: owner-dev-commits-src-branches@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: 9bd4391f4ce023fba8f5c5296a359ffb605efec2 Auto-Submitted: auto-generated The branch stable/14 has been updated by bz: URL: https://cgit.FreeBSD.org/src/commit/?id=9bd4391f4ce023fba8f5c5296a359ffb605efec2 commit 9bd4391f4ce023fba8f5c5296a359ffb605efec2 Author: Bjoern A. Zeeb AuthorDate: 2025-04-11 23:01:55 +0000 Commit: Bjoern A. Zeeb CommitDate: 2025-04-18 14:36:02 +0000 LinuxKPI: 802.11: further locking workarounds fro crypto updates There are cases when net80211 calls into crypto updates with the ic lock held (not (just) the nt lock). We have to unlock that as well and track the unlock like we do for the nt to avoid panics when we later can sleep (on the wiphy [sx] lock). Sponsored by: The FreeBSD Foundation Reported by: rm Tested by: rm PR: 285729 Fixes: b8dfc3ecf703 Differential Revision: https://reviews.freebsd.org/D49791 (cherry picked from commit a6165709e3c8ba4a0bee18aead6ca8ea2b033933) --- sys/compat/linuxkpi/common/src/linux_80211.c | 51 ++++++++++++++++++---------- sys/compat/linuxkpi/common/src/linux_80211.h | 1 + 2 files changed, 35 insertions(+), 17 deletions(-) diff --git a/sys/compat/linuxkpi/common/src/linux_80211.c b/sys/compat/linuxkpi/common/src/linux_80211.c index 5a4798f1ef1b..f9f16e0a6f8f 100644 --- a/sys/compat/linuxkpi/common/src/linux_80211.c +++ b/sys/compat/linuxkpi/common/src/linux_80211.c @@ -1427,7 +1427,7 @@ lkpi_iv_key_update_begin(struct ieee80211vap *vap) struct lkpi_hw *lhw; struct ieee80211_hw *hw; struct lkpi_vif *lvif; - bool islocked; + bool icislocked, ntislocked; ic = vap->iv_ic; lhw = ic->ic_softc; @@ -1435,28 +1435,35 @@ lkpi_iv_key_update_begin(struct ieee80211vap *vap) lvif = VAP_TO_LVIF(vap); nt = &ic->ic_sta; - islocked = IEEE80211_NODE_IS_LOCKED(nt); + icislocked = IEEE80211_IS_LOCKED(ic); + ntislocked = IEEE80211_NODE_IS_LOCKED(nt); #ifdef LINUXKPI_DEBUG_80211 if (linuxkpi_debug_80211 & D80211_TRACE_HW_CRYPTO) - ic_printf(vap->iv_ic, "%s: tid %d vap %p nt %p %slocked " - "lvif nt_unlocked %d\n", __func__, curthread->td_tid, - vap, nt, islocked ? "" : "un", lvif->nt_unlocked); + ic_printf(ic, "%s: tid %d vap %p ic %p %slocked nt %p %slocked " + "lvif ic_unlocked %d nt_unlocked %d\n", __func__, + curthread->td_tid, vap, + ic, icislocked ? "" : "un", nt, ntislocked ? "" : "un", + lvif->ic_unlocked, lvif->nt_unlocked); #endif /* This is inconsistent net80211 locking to be fixed one day. */ - if (islocked) + if (icislocked) + IEEE80211_UNLOCK(ic); + if (ntislocked) IEEE80211_NODE_UNLOCK(nt); wiphy_lock(hw->wiphy); /* - * nt_unlocked could be a bool given we are under the lock and there + * ic/nt_unlocked could be a bool given we are under the lock and there * must only be a single thread. * In case anything in the future disturbs the order the refcnt will * help us catching problems a lot easier. */ - if (islocked) + if (icislocked) + refcount_acquire(&lvif->ic_unlocked); + if (ntislocked) refcount_acquire(&lvif->nt_unlocked); } @@ -1468,7 +1475,7 @@ lkpi_iv_key_update_end(struct ieee80211vap *vap) struct lkpi_hw *lhw; struct ieee80211_hw *hw; struct lkpi_vif *lvif; - bool islocked; + bool icislocked, ntislocked; ic = vap->iv_ic; lhw = ic->ic_softc; @@ -1476,14 +1483,18 @@ lkpi_iv_key_update_end(struct ieee80211vap *vap) lvif = VAP_TO_LVIF(vap); nt = &ic->ic_sta; - islocked = IEEE80211_NODE_IS_LOCKED(nt); - MPASS(!islocked); + icislocked = IEEE80211_IS_LOCKED(ic); + MPASS(!icislocked); + ntislocked = IEEE80211_NODE_IS_LOCKED(nt); + MPASS(!ntislocked); #ifdef LINUXKPI_DEBUG_80211 if (linuxkpi_debug_80211 & D80211_TRACE_HW_CRYPTO) - ic_printf(vap->iv_ic, "%s: tid %d vap %p nt %p %slocked " - "lvif nt_unlocked %d\n", __func__, curthread->td_tid, - vap, nt, islocked ? "" : "un", lvif->nt_unlocked); + ic_printf(ic, "%s: tid %d vap %p ic %p %slocked nt %p %slocked " + "lvif ic_unlocked %d nt_unlocked %d\n", __func__, + curthread->td_tid, vap, + ic, icislocked ? "" : "un", nt, ntislocked ? "" : "un", + lvif->ic_unlocked, lvif->nt_unlocked); #endif /* @@ -1491,11 +1502,17 @@ lkpi_iv_key_update_end(struct ieee80211vap *vap) * In case the refcnt gets out of sync locking in net80211 will * quickly barf as well (trying to unlock a lock not held). */ - islocked = refcount_release_if_last(&lvif->nt_unlocked); + icislocked = refcount_release_if_last(&lvif->ic_unlocked); + ntislocked = refcount_release_if_last(&lvif->nt_unlocked); wiphy_unlock(hw->wiphy); - /* This is inconsistent net80211 locking to be fixed one day. */ - if (islocked) + /* + * This is inconsistent net80211 locking to be fixed one day. + * ic before nt to avoid a LOR. + */ + if (icislocked) + IEEE80211_LOCK(ic); + if (ntislocked) IEEE80211_NODE_LOCK(nt); } #endif diff --git a/sys/compat/linuxkpi/common/src/linux_80211.h b/sys/compat/linuxkpi/common/src/linux_80211.h index da377280b1c0..ebf02994af47 100644 --- a/sys/compat/linuxkpi/common/src/linux_80211.h +++ b/sys/compat/linuxkpi/common/src/linux_80211.h @@ -187,6 +187,7 @@ struct lkpi_vif { struct lkpi_sta *lvif_bss; + int ic_unlocked; /* Count of ic unlocks pending (*mo_set_key) */ int nt_unlocked; /* Count of nt unlocks pending (*mo_set_key) */ bool lvif_bss_synched; bool added_to_drv; /* Driver knows; i.e. we called add_interface(). */