Commit 5dd03f55 authored by Eric Paris's avatar Eric Paris
Browse files

fanotify: allow userspace to override max queue depth



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: default avatarEric Paris <eparis@redhat.com>
parent 2529a0df
Loading
Loading
Loading
Loading
+8 −1
Original line number Original line Diff line number Diff line
@@ -691,7 +691,14 @@ SYSCALL_DEFINE2(fanotify_init, unsigned int, flags, unsigned int, event_f_flags)
		goto out_put_group;
		goto out_put_group;
	}
	}


	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;
		group->max_events = FANOTIFY_DEFAULT_MAX_EVENTS;
	}


	fd = anon_inode_getfd("[fanotify]", &fanotify_fops, group, f_flags);
	fd = anon_inode_getfd("[fanotify]", &fanotify_fops, group, f_flags);
	if (fd < 0)
	if (fd < 0)
+3 −2
Original line number Original line Diff line number Diff line
@@ -28,12 +28,13 @@
#define FAN_CLASS_NOTIF		0x00000000
#define FAN_CLASS_NOTIF		0x00000000
#define FAN_CLASS_CONTENT	0x00000004
#define FAN_CLASS_CONTENT	0x00000004
#define FAN_CLASS_PRE_CONTENT	0x00000008
#define FAN_CLASS_PRE_CONTENT	0x00000008

#define FAN_ALL_CLASS_BITS	(FAN_CLASS_NOTIF | FAN_CLASS_CONTENT | \
#define FAN_ALL_CLASS_BITS	(FAN_CLASS_NOTIF | FAN_CLASS_CONTENT | \
				 FAN_CLASS_PRE_CONTENT)
				 FAN_CLASS_PRE_CONTENT)


#define FAN_UNLIMITED_QUEUE	0x00000010

#define FAN_ALL_INIT_FLAGS	(FAN_CLOEXEC | FAN_NONBLOCK | \
#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() */
/* flags used for fanotify_modify_mark() */
#define FAN_MARK_ADD		0x00000001
#define FAN_MARK_ADD		0x00000001