Commit 80af2588 authored by Eric Paris's avatar Eric Paris

fanotify: groups can specify their f_flags for new fd

Currently fanotify fds opened for thier listeners are done with f_flags
equal to O_RDONLY | O_LARGEFILE.  This patch instead takes f_flags from the
fanotify_init syscall and uses those when opening files in the context of
the listener.
Signed-off-by: default avatarEric Paris <eparis@redhat.com>
parent 20dee624
...@@ -81,7 +81,7 @@ static int create_fd(struct fsnotify_group *group, struct fsnotify_event *event) ...@@ -81,7 +81,7 @@ static int create_fd(struct fsnotify_group *group, struct fsnotify_event *event)
* are NULL; That's fine, just don't call dentry open */ * are NULL; That's fine, just don't call dentry open */
if (dentry && mnt) if (dentry && mnt)
new_file = dentry_open(dentry, mnt, new_file = dentry_open(dentry, mnt,
O_RDONLY | O_LARGEFILE | FMODE_NONOTIFY, group->fanotify_data.f_flags | FMODE_NONOTIFY,
current_cred()); current_cred());
else else
new_file = ERR_PTR(-EOVERFLOW); new_file = ERR_PTR(-EOVERFLOW);
...@@ -625,9 +625,6 @@ SYSCALL_DEFINE2(fanotify_init, unsigned int, flags, unsigned int, event_f_flags) ...@@ -625,9 +625,6 @@ SYSCALL_DEFINE2(fanotify_init, unsigned int, flags, unsigned int, event_f_flags)
pr_debug("%s: flags=%d event_f_flags=%d\n", pr_debug("%s: flags=%d event_f_flags=%d\n",
__func__, flags, event_f_flags); __func__, flags, event_f_flags);
if (event_f_flags)
return -EINVAL;
if (!capable(CAP_SYS_ADMIN)) if (!capable(CAP_SYS_ADMIN))
return -EACCES; return -EACCES;
...@@ -645,6 +642,7 @@ SYSCALL_DEFINE2(fanotify_init, unsigned int, flags, unsigned int, event_f_flags) ...@@ -645,6 +642,7 @@ SYSCALL_DEFINE2(fanotify_init, unsigned int, flags, unsigned int, event_f_flags)
if (IS_ERR(group)) if (IS_ERR(group))
return PTR_ERR(group); return PTR_ERR(group);
group->fanotify_data.f_flags = event_f_flags;
#ifdef CONFIG_FANOTIFY_ACCESS_PERMISSIONS #ifdef CONFIG_FANOTIFY_ACCESS_PERMISSIONS
mutex_init(&group->fanotify_data.access_mutex); mutex_init(&group->fanotify_data.access_mutex);
init_waitqueue_head(&group->fanotify_data.access_waitq); init_waitqueue_head(&group->fanotify_data.access_waitq);
......
...@@ -169,14 +169,17 @@ struct fsnotify_group { ...@@ -169,14 +169,17 @@ struct fsnotify_group {
struct user_struct *user; struct user_struct *user;
} inotify_data; } inotify_data;
#endif #endif
#ifdef CONFIG_FANOTIFY_ACCESS_PERMISSIONS #ifdef CONFIG_FANOTIFY
struct fanotify_group_private_data { struct fanotify_group_private_data {
#ifdef CONFIG_FANOTIFY_ACCESS_PERMISSIONS
/* allows a group to block waiting for a userspace response */ /* allows a group to block waiting for a userspace response */
struct mutex access_mutex; struct mutex access_mutex;
struct list_head access_list; struct list_head access_list;
wait_queue_head_t access_waitq; wait_queue_head_t access_waitq;
#endif /* CONFIG_FANOTIFY_ACCESS_PERMISSIONS */
int f_flags;
} fanotify_data; } fanotify_data;
#endif #endif /* CONFIG_FANOTIFY */
}; };
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment