]> git.itanic.dy.fi Git - linux-stable/commit
inotify: Avoid reporting event with invalid wd
authorJan Kara <jack@suse.cz>
Mon, 24 Apr 2023 16:32:19 +0000 (18:32 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 17 May 2023 11:58:59 +0000 (13:58 +0200)
commitfb3294998489d39835006240e9c6e6b2ac62022e
tree9f0b18d3d921e66580cb5068e3dca07b45eecbf4
parent4a44bfc030fdc9d6f72919cbbdb02bc29ee38b7d
inotify: Avoid reporting event with invalid wd

commit c915d8f5918bea7c3962b09b8884ca128bfd9b0c 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: 7e790dd5fc93 ("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>
fs/notify/inotify/inotify_fsnotify.c