]> git.baikalelectronics.ru Git - kernel.git/commit
fanotify: fix fsnotify_prepare_user_wait() failure
authorMiklos Szeredi <mszeredi@redhat.com>
Mon, 30 Oct 2017 20:14:56 +0000 (21:14 +0100)
committerJan Kara <jack@suse.cz>
Tue, 31 Oct 2017 16:54:56 +0000 (17:54 +0100)
commit5c934a4e32a3cdcca2be19793c6c163414f04342
treeff7aab8765170e57aaa8eb117b9c899017b02fe6
parent8affd94346292135e7c227439546955d08fa5669
fanotify: fix fsnotify_prepare_user_wait() failure

If fsnotify_prepare_user_wait() fails, we leave the event on the
notification list.  Which will result in a warning in
fsnotify_destroy_event() and later use-after-free.

Instead of adding a new helper to remove the event from the list in this
case, I opted to move the prepare/finish up into fanotify_handle_event().

This will allow these to be moved further out into the generic code later,
and perhaps let us move to non-sleeping RCU.

Reviewed-by: Amir Goldstein <amir73il@gmail.com>
Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
Fixes: 93f130ca380f ("fanotify: Release SRCU lock when waiting for userspace response")
Cc: <stable@vger.kernel.org> # v4.12
Signed-off-by: Jan Kara <jack@suse.cz>
fs/notify/fanotify/fanotify.c