Skip to content

Commit

Permalink
fsnotify: implement a default maximum queue depth
Browse files Browse the repository at this point in the history
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 <eparis@redhat.com>
  • Loading branch information
Eric Paris committed Oct 28, 2010
1 parent 5322a59 commit 2529a0d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
4 changes: 4 additions & 0 deletions fs/notify/fanotify/fanotify_user.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

#include <asm/ioctls.h>

#define FANOTIFY_DEFAULT_MAX_EVENTS 16384

extern const struct fsnotify_ops fanotify_fsnotify_ops;

static struct kmem_cache *fanotify_mark_cache __read_mostly;
Expand Down Expand Up @@ -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;
Expand Down
1 change: 0 additions & 1 deletion include/linux/fanotify.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down

0 comments on commit 2529a0d

Please sign in to comment.