]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
fanotify: check FS_ISDIR flag instead of d_is_dir()
authorAmir Goldstein <amir73il@gmail.com>
Thu, 10 Jan 2019 17:04:41 +0000 (19:04 +0200)
committerJan Kara <jack@suse.cz>
Thu, 7 Feb 2019 15:38:36 +0000 (16:38 +0100)
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 <amir73il@gmail.com>
Signed-off-by: Jan Kara <jack@suse.cz>
fs/notify/fanotify/fanotify.c
include/linux/fsnotify.h

index 5558316036370242320fd22cb2840852b31ddf90..195fc9fe0150b0af8f28bfe4af59719949795646 100644 (file)
@@ -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;
 
index 9becae61002236fe4c088595dcfac473e3294764..09587e2860b53e5db5d280925eaebf8f2f421431 100644 (file)
@@ -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);
 }