Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

fanotify: Allow users to request FAN_FS_ERROR events

Wire up the FAN_FS_ERROR event in the fanotify_mark syscall, allowing
user space to request the monitoring of FAN_FS_ERROR events.

These events are limited to filesystem marks, so check it is the
case in the syscall handler.

Link: https://lore.kernel.org/r/20211025192746.66445-29-krisman@collabora.com
Reviewed-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Jan Kara <jack@suse.cz>
Signed-off-by: Gabriel Krisman Bertazi <krisman@collabora.com>
Signed-off-by: Jan Kara <jack@suse.cz>

authored by

Gabriel Krisman Bertazi and committed by
Jan Kara
9709bd54 130a3c74

+10 -2
+1 -1
fs/notify/fanotify/fanotify.c
··· 822 822 BUILD_BUG_ON(FAN_OPEN_EXEC_PERM != FS_OPEN_EXEC_PERM); 823 823 BUILD_BUG_ON(FAN_FS_ERROR != FS_ERROR); 824 824 825 - BUILD_BUG_ON(HWEIGHT32(ALL_FANOTIFY_EVENT_BITS) != 19); 825 + BUILD_BUG_ON(HWEIGHT32(ALL_FANOTIFY_EVENT_BITS) != 20); 826 826 827 827 mask = fanotify_group_event_mask(group, iter_info, mask, data, 828 828 data_type, dir);
+4
fs/notify/fanotify/fanotify_user.c
··· 1520 1520 group->priority == FS_PRIO_0) 1521 1521 goto fput_and_out; 1522 1522 1523 + if (mask & FAN_FS_ERROR && 1524 + mark_type != FAN_MARK_FILESYSTEM) 1525 + goto fput_and_out; 1526 + 1523 1527 /* 1524 1528 * Events that do not carry enough information to report 1525 1529 * event->fd require a group that supports reporting fid. Those
+5 -1
include/linux/fanotify.h
··· 91 91 #define FANOTIFY_INODE_EVENTS (FANOTIFY_DIRENT_EVENTS | \ 92 92 FAN_ATTRIB | FAN_MOVE_SELF | FAN_DELETE_SELF) 93 93 94 + /* Events that can only be reported with data type FSNOTIFY_EVENT_ERROR */ 95 + #define FANOTIFY_ERROR_EVENTS (FAN_FS_ERROR) 96 + 94 97 /* Events that user can request to be notified on */ 95 98 #define FANOTIFY_EVENTS (FANOTIFY_PATH_EVENTS | \ 96 - FANOTIFY_INODE_EVENTS) 99 + FANOTIFY_INODE_EVENTS | \ 100 + FANOTIFY_ERROR_EVENTS) 97 101 98 102 /* Events that require a permission response from user */ 99 103 #define FANOTIFY_PERM_EVENTS (FAN_OPEN_PERM | FAN_ACCESS_PERM | \