From: Eric Paris Date: Thu, 28 Oct 2010 21:21:57 +0000 (-0400) Subject: fsnotify: implement a default maximum queue depth X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=2529a0df0f64dab1f60ae08e038b89c53a6b4c02;p=GitHub%2Fexynos8895%2Fandroid_kernel_samsung_universal8895.git fsnotify: implement a default maximum queue depth Currently fanotify has no maximum queue depth. Since fanotify is CAP_SYS_ADMIN only this does not pose a normal user DoS issue, but it certianly is possible that an fanotify listener which can't keep up could OOM the box. This patch implements a default 16k depth. This is the same default depth used by inotify, but given fanotify's better queue merging in many situations this queue will contain many additional useful events by comparison. Signed-off-by: Eric Paris --- diff --git a/fs/notify/fanotify/fanotify_user.c b/fs/notify/fanotify/fanotify_user.c index b265936e92d6..04f2fe47b66a 100644 --- a/fs/notify/fanotify/fanotify_user.c +++ b/fs/notify/fanotify/fanotify_user.c @@ -16,6 +16,8 @@ #include +#define FANOTIFY_DEFAULT_MAX_EVENTS 16384 + extern const struct fsnotify_ops fanotify_fsnotify_ops; static struct kmem_cache *fanotify_mark_cache __read_mostly; @@ -689,6 +691,8 @@ SYSCALL_DEFINE2(fanotify_init, unsigned int, flags, unsigned int, event_f_flags) goto out_put_group; } + group->max_events = FANOTIFY_DEFAULT_MAX_EVENTS; + fd = anon_inode_getfd("[fanotify]", &fanotify_fops, group, f_flags); if (fd < 0) goto out_put_group; diff --git a/include/linux/fanotify.h b/include/linux/fanotify.h index a97c96d28c07..ed479b6fef7b 100644 --- a/include/linux/fanotify.h +++ b/include/linux/fanotify.h @@ -12,7 +12,6 @@ #define FAN_EVENT_ON_CHILD 0x08000000 /* interested in child events */ -/* FIXME currently Q's have no limit.... */ #define FAN_Q_OVERFLOW 0x00004000 /* Event queued overflowed */ #define FAN_OPEN_PERM 0x00010000 /* File open in perm check */