git: e8c54222acdb - stable/14 - inotify: do not call into namei() with a locked vnode

Mark Johnston <[email protected]>
Newsgroups gmane.os.freebsd.devel.cvs.src
Message-ID <6a7353da.46d54.51c4cd26__21619.6417271689$1785943215$gmane$org@gitrepo.freebsd.org>
The branch stable/14 has been updated by markj:

URL: https://cgit.FreeBSD.org/src/commit/?id=e8c54222acdbb977c4164667627b6ee569d2eb90

commit e8c54222acdbb977c4164667627b6ee569d2eb90
Author:     Konstantin Belousov <[email protected]>
AuthorDate: 2025-07-10 07:15:13 +0000
Commit:     Mark Johnston <[email protected]>
CommitDate: 2026-08-05 15:15:16 +0000

    inotify: do not call into namei() with a locked vnode
    
    PR:     288127
    Reviewed by:    markj
    Fixes:  f1f230439fa48581f40a57f095627f667a9713c3
    Sponsored by:   The FreeBSD Foundation
    Differential revision:  https://reviews.freebsd.org/D51233
    
    (cherry picked from commit 63389aea24f15fe823c775960d77017f1a35f54b)
---
 sys/kern/vfs_inotify.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/sys/kern/vfs_inotify.c b/sys/kern/vfs_inotify.c
index 8c9e7599b888..46971c78440c 100644
--- a/sys/kern/vfs_inotify.c
+++ b/sys/kern/vfs_inotify.c
@@ -757,9 +757,11 @@ vn_inotify_add_watch(struct vnode *vp, struct inotify_softc *sc, uint32_t mask,
 			 * directory if it's specified as a vnode.
 			 */
 			vrefact(vp);
+			VOP_UNLOCK(vp);
 			NDINIT_ATVP(&nd, LOOKUP, NOFOLLOW, UIO_SYSSPACE,
 			    dp->d_name, vp);
 			error = namei(&nd);
+			vn_lock(vp, LK_SHARED | LK_RETRY);
 			if (error != 0)
 				break;
 			vn_irflag_set_cond(nd.ni_vp, VIRF_INOTIFY_PARENT);
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.