From nobody Sun Jun 14 02:05:14 2026 X-Original-To: dev-commits-src-main@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 4gdGmV62pvz6h8F1 for ; Sun, 14 Jun 2026 02:05:14 +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 4gdGmV3PNTz3J6j for ; Sun, 14 Jun 2026 02:05:14 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1781402714; 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=GJWEdfSTYADtwAWI541mTSmtZawXDQ+EkYYhWs0uDVsIBIt5y+Xc1C62/5PkDG5HrSsdIM HYct/73AIqf8nR3WKfSJMOTzCdg6vpj4gpjusHkKCv+g+eee7THdAzCImTnYwTBDZ1IHOS 6/hbtv+nQ320TURnm2aKAp9eutA2a/CksoP9yROncA2IhlgiDdIrdFJ6jE9vof3e55pD6B JzOD/as+61qQjq7X0Pbxwxr6iDO+CIthOR58Q/hWra27Aytc225NBlCnUCwYbRebwmwkyj 58dc5TvboeKtAZgRdvxGqyjOirpB0cFVsIBzOEnagNRCgUaZXd6WJhzSNTMltg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1781402714; a=rsa-sha256; cv=none; b=t3RGjbcx6Cc7x3pgezZ8FK+gOUcXjYC+36w2zVkRgxX27KL7bP1W1Hv1BQ5WqUu1xcaqht vPOt3XRdqo/kEEH74q2cbV+GmMUjsc/xeti0fJiS4E55UArWF6Fol+X0Wh1KfeDtSQMM0W mmOqkB7dlqHNHgg3OHcWQwrEPH1OJsJGmg/PyK7WwD+/oYFbrG8axwoh52J71IiO7rV70C ZYGhsFSS8JaCH7N9yoJ1Wy+dVpcbdR5/Be+xU/FJm1p6/fPTWQfnMjm9fBXSvBAB34zJeS KVpwiyFztBMfX+r2sEj2SkpMUmYL5J+lXn4opVVoEPEGetFt7ee7bQv4BETv6Q== 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=1781402714; 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=auWjfk+vwVhZKukVvtBW9q7DCSPVyJbtloDOKCQdtKBhfoTw5gRCkGVcGlW19BE1qyRrvt PBn5Iyt84X4uhvuLLOuPN+XZWRMfTmnyrPx5qPf/R+VOx33HbDvoo9rAafUhGI8rLUrnU/ 1+SqNZceSJAxVo1uhGrwxYytyaq/msP+j7zqcTv3/ucOhQvZl0IBKwsLkd7IwBYMGiQkWc oQgW/HJ5W1stM5JV7CqvT/zWtjpUuE9bnWy3/5vUsuR5XeBDGIyg5rNSV/OcydfopilTO4 Kr9FI4/WdH6gSX0VesVT9+S3VEbXH8n//O/OYWsVPl+FKi9uiCy6pQqp4EOxCQ== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4gdGmV2rwYzpQc for ; Sun, 14 Jun 2026 02:05:14 +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 the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@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);