diff options
author | Lino Sanfilippo <LinoSanfilippo@gmx.de> | 2010-11-24 12:26:04 -0500 |
---|---|---|
committer | Eric Paris <eparis@redhat.com> | 2010-12-07 16:14:24 -0500 |
commit | fdbf3ceeb659f0b3c0e8dd79b331b7ac05910f1e (patch) | |
tree | 72ed0abad8e550cfa54d83c677d3a9baba28f110 | |
parent | e9a3854fd4ff3907e6c200a3980e19365ee695e9 (diff) |
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: Lino Sanfilippo <LinoSanfilippo@gmx.de>
Signed-off-by: Eric Paris <eparis@redhat.com>
-rw-r--r-- | fs/notify/fanotify/fanotify_user.c | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/fs/notify/fanotify/fanotify_user.c b/fs/notify/fanotify/fanotify_user.c index ca54957b1f61..dccd7985e65a 100644 --- a/fs/notify/fanotify/fanotify_user.c +++ b/fs/notify/fanotify/fanotify_user.c | |||
@@ -110,6 +110,8 @@ static int fill_event_metadata(struct fsnotify_group *group, | |||
110 | struct fanotify_event_metadata *metadata, | 110 | struct fanotify_event_metadata *metadata, |
111 | struct fsnotify_event *event) | 111 | struct fsnotify_event *event) |
112 | { | 112 | { |
113 | int ret = 0; | ||
114 | |||
113 | pr_debug("%s: group=%p metadata=%p event=%p\n", __func__, | 115 | pr_debug("%s: group=%p metadata=%p event=%p\n", __func__, |
114 | group, metadata, event); | 116 | group, metadata, event); |
115 | 117 | ||
@@ -117,9 +119,15 @@ static int fill_event_metadata(struct fsnotify_group *group, | |||
117 | metadata->vers = FANOTIFY_METADATA_VERSION; | 119 | metadata->vers = FANOTIFY_METADATA_VERSION; |
118 | metadata->mask = event->mask & FAN_ALL_OUTGOING_EVENTS; | 120 | metadata->mask = event->mask & FAN_ALL_OUTGOING_EVENTS; |
119 | metadata->pid = pid_vnr(event->tgid); | 121 | metadata->pid = pid_vnr(event->tgid); |
120 | metadata->fd = create_fd(group, event); | 122 | if (unlikely(event->mask & FAN_Q_OVERFLOW)) |
123 | metadata->fd = FAN_NOFD; | ||
124 | else { | ||
125 | metadata->fd = create_fd(group, event); | ||
126 | if (metadata->fd < 0) | ||
127 | ret = metadata->fd; | ||
128 | } | ||
121 | 129 | ||
122 | return metadata->fd; | 130 | return ret; |
123 | } | 131 | } |
124 | 132 | ||
125 | #ifdef CONFIG_FANOTIFY_ACCESS_PERMISSIONS | 133 | #ifdef CONFIG_FANOTIFY_ACCESS_PERMISSIONS |
@@ -261,7 +269,7 @@ static ssize_t copy_event_to_user(struct fsnotify_group *group, | |||
261 | if (ret < 0) | 269 | if (ret < 0) |
262 | goto out; | 270 | goto out; |
263 | 271 | ||
264 | fd = ret; | 272 | fd = fanotify_event_metadata.fd; |
265 | ret = prepare_for_access_response(group, event, fd); | 273 | ret = prepare_for_access_response(group, event, fd); |
266 | if (ret) | 274 | if (ret) |
267 | goto out_close_fd; | 275 | goto out_close_fd; |
@@ -275,7 +283,8 @@ static ssize_t copy_event_to_user(struct fsnotify_group *group, | |||
275 | out_kill_access_response: | 283 | out_kill_access_response: |
276 | remove_access_response(group, event, fd); | 284 | remove_access_response(group, event, fd); |
277 | out_close_fd: | 285 | out_close_fd: |
278 | sys_close(fd); | 286 | if (fd != FAN_NOFD) |
287 | sys_close(fd); | ||
279 | out: | 288 | out: |
280 | #ifdef CONFIG_FANOTIFY_ACCESS_PERMISSIONS | 289 | #ifdef CONFIG_FANOTIFY_ACCESS_PERMISSIONS |
281 | if (event->mask & FAN_ALL_PERM_EVENTS) { | 290 | if (event->mask & FAN_ALL_PERM_EVENTS) { |