diff options
-rw-r--r-- | fs/notify/fanotify/fanotify_user.c | 40 |
1 files changed, 19 insertions, 21 deletions
diff --git a/fs/notify/fanotify/fanotify_user.c b/fs/notify/fanotify/fanotify_user.c index f1097f56137e..4e565c814309 100644 --- a/fs/notify/fanotify/fanotify_user.c +++ b/fs/notify/fanotify/fanotify_user.c | |||
@@ -199,7 +199,7 @@ static ssize_t copy_event_to_user(struct fsnotify_group *group, | |||
199 | 199 | ||
200 | ret = fill_event_metadata(group, &fanotify_event_metadata, event, &f); | 200 | ret = fill_event_metadata(group, &fanotify_event_metadata, event, &f); |
201 | if (ret < 0) | 201 | if (ret < 0) |
202 | goto out; | 202 | return ret; |
203 | 203 | ||
204 | fd = fanotify_event_metadata.fd; | 204 | fd = fanotify_event_metadata.fd; |
205 | ret = -EFAULT; | 205 | ret = -EFAULT; |
@@ -208,16 +208,8 @@ static ssize_t copy_event_to_user(struct fsnotify_group *group, | |||
208 | goto out_close_fd; | 208 | goto out_close_fd; |
209 | 209 | ||
210 | #ifdef CONFIG_FANOTIFY_ACCESS_PERMISSIONS | 210 | #ifdef CONFIG_FANOTIFY_ACCESS_PERMISSIONS |
211 | if (event->mask & FAN_ALL_PERM_EVENTS) { | 211 | if (event->mask & FAN_ALL_PERM_EVENTS) |
212 | struct fanotify_perm_event_info *pevent; | 212 | FANOTIFY_PE(event)->fd = fd; |
213 | |||
214 | pevent = FANOTIFY_PE(event); | ||
215 | pevent->fd = fd; | ||
216 | spin_lock(&group->fanotify_data.access_lock); | ||
217 | list_add_tail(&pevent->fae.fse.list, | ||
218 | &group->fanotify_data.access_list); | ||
219 | spin_unlock(&group->fanotify_data.access_lock); | ||
220 | } | ||
221 | #endif | 213 | #endif |
222 | 214 | ||
223 | if (fd != FAN_NOFD) | 215 | if (fd != FAN_NOFD) |
@@ -229,13 +221,6 @@ out_close_fd: | |||
229 | put_unused_fd(fd); | 221 | put_unused_fd(fd); |
230 | fput(f); | 222 | fput(f); |
231 | } | 223 | } |
232 | out: | ||
233 | #ifdef CONFIG_FANOTIFY_ACCESS_PERMISSIONS | ||
234 | if (event->mask & FAN_ALL_PERM_EVENTS) { | ||
235 | FANOTIFY_PE(event)->response = FAN_DENY; | ||
236 | wake_up(&group->fanotify_data.access_waitq); | ||
237 | } | ||
238 | #endif | ||
239 | return ret; | 224 | return ret; |
240 | } | 225 | } |
241 | 226 | ||
@@ -300,10 +285,23 @@ static ssize_t fanotify_read(struct file *file, char __user *buf, | |||
300 | * Permission events get queued to wait for response. Other | 285 | * Permission events get queued to wait for response. Other |
301 | * events can be destroyed now. | 286 | * events can be destroyed now. |
302 | */ | 287 | */ |
303 | if (!(kevent->mask & FAN_ALL_PERM_EVENTS)) | 288 | if (!(kevent->mask & FAN_ALL_PERM_EVENTS)) { |
304 | fsnotify_destroy_event(group, kevent); | 289 | fsnotify_destroy_event(group, kevent); |
305 | if (ret < 0) | 290 | if (ret < 0) |
306 | break; | 291 | break; |
292 | } else { | ||
293 | #ifdef CONFIG_FANOTIFY_ACCESS_PERMISSIONS | ||
294 | if (ret < 0) { | ||
295 | FANOTIFY_PE(kevent)->response = FAN_DENY; | ||
296 | wake_up(&group->fanotify_data.access_waitq); | ||
297 | break; | ||
298 | } | ||
299 | spin_lock(&group->fanotify_data.access_lock); | ||
300 | list_add_tail(&kevent->list, | ||
301 | &group->fanotify_data.access_list); | ||
302 | spin_unlock(&group->fanotify_data.access_lock); | ||
303 | #endif | ||
304 | } | ||
307 | buf += ret; | 305 | buf += ret; |
308 | count -= ret; | 306 | count -= ret; |
309 | } | 307 | } |