Skip to content

Commit

Permalink
fanotify: check FS_ISDIR flag instead of d_is_dir()
Browse files Browse the repository at this point in the history
All fsnotify hooks set the FS_ISDIR flag for events that happen
on directory victim inodes except for fsnotify_perm().

Add the missing FS_ISDIR flag in fsnotify_perm() hook and let
fanotify_group_event_mask() check the FS_ISDIR flag instead of
checking if path argument is a directory.

This is needed for fanotify support for event types that do not
carry path information.

Signed-off-by: Amir Goldstein <[email protected]>
Signed-off-by: Jan Kara <[email protected]>
  • Loading branch information
amir73il authored and jankara committed Feb 7, 2019
1 parent 0a20df7 commit 0321e03
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion fs/notify/fanotify/fanotify.c
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ static u32 fanotify_group_event_mask(struct fsnotify_iter_info *iter_info,
marks_ignored_mask |= mark->ignored_mask;
}

if (d_is_dir(path->dentry) &&
if (event_mask & FS_ISDIR &&
!(marks_mask & FS_ISDIR & ~marks_ignored_mask))
return 0;

Expand Down
3 changes: 3 additions & 0 deletions include/linux/fsnotify.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ static inline int fsnotify_perm(struct file *file, int mask)
fsnotify_mask = FS_ACCESS_PERM;
}

if (S_ISDIR(inode->i_mode))
fsnotify_mask |= FS_ISDIR;

return fsnotify_path(inode, path, fsnotify_mask);
}

Expand Down

0 comments on commit 0321e03

Please sign in to comment.