From nobody Sun Jun 14 02:05:14 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 4gdGmc0mWVz6h8F2 for ; Sun, 14 Jun 2026 02:05:20 +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 "R13" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4gdGmb48byz3Jfn for ; Sun, 14 Jun 2026 02:05:19 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1781402719; 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=OnuBuiKFLo2wRre8QauDz4e20zM1waC0Lm5x+O3oIWM=; b=FhzNhLHboZcOAmNh9xRMm7x9bqnqIDRMXtRI8idEfQzo3mKNEk99AqqwLYYXHrBfLSjhoe A+QdrccA6mB20YJeb42S0KRornPfBNqte+41jEED9lmtyTGZocrbNwQf6IpvCG/3BWxqKH +ij3Lk6QOxaSCGQZVNmXfMDhjiNboflUrcSeTvpZWxI5tGjxM+WEvNYtmUSZkTH3hOnKz2 vO0Vod/plah2lYZM8MYWGmT9D/ZIyQQbsEfc3KAPwHF2D0/n1c0+/OizFmenGtjysgONK2 8kM75xwXgVqwV5zwSwwpE6xg1If9R/lmeGZZqRfyU5qfduCaE11PpLbOgUCCIw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1781402719; a=rsa-sha256; cv=none; b=GONjJzC84G/C3OHZjv1bLhb5zzkS0bxqttvdBB+yRacm0pkpY+3gFQGrQL2OJmei8blI5J 9f2Qw0VLkNIHr/o6GNtKQOvZyzGJWq/0BV47x8YfCsBr/FvpwFuVay+TeJxqKf7WJZGu9U f96RJ1BVNZWk6Eylc2/HB5s8yJUkgL4lwkpTprPuNLea3MYIAnvG/tv0gkrR5aFqAnpm9N WFWo/xckM+p9rzfJ4ljgfK77C0Wj12/OkcaexvinuJ7A3IghCQqpDuT54jxWrYgSIuwCoe woz2Yj6WyXPG7hQpMcvd5zjBpgzvvSa+CwTLLyevfsEfExsSKEFzaznrYa5unw== 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=1781402719; 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=OnuBuiKFLo2wRre8QauDz4e20zM1waC0Lm5x+O3oIWM=; b=olRhqCC1m/tIRXRFkdM2RG6gHuO7Vt0W+Zfc76QbRSHLeJ/3vqKzGdpTwl48YVrpYvMfgf aGbJTRroDL0Dmwu8t2f2mAeuqnGwi8crmgfDgrzzyDl74T8pJkuJh1+whEi0tQWpb5nam8 g70lvC2IKTX0ydB3XODZ7mAOwuG3v73PylX1W3NqMTuV3RicR53T3ulMXIvti7Ho8RQLIi nAgO025VAIDmaFenqgaxEmxyvcKZWshDu8BOm9YM78vqVUIBppiOqyGs/iq+wdviSEYFxC hYRSW0TgMHJ6JizdCgLfNBwJP9FUs5xU138VTqLbW1MSCiAMMjE1Vh2gBwLpwg== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4gdGmb3mNXzpQf for ; Sun, 14 Jun 2026 02:05:19 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 27eb4 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Sun, 14 Jun 2026 02:05:14 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Konstantin Belousov Subject: git: 36b155a2b3ba - main - vfs: work around the race between vget() and vnlru 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: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org List-Id: 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: kib X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 36b155a2b3baa747c1968a9094df9fa7fb0d02b3 Auto-Submitted: auto-generated Date: Sun, 14 Jun 2026 02:05:14 +0000 Message-Id: <6a2e0c5a.27eb4.27ede61b@gitrepo.freebsd.org> The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=36b155a2b3baa747c1968a9094df9fa7fb0d02b3 commit 36b155a2b3baa747c1968a9094df9fa7fb0d02b3 Author: Konstantin Belousov AuthorDate: 2026-05-28 09:42:38 +0000 Commit: Konstantin Belousov CommitDate: 2026-06-14 02:02:38 +0000 vfs: work around the race between vget() and vnlru Specifically, do not let vtryrecycle() to recycle a used vnode. It is possible for a vnode to be vref-ed or vuse-ed lockless after it is held by vhold_recycle_free(). Then, since vtryrecycle() does not recheck the hold count, we might end up freeing vused vnode. Since vget_finish() increments v_usecount after obtaining the vnode lock, we would observe the hold reference anyway when the parallel vget() is blocked waiting on the vnode lock. PR: 281749 Reported and tested by: Steve Peurifoy , Vladimir Grebenshchikov Reviewed by: olce Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D57305 --- sys/kern/vfs_subr.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/sys/kern/vfs_subr.c b/sys/kern/vfs_subr.c index 65529bc195bb..7b2718269a1f 100644 --- a/sys/kern/vfs_subr.c +++ b/sys/kern/vfs_subr.c @@ -1936,9 +1936,14 @@ vtryrecycle(struct vnode *vp, bool isvnlru) * anyone picked up this vnode from another list. If not, we will * mark it with DOOMED via vgonel() so that anyone who does find it * will skip over it. + * + * We cannot check only for v_usecount > 0 there, since + * v_usecount increment is lockless. Instead check for + * v_holdcnt > 1, with the side effect that a parallel vhold() + * also aborts freeing this vnode. */ VI_LOCK(vp); - if (vp->v_usecount) { + if (vp->v_holdcnt > 1) { VOP_UNLOCK(vp); vdropl_recycle(vp); vn_finished_write(vnmp);