From nobody Thu Oct 22 17:31:52 2026 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 4j9Y9h3Tldz6xPR0 for ; Thu, 22 Oct 2026 17:31:52 +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) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 4j9Y9h20Dnz3GrP for ; Thu, 22 Oct 2026 17:31:52 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1792690312; 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=38nFXd7v4RZPa3OFp9nRkDkZL3U/YHuZ/PIOnyzw1M8=; b=UnVE5piE7OP63h8Cv/IjRLO2pONzZJZ0gcPN5SXRIVO1zTFkzCjT4qA8e40umFXxLc3/gf +QqRNg4363bQefzLmsA4l+8+VklKbktIiYkH9LuMcv3/mV3qMWCvrrhTRwYiIi8MGmD4u3 SHYiWXOVAflSuPTMRlhOZ5iDZCTgqqvFVnQMNVztL5HRHTrokO7lC+x2zgtBG8uyeccygb QkRUEnf3M9o+5XYawklEslfRxHN9fxNiLxh0h17b/BuGFW7yMrtAW8LUiYSBseT3/gisV0 vK7QeWJPaNfK6hShmVxPOety/AxdRKQaOamDKZu7hAcDJbaWBl4xdmacQscwKQ== ARC-Seal: i=1; a=rsa-sha256; d=freebsd.org; s=dkim; cv=none; t=1792690312; b=AdiAIVHST52AAarlJwT347AlhebJjCAT90qVl6e4TjqkYY8tNkljwSbB7uXsYioeMsZ45a uDQn7KIbq0A91YVM48lowpqbCt4Iq/dR0MUBHP1F2pPjMgmH9Mp85Ps4Wc5duckMsFCVCq QRP3meHBbZ2BMg92Lfyv+2yDjksMgFu/loLg0062YLTbxcuAfHp43NbCF3NTWhilEEHRkm t/byTTWErArtk9DVkHjI43E97M9t0VWgDNm4uMJDdZDEAGc941ttzzj6D9+jA/HJ+Se4xl gM/wj/lGEo6hYThhILqReWtyXBcmndbJ+14XTo4bKLY50wFGWFtDiN1cI/i/4A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1792690312; 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=38nFXd7v4RZPa3OFp9nRkDkZL3U/YHuZ/PIOnyzw1M8=; b=CuhMFMVpw7LQ2kBE1XSYczR/QmQ/IPwQ9SxTntgKRlRF9l7zTfJ5H1//m6clMchSucodbS 7+95k88oWqQR7cSWul7ftS3kiajQ6PLtds1pCwHJQ+VWMpowoH6JXIEkaydmHtMmYqTV9R 5YSRUUBt70ntAUeTCjUXcIdg1HNtwiCEDcKckSLj4QW/HgWJ+vh66rMiHvehbuWTqXz6uZ hY8J/oYTmqTZckJX65ZmkzA4w93TNjMU+q0LPx/RYdBKEDrADaSyT/CYVSEWpYGZavXjdp ehGz1rYpsVpf7i1Wzd6WQIIqdokME6847XpGhkAqx9ynOOejq3uZObCDlas5hA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4j9Y9h16wDzrlb for ; Thu, 22 Oct 2026 17:31:52 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 3d0c1 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Thu, 22 Oct 2026 17:31:52 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mark Johnston Subject: git: ec48222a648f - stable/15 - lockf: Truncate the active lock list earlier in lf_purgelocks() List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org List-Id: Commit messages for all branches of the src repository List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/stable/15 X-Git-Reftype: branch X-Git-Commit: ec48222a648f6e6b617582efeefcdefb1b075405 Auto-Submitted: auto-generated Date: Thu, 22 Oct 2026 17:31:52 +0000 Message-Id: <6ada4888.3d0c1.4766d563@gitrepo.freebsd.org> The branch stable/15 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=ec48222a648f6e6b617582efeefcdefb1b075405 commit ec48222a648f6e6b617582efeefcdefb1b075405 Author: Mark Johnston AuthorDate: 2026-09-21 14:14:45 +0000 Commit: Mark Johnston CommitDate: 2026-10-22 15:45:40 +0000 lockf: Truncate the active lock list earlier in lf_purgelocks() Otherwise vfs_report_lockf() can race with lf_purgelocks() while the latter is freeing active lock entries without any locks held. Reviewed by: kib MFC after: 2 weeks Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D59768 (cherry picked from commit e20ed58d265cd6eba9b28efc8e8956324937d4c3) --- sys/kern/kern_lockf.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/sys/kern/kern_lockf.c b/sys/kern/kern_lockf.c index da2f619d8d99..2cb02b21cd78 100644 --- a/sys/kern/kern_lockf.c +++ b/sys/kern/kern_lockf.c @@ -752,6 +752,7 @@ lf_purgelocks(struct vnode *vp, struct lockf **statep) { struct lockf *state; struct lockf_entry *lock, *nlock; + struct lockf_entry_list active; /* * For this to work correctly, the caller must ensure that no @@ -778,6 +779,7 @@ lf_purgelocks(struct vnode *vp, struct lockf **statep) state->ls_threads++; VI_UNLOCK(vp); + LIST_INIT(&active); sx_xlock(&state->ls_lock); sx_xlock(&lf_owner_graph_lock); LIST_FOREACH_SAFE(lock, &state->ls_pending, lf_link, nlock) { @@ -797,6 +799,7 @@ lf_purgelocks(struct vnode *vp, struct lockf **statep) wakeup(lock); } } + LIST_SWAP(&active, &state->ls_active, lockf_entry, lf_link); sx_xunlock(&lf_owner_graph_lock); sx_xunlock(&state->ls_lock); @@ -810,19 +813,17 @@ lf_purgelocks(struct vnode *vp, struct lockf **statep) VI_UNLOCK(vp); /* - * We can just free all the active locks since they - * will have no dependencies (we removed them all - * above). We don't need to bother locking since we - * are the last thread using this state structure. + * We can just free all the active locks since they will have no + * dependencies (we removed them all above). */ - KASSERT(LIST_EMPTY(&state->ls_pending), - ("lock pending for %p", state)); - LIST_FOREACH_SAFE(lock, &state->ls_active, lf_link, nlock) { + LIST_FOREACH_SAFE(lock, &active, lf_link, nlock) { LIST_REMOVE(lock, lf_link); lf_free_lock(lock); } out_free: sx_xlock(&lf_lock_states_lock); + KASSERT(LIST_EMPTY(&state->ls_pending), ("lock pending for %p", state)); + KASSERT(LIST_EMPTY(&state->ls_active), ("lock active for %p", state)); LIST_REMOVE(state, ls_link); sx_xunlock(&lf_lock_states_lock); sx_destroy(&state->ls_lock);