diff options
Diffstat (limited to 'fs')
-rw-r--r-- | fs/notify/fanotify/fanotify_user.c | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/fs/notify/fanotify/fanotify_user.c b/fs/notify/fanotify/fanotify_user.c index 7ebfca6a1427..258e8f635148 100644 --- a/fs/notify/fanotify/fanotify_user.c +++ b/fs/notify/fanotify/fanotify_user.c | |||
@@ -294,27 +294,37 @@ static ssize_t fanotify_read(struct file *file, char __user *buf, | |||
294 | } | 294 | } |
295 | 295 | ||
296 | ret = copy_event_to_user(group, kevent, buf); | 296 | ret = copy_event_to_user(group, kevent, buf); |
297 | if (unlikely(ret == -EOPENSTALE)) { | ||
298 | /* | ||
299 | * We cannot report events with stale fd so drop it. | ||
300 | * Setting ret to 0 will continue the event loop and | ||
301 | * do the right thing if there are no more events to | ||
302 | * read (i.e. return bytes read, -EAGAIN or wait). | ||
303 | */ | ||
304 | ret = 0; | ||
305 | } | ||
306 | |||
297 | /* | 307 | /* |
298 | * Permission events get queued to wait for response. Other | 308 | * Permission events get queued to wait for response. Other |
299 | * events can be destroyed now. | 309 | * events can be destroyed now. |
300 | */ | 310 | */ |
301 | if (!(kevent->mask & FAN_ALL_PERM_EVENTS)) { | 311 | if (!(kevent->mask & FAN_ALL_PERM_EVENTS)) { |
302 | fsnotify_destroy_event(group, kevent); | 312 | fsnotify_destroy_event(group, kevent); |
303 | if (ret < 0) | ||
304 | break; | ||
305 | } else { | 313 | } else { |
306 | #ifdef CONFIG_FANOTIFY_ACCESS_PERMISSIONS | 314 | #ifdef CONFIG_FANOTIFY_ACCESS_PERMISSIONS |
307 | if (ret < 0) { | 315 | if (ret <= 0) { |
308 | FANOTIFY_PE(kevent)->response = FAN_DENY; | 316 | FANOTIFY_PE(kevent)->response = FAN_DENY; |
309 | wake_up(&group->fanotify_data.access_waitq); | 317 | wake_up(&group->fanotify_data.access_waitq); |
310 | break; | 318 | } else { |
319 | spin_lock(&group->notification_lock); | ||
320 | list_add_tail(&kevent->list, | ||
321 | &group->fanotify_data.access_list); | ||
322 | spin_unlock(&group->notification_lock); | ||
311 | } | 323 | } |
312 | spin_lock(&group->notification_lock); | ||
313 | list_add_tail(&kevent->list, | ||
314 | &group->fanotify_data.access_list); | ||
315 | spin_unlock(&group->notification_lock); | ||
316 | #endif | 324 | #endif |
317 | } | 325 | } |
326 | if (ret < 0) | ||
327 | break; | ||
318 | buf += ret; | 328 | buf += ret; |
319 | count -= ret; | 329 | count -= ret; |
320 | } | 330 | } |