]> bbs.cooldavid.org Git - net-next-2.6.git/commitdiff
fanotify: allow userspace to override max queue depth
authorEric Paris <eparis@redhat.com>
Thu, 28 Oct 2010 21:21:57 +0000 (17:21 -0400)
committerEric Paris <eparis@redhat.com>
Thu, 28 Oct 2010 21:22:14 +0000 (17:22 -0400)
fanotify has a defualt max queue depth.  This patch allows processes which
explicitly request it to have an 'unlimited' queue depth.  These processes
need to be very careful to make sure they cannot fall far enough behind
that they OOM the box.  Thus this flag is gated on CAP_SYS_ADMIN.

Signed-off-by: Eric Paris <eparis@redhat.com>
fs/notify/fanotify/fanotify_user.c
include/linux/fanotify.h

index 04f2fe47b66a35be8df40127f8b1608419bc46f7..43d66d9b2eff13b4188c7379bc618ea474047805 100644 (file)
@@ -691,7 +691,14 @@ SYSCALL_DEFINE2(fanotify_init, unsigned int, flags, unsigned int, event_f_flags)
                goto out_put_group;
        }
 
-       group->max_events = FANOTIFY_DEFAULT_MAX_EVENTS;
+       if (flags & FAN_UNLIMITED_QUEUE) {
+               fd = -EPERM;
+               if (!capable(CAP_SYS_ADMIN))
+                       goto out_put_group;
+               group->max_events = UINT_MAX;
+       } else {
+               group->max_events = FANOTIFY_DEFAULT_MAX_EVENTS;
+       }
 
        fd = anon_inode_getfd("[fanotify]", &fanotify_fops, group, f_flags);
        if (fd < 0)
index ed479b6fef7b065b0d612dc9cfbbd3d8a78743cd..e37f559c95e1316dec36cc549c63234d671f062d 100644 (file)
 #define FAN_CLASS_NOTIF                0x00000000
 #define FAN_CLASS_CONTENT      0x00000004
 #define FAN_CLASS_PRE_CONTENT  0x00000008
-
 #define FAN_ALL_CLASS_BITS     (FAN_CLASS_NOTIF | FAN_CLASS_CONTENT | \
                                 FAN_CLASS_PRE_CONTENT)
 
+#define FAN_UNLIMITED_QUEUE    0x00000010
+
 #define FAN_ALL_INIT_FLAGS     (FAN_CLOEXEC | FAN_NONBLOCK | \
-                                FAN_ALL_CLASS_BITS)
+                                FAN_ALL_CLASS_BITS | FAN_UNLIMITED_QUEUE)
 
 /* flags used for fanotify_modify_mark() */
 #define FAN_MARK_ADD           0x00000001