Commit 2529a0df0f64dab1f60ae08e038b89c53a6b4c02
1 parent
5322a59f14
Exists in
master
and in
7 other branches
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 <eparis@redhat.com>
Showing 2 changed files with 4 additions and 1 deletions Side-by-side Diff
fs/notify/fanotify/fanotify_user.c
... | ... | @@ -16,6 +16,8 @@ |
16 | 16 | |
17 | 17 | #include <asm/ioctls.h> |
18 | 18 | |
19 | +#define FANOTIFY_DEFAULT_MAX_EVENTS 16384 | |
20 | + | |
19 | 21 | extern const struct fsnotify_ops fanotify_fsnotify_ops; |
20 | 22 | |
21 | 23 | static struct kmem_cache *fanotify_mark_cache __read_mostly; |
... | ... | @@ -688,6 +690,8 @@ |
688 | 690 | fd = -EINVAL; |
689 | 691 | goto out_put_group; |
690 | 692 | } |
693 | + | |
694 | + group->max_events = FANOTIFY_DEFAULT_MAX_EVENTS; | |
691 | 695 | |
692 | 696 | fd = anon_inode_getfd("[fanotify]", &fanotify_fops, group, f_flags); |
693 | 697 | if (fd < 0) |
include/linux/fanotify.h
... | ... | @@ -12,7 +12,6 @@ |
12 | 12 | |
13 | 13 | #define FAN_EVENT_ON_CHILD 0x08000000 /* interested in child events */ |
14 | 14 | |
15 | -/* FIXME currently Q's have no limit.... */ | |
16 | 15 | #define FAN_Q_OVERFLOW 0x00004000 /* Event queued overflowed */ |
17 | 16 | |
18 | 17 | #define FAN_OPEN_PERM 0x00010000 /* File open in perm check */ |