diff --git a/fs/backing-file.c b/fs/backing-file.c index ad573f5153c7..5780f60662d0 100644 --- a/fs/backing-file.c +++ b/fs/backing-file.c @@ -55,6 +55,17 @@ struct file *backing_file_open(const struct file *user_file, int flags, if (IS_ERR(f)) return f; + /* + * A user file that must not generate fsnotify events (e.g. the fd + * that fanotify creates for a permission event with + * dentry_open_nonotify()) must not generate them through its backing + * file either. Otherwise a listener watching the backing filesystem + * gets a nested permission event from its own read(2), which only + * another reader of the same group can answer. + */ + if (FMODE_FSNOTIFY_NONE(user_file->f_mode)) + file_set_fsnotify_mode(f, FMODE_NONOTIFY); + path_get(user_path); backing_file_set_user_path(f, user_path); error = vfs_open(real_path, f);