linux-stable/fs/notify
Jan Kara 2d65c97777 inotify: Avoid reporting event with invalid wd
commit c915d8f591 upstream.

When inotify_freeing_mark() races with inotify_handle_inode_event() it
can happen that inotify_handle_inode_event() sees that i_mark->wd got
already reset to -1 and reports this value to userspace which can
confuse the inotify listener. Avoid the problem by validating that wd is
sensible (and pretend the mark got removed before the event got
generated otherwise).

CC: stable@vger.kernel.org
Fixes: 7e790dd5fc ("inotify: fix error paths in inotify_update_watch")
Message-Id: <20230424163219.9250-1-jack@suse.cz>
Reported-by: syzbot+4a06d4373fd52f0b2f9c@syzkaller.appspotmail.com
Reviewed-by: Amir Goldstein <amir73il@gmail.com>
Signed-off-by: Jan Kara <jack@suse.cz>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2023-05-17 11:48:14 +02:00
..
dnotify fsnotify: generalize handle_inode_event() 2020-12-30 11:54:18 +01:00
fanotify fanotify: Fix stale file descriptor in copy_event_to_user() 2022-02-05 12:37:56 +01:00
inotify inotify: Avoid reporting event with invalid wd 2023-05-17 11:48:14 +02:00
fdinfo.c inotify: show inotify mask flags in proc fdinfo 2022-06-09 10:21:03 +02:00
fdinfo.h
fsnotify.c fsnotify: fix events reported to watching parent and child 2020-12-30 11:54:18 +01:00
fsnotify.h
group.c
Kconfig
Makefile
mark.c fsnotify: fix wrong lockdep annotations 2022-06-09 10:21:03 +02:00
notification.c