Skip to content

Commit 9709bd5

Browse files
krisman-at-collaborajankara
authored andcommitted
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/[email protected] Reviewed-by: Amir Goldstein <[email protected]> Reviewed-by: Jan Kara <[email protected]> Signed-off-by: Gabriel Krisman Bertazi <[email protected]> Signed-off-by: Jan Kara <[email protected]>
1 parent 130a3c7 commit 9709bd5

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

fs/notify/fanotify/fanotify.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -822,7 +822,7 @@ static int fanotify_handle_event(struct fsnotify_group *group, u32 mask,
822822
BUILD_BUG_ON(FAN_OPEN_EXEC_PERM != FS_OPEN_EXEC_PERM);
823823
BUILD_BUG_ON(FAN_FS_ERROR != FS_ERROR);
824824

825-
BUILD_BUG_ON(HWEIGHT32(ALL_FANOTIFY_EVENT_BITS) != 19);
825+
BUILD_BUG_ON(HWEIGHT32(ALL_FANOTIFY_EVENT_BITS) != 20);
826826

827827
mask = fanotify_group_event_mask(group, iter_info, mask, data,
828828
data_type, dir);

fs/notify/fanotify/fanotify_user.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1520,6 +1520,10 @@ static int do_fanotify_mark(int fanotify_fd, unsigned int flags, __u64 mask,
15201520
group->priority == FS_PRIO_0)
15211521
goto fput_and_out;
15221522

1523+
if (mask & FAN_FS_ERROR &&
1524+
mark_type != FAN_MARK_FILESYSTEM)
1525+
goto fput_and_out;
1526+
15231527
/*
15241528
* Events that do not carry enough information to report
15251529
* event->fd require a group that supports reporting fid. Those

include/linux/fanotify.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,13 @@ extern struct ctl_table fanotify_table[]; /* for sysctl */
9191
#define FANOTIFY_INODE_EVENTS (FANOTIFY_DIRENT_EVENTS | \
9292
FAN_ATTRIB | FAN_MOVE_SELF | FAN_DELETE_SELF)
9393

94+
/* Events that can only be reported with data type FSNOTIFY_EVENT_ERROR */
95+
#define FANOTIFY_ERROR_EVENTS (FAN_FS_ERROR)
96+
9497
/* Events that user can request to be notified on */
9598
#define FANOTIFY_EVENTS (FANOTIFY_PATH_EVENTS | \
96-
FANOTIFY_INODE_EVENTS)
99+
FANOTIFY_INODE_EVENTS | \
100+
FANOTIFY_ERROR_EVENTS)
97101

98102
/* Events that require a permission response from user */
99103
#define FANOTIFY_PERM_EVENTS (FAN_OPEN_PERM | FAN_ACCESS_PERM | \

0 commit comments

Comments
 (0)