]> git.baikalelectronics.ru Git - kernel.git/commit
fsnotify: fix fsnotify hooks in pseudo filesystems
authorAmir Goldstein <amir73il@gmail.com>
Thu, 20 Jan 2022 21:53:05 +0000 (23:53 +0200)
committerJan Kara <jack@suse.cz>
Mon, 24 Jan 2022 13:17:02 +0000 (14:17 +0100)
commit0cc6e46e686834b8e45561e44420befdb6afe3a5
treef7480a05b92c6d395836774ed3a52fb4bb5a3404
parent73e2904dcc71c6b9d8fecffd22aa4b59fe19456d
fsnotify: fix fsnotify hooks in pseudo filesystems

Commit c2262d9f1121 ("fsnotify: move fsnotify_nameremove() hook out of
d_delete()") moved the fsnotify delete hook before d_delete() so fsnotify
will have access to a positive dentry.

This allowed a race where opening the deleted file via cached dentry
is now possible after receiving the IN_DELETE event.

To fix the regression in pseudo filesystems, convert d_delete() calls
to d_drop() (see commit c794f967bcf1 ("devpts_pty_kill(): don't bother
with d_delete()") and move the fsnotify hook after d_drop().

Add a missing fsnotify_unlink() hook in nfsdfs that was found during
the audit of fsnotify hooks in pseudo filesystems.

Note that the fsnotify hooks in simple_recursive_removal() follow
d_invalidate(), so they require no change.

Link: https://lore.kernel.org/r/20220120215305.282577-2-amir73il@gmail.com
Reported-by: Ivan Delalande <colona@arista.com>
Link: https://lore.kernel.org/linux-fsdevel/YeNyzoDM5hP5LtGW@visor/
Fixes: c2262d9f1121 ("fsnotify: move fsnotify_nameremove() hook out of d_delete()")
Cc: stable@vger.kernel.org # v5.3+
Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Signed-off-by: Jan Kara <jack@suse.cz>
fs/configfs/dir.c
fs/devpts/inode.c
fs/nfsd/nfsctl.c
net/sunrpc/rpc_pipe.c