From nobody Wed Nov 19 16:17:17 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 4dBRT974Tpz6HwGq for ; Wed, 19 Nov 2025 16:17:17 +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 "R12" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4dBRT94Z6pz4Nqg for ; Wed, 19 Nov 2025 16:17:17 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1763569037; 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=11YBw5g6XtRE6XaQ+fNr5jpLGSoFlCcKEBOfmSiYIoo=; b=BEHowLPp0d8qsifgKMozOW6DFHmIQfMj2SA1v905tj52HijnUhYsIEHlSQAAlghJBO9Jam 85cs0EL9dHDpzOyvWQrTDXAV5PH2R98PFgmYZ0xGjgWcfHo9YhzLiouN4jeAa9X8bFttRV cs9t3/pOSTZB+s4ninGGiuyaAppwV77k7KlAel47qkhO/hnzs3V9J+BzbGfnGtYCbI+VRz KtoJ042BtjvPycsSujnGZQjr4p8EpY648+7HQM4eOvUccZXgKeD5pJP388z6WQGn2WLj/k eqCouOCIfDgq34l1nuVHHAUR4QFbmsGld2yn3gVzDZwj+uhT3cXY9FhcsxTfbw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1763569037; 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=11YBw5g6XtRE6XaQ+fNr5jpLGSoFlCcKEBOfmSiYIoo=; b=u6DIbKkF+pESsbcLJJu8S00EjDJdpAGogeDbiWffNWKzmuFtbafvBG7Eq1OqsAda16/8zO 87eGAGG9SKZjNd5g4AOyQhwex0J77NagHeQqfGIwI671LqsyiWhgDowaYmSRtoAY5vuEqO EBqN/5wS0Io5UvXt02/2QuQbURcQu1pKRlfp8/OlmWTeRLVjbC/6hodDAgyOgs6e9hxmn1 HdPnhxy6EL8HBsHzOLCj5kXP54L0x0iBtoQIGqPeW62RqdTGyyl6UuDPFzp77inqkwtpXt 5PxsSbnuYYsUNUT9k2PLu4ithgveME2Wj/SluhYDgCVr4gLBWDmkED2glsI8cA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1763569037; a=rsa-sha256; cv=none; b=ihzY156SqLUGpbfzledrCrOP65CXS8JxTIrjZlRIZMoUmRcnOUeRJFIJyhd+BWuTAg2jhU fB1EZdXMOa8PpcU+NEsZg+5ndmp2usigIyAKUgHK5c/42v4h3iE4T6FsDQwfToUN9SBTYZ 1wx2Lak9l688w0mde70zy9v2TFfFlzRnyG/7itbARb+KBENsuEkvpxiEXwC/o+diElmix5 6eWz95tI4PpNGgpD8Mz0kPKp5ZOs/1PjugNoYZZskf7MbAvYOlu5dBIg9X5i/N3JHvSAEk DZoV0fn0GNm2YT69skMYUAjhCtnt9z4hiUpSBKAp7/qfhTjB0wpNgkprVKpMYQ== 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 4dBRT93vy1zntC for ; Wed, 19 Nov 2025 16:17:17 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 398b1 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Wed, 19 Nov 2025 16:17:17 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mark Johnston Subject: git: 1f6e3abf4171 - stable/15 - inotify: Work around the vput() bug directly 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: markj X-Git-Repository: src X-Git-Refname: refs/heads/stable/15 X-Git-Reftype: branch X-Git-Commit: 1f6e3abf41718e8e4a309be122f0a6048e9c5772 Auto-Submitted: auto-generated Date: Wed, 19 Nov 2025 16:17:17 +0000 Message-Id: <691ded8d.398b1.5f100ac8@gitrepo.freebsd.org> The branch stable/15 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=1f6e3abf41718e8e4a309be122f0a6048e9c5772 commit 1f6e3abf41718e8e4a309be122f0a6048e9c5772 Author: Mark Johnston AuthorDate: 2025-11-15 18:00:44 +0000 Commit: Mark Johnston CommitDate: 2025-11-19 16:17:08 +0000 inotify: Work around the vput() bug directly For 15.0, apply a minimal fix which at least ensures that inotify can't trigger the latent race described in commit 99cb3dca4773 ("vnode: Rework vput() to avoid holding the vnode lock after decrementing"). Reviewed by: olce, kib MFC after: 3 days Differential Revision: https://reviews.freebsd.org/D53774 (cherry picked from commit ebc17879f0885ca87644980f6275b9759b311eb3) --- sys/kern/vfs_inotify.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/sys/kern/vfs_inotify.c b/sys/kern/vfs_inotify.c index e60d8426ee42..fd1ef39b13f7 100644 --- a/sys/kern/vfs_inotify.c +++ b/sys/kern/vfs_inotify.c @@ -381,7 +381,14 @@ inotify_unlink_watch_locked(struct inotify_softc *sc, struct inotify_watch *watc static void inotify_free_watch(struct inotify_watch *watch) { - vrele(watch->vp); + /* + * Formally, we don't need to lock the vnode here. However, if we + * don't, and vrele() releases the last reference, it's possible the + * vnode will be recycled while a different thread holds the vnode lock. + * Work around this bug by acquiring the lock here. + */ + (void)vn_lock(watch->vp, LK_EXCLUSIVE | LK_RETRY); + vput(watch->vp); free(watch, M_INOTIFY); }