Commit fdbf3cee authored by Lino Sanfilippo's avatar Lino Sanfilippo Committed by Eric Paris

fanotify: Dont try to open a file descriptor for the overflow event

We should not try to open a file descriptor for the overflow event since this
will always fail.
Signed-off-by: default avatarLino Sanfilippo <LinoSanfilippo@gmx.de>
Signed-off-by: default avatarEric Paris <eparis@redhat.com>
parent e9a3854f
...@@ -110,6 +110,8 @@ static int fill_event_metadata(struct fsnotify_group *group, ...@@ -110,6 +110,8 @@ static int fill_event_metadata(struct fsnotify_group *group,
struct fanotify_event_metadata *metadata, struct fanotify_event_metadata *metadata,
struct fsnotify_event *event) struct fsnotify_event *event)
{ {
int ret = 0;
pr_debug("%s: group=%p metadata=%p event=%p\n", __func__, pr_debug("%s: group=%p metadata=%p event=%p\n", __func__,
group, metadata, event); group, metadata, event);
...@@ -117,9 +119,15 @@ static int fill_event_metadata(struct fsnotify_group *group, ...@@ -117,9 +119,15 @@ static int fill_event_metadata(struct fsnotify_group *group,
metadata->vers = FANOTIFY_METADATA_VERSION; metadata->vers = FANOTIFY_METADATA_VERSION;
metadata->mask = event->mask & FAN_ALL_OUTGOING_EVENTS; metadata->mask = event->mask & FAN_ALL_OUTGOING_EVENTS;
metadata->pid = pid_vnr(event->tgid); metadata->pid = pid_vnr(event->tgid);
if (unlikely(event->mask & FAN_Q_OVERFLOW))
metadata->fd = FAN_NOFD;
else {
metadata->fd = create_fd(group, event); metadata->fd = create_fd(group, event);
if (metadata->fd < 0)
ret = metadata->fd;
}
return metadata->fd; return ret;
} }
#ifdef CONFIG_FANOTIFY_ACCESS_PERMISSIONS #ifdef CONFIG_FANOTIFY_ACCESS_PERMISSIONS
...@@ -261,7 +269,7 @@ static ssize_t copy_event_to_user(struct fsnotify_group *group, ...@@ -261,7 +269,7 @@ static ssize_t copy_event_to_user(struct fsnotify_group *group,
if (ret < 0) if (ret < 0)
goto out; goto out;
fd = ret; fd = fanotify_event_metadata.fd;
ret = prepare_for_access_response(group, event, fd); ret = prepare_for_access_response(group, event, fd);
if (ret) if (ret)
goto out_close_fd; goto out_close_fd;
...@@ -275,6 +283,7 @@ static ssize_t copy_event_to_user(struct fsnotify_group *group, ...@@ -275,6 +283,7 @@ static ssize_t copy_event_to_user(struct fsnotify_group *group,
out_kill_access_response: out_kill_access_response:
remove_access_response(group, event, fd); remove_access_response(group, event, fd);
out_close_fd: out_close_fd:
if (fd != FAN_NOFD)
sys_close(fd); sys_close(fd);
out: out:
#ifdef CONFIG_FANOTIFY_ACCESS_PERMISSIONS #ifdef CONFIG_FANOTIFY_ACCESS_PERMISSIONS
......
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