summaryrefslogtreecommitdiff
path: root/fs/notify/notification.c
diff options
context:
space:
mode:
authorJan Kara <jack@suse.cz>2014-02-21 22:07:54 +0400
committerJan Kara <jack@suse.cz>2014-02-25 14:17:58 +0400
commit482ef06c5e946aae360f247dc69471ec031e09d2 (patch)
treeea36241c3ff91d0ec915e6825caa2f806db938ba /fs/notify/notification.c
parent2513190a926f093dbdc301c68e6ade0bcf293f9a (diff)
downloadlinux-482ef06c5e946aae360f247dc69471ec031e09d2.tar.xz
fanotify: Handle overflow in case of permission events
If the event queue overflows when we are handling permission event, we will never get response from userspace. So we must avoid waiting for it. Change fsnotify_add_notify_event() to return whether overflow has happened so that we can detect it in fanotify_handle_event() and act accordingly. Signed-off-by: Jan Kara <jack@suse.cz>
Diffstat (limited to 'fs/notify/notification.c')
-rw-r--r--fs/notify/notification.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/fs/notify/notification.c b/fs/notify/notification.c
index 6bec2f4918f9..6a4ba17c0395 100644
--- a/fs/notify/notification.c
+++ b/fs/notify/notification.c
@@ -80,7 +80,8 @@ void fsnotify_destroy_event(struct fsnotify_group *group,
/*
* Add an event to the group notification queue. The group can later pull this
* event off the queue to deal with. The function returns 0 if the event was
- * added to the queue, 1 if the event was merged with some other queued event.
+ * added to the queue, 1 if the event was merged with some other queued event,
+ * 2 if the queue of events has overflown.
*/
int fsnotify_add_notify_event(struct fsnotify_group *group,
struct fsnotify_event *event,
@@ -95,10 +96,14 @@ int fsnotify_add_notify_event(struct fsnotify_group *group,
mutex_lock(&group->notification_mutex);
if (group->q_len >= group->max_events) {
+ ret = 2;
/* Queue overflow event only if it isn't already queued */
- if (list_empty(&group->overflow_event.list))
- event = &group->overflow_event;
- ret = 1;
+ if (!list_empty(&group->overflow_event.list)) {
+ mutex_unlock(&group->notification_mutex);
+ return ret;
+ }
+ event = &group->overflow_event;
+ goto queue;
}
if (!list_empty(list) && merge) {
@@ -109,6 +114,7 @@ int fsnotify_add_notify_event(struct fsnotify_group *group,
}
}
+queue:
group->q_len++;
list_add_tail(&event->list, list);
mutex_unlock(&group->notification_mutex);