Page MenuHomeFreeBSD

inotify: Avoid calling vrele() with a namecache mutex held
ClosedPublic

Authored by markj on Fri, Aug 1, 6:23 PM.
Tags
None
Referenced Files
Unknown Object (File)
Thu, Aug 14, 10:48 PM
Unknown Object (File)
Thu, Aug 14, 4:29 PM
Unknown Object (File)
Wed, Aug 13, 12:08 PM
Unknown Object (File)
Tue, Aug 12, 9:11 PM
Unknown Object (File)
Tue, Aug 5, 3:46 PM
Unknown Object (File)
Mon, Aug 4, 2:49 PM
Unknown Object (File)
Mon, Aug 4, 1:01 PM
Unknown Object (File)
Mon, Aug 4, 10:46 AM
Subscribers

Details

Summary

In cache_vop_inotify(), we call inotify_log() with a namecache hash lock
held. inotify_log() looks at all watches registered with the vnode to
see if any of them are interested in the event. In some cases, we have
to detach and free the watch after logging the event. This means we
must vrele() the watched vnode, and this must not be done while a
non-sleepable lock held.

Previously, I deferred the vrele() to until the inotify softc and vnode
pollinfo locks were dropped. However, this is not enough since we may
still be holding the aforementioned namecache lock. Go further and use
a taskqueue thread to release vnode references. Introduce a set of
detached watches, and queue a threaded task which releases the vnode
reference.

Reported by: syzbot+c128f121cb22df95559b@syzkaller.appspotmail.com
Fixes: f1f230439fa4 ("vfs: Initial revision of inotify")

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped
Build Status
Buildable 65903
Build 62786: arc lint + arc unit

Event Timeline

markj requested review of this revision.Fri, Aug 1, 6:23 PM
sys/kern/vfs_inotify.c
172

Why this needs to be tree and not e.g. just a list?

markj marked an inline comment as done.

Use tailq linkage instead.

This revision is now accepted and ready to land.Fri, Aug 1, 8:04 PM