linux-stable/fs/notify
Amir Goldstein ceaf69f8ea fanotify: do not allow setting dirent events in mask of non-dir
Dirent events (create/delete/move) are only reported on watched
directory inodes, but in fanotify as well as in legacy inotify, it was
always allowed to set them on non-dir inode, which does not result in
any meaningful outcome.

Until kernel v5.17, dirent events in fanotify also differed from events
"on child" (e.g. FAN_OPEN) in the information provided in the event.
For example, FAN_OPEN could be set in the mask of a non-dir or the mask
of its parent and event would report the fid of the child regardless of
the marked object.
By contrast, FAN_DELETE is not reported if the child is marked and the
child fid was not reported in the events.

Since kernel v5.17, with fanotify group flag FAN_REPORT_TARGET_FID, the
fid of the child is reported with dirent events, like events "on child",
which may create confusion for users expecting the same behavior as
events "on child" when setting events in the mask on a child.

The desired semantics of setting dirent events in the mask of a child
are not clear, so for now, deny this action for a group initialized
with flag FAN_REPORT_TARGET_FID and for the new event FAN_RENAME.
We may relax this restriction in the future if we decide on the
semantics and implement them.

Fixes: d61fd650e9 ("fanotify: introduce group flag FAN_REPORT_TARGET_FID")
Fixes: 8cc3b1ccd9 ("fanotify: wire up FAN_RENAME event")
Link: https://lore.kernel.org/linux-fsdevel/20220505133057.zm5t6vumc4xdcnsg@quack3.lan/
Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Signed-off-by: Jan Kara <jack@suse.cz>
Link: https://lore.kernel.org/r/20220507080028.219826-1-amir73il@gmail.com
2022-05-09 11:49:09 +02:00
..
dnotify dnotify: move dnotify sysctl to dnotify.c 2022-01-22 08:33:34 +02:00
fanotify fanotify: do not allow setting dirent events in mask of non-dir 2022-05-09 11:49:09 +02:00
inotify inotify: simplify subdirectory registration with register_sysctl() 2022-01-22 08:33:35 +02:00
Kconfig treewide: Add SPDX license identifier - Makefile/Kconfig 2019-05-21 10:50:46 +02:00
Makefile License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
fdinfo.c fanotify: fix permission model of unprivileged group 2021-05-25 12:21:14 +02:00
fdinfo.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
fsnotify.c fsnotify: remove redundant parameter judgment 2022-03-14 09:05:25 +01:00
fsnotify.h fsnotify: count all objects with attached connectors 2021-08-11 13:50:48 +02:00
group.c fsnotify: clarify object type argument 2021-12-15 14:04:03 +01:00
mark.c fsnotify: fix merge with parent's ignored mask 2022-02-24 14:04:51 +01:00
notification.c fsnotify: Pass group argument to free_event 2021-10-27 12:34:18 +02:00