Davide Libenzi 7ef9964e6d epoll: introduce resource usage limits
It has been thought that the per-user file descriptors limit would also
limit the resources that a normal user can request via the epoll
interface.  Vegard Nossum reported a very simple program (a modified
version attached) that can make a normal user to request a pretty large
amount of kernel memory, well within the its maximum number of fds.  To
solve such problem, default limits are now imposed, and /proc based
configuration has been introduced.  A new directory has been created,
named /proc/sys/fs/epoll/ and inside there, there are two configuration
points:

  max_user_instances = Maximum number of devices - per user

  max_user_watches   = Maximum number of "watched" fds - per user

The current default for "max_user_watches" limits the memory used by epoll
to store "watches", to 1/32 of the amount of the low RAM.  As example, a
256MB 32bit machine, will have "max_user_watches" set to roughly 90000.
That should be enough to not break existing heavy epoll users.  The
default value for "max_user_instances" is set to 128, that should be
enough too.

This also changes the userspace, because a new error code can now come out
from EPOLL_CTL_ADD (-ENOSPC).  The EMFILE from epoll_create() was already
listed, so that should be ok.

[akpm@linux-foundation.org: use get_current_user()]
Signed-off-by: Davide Libenzi <davidel@xmailserver.org>
Cc: Michael Kerrisk <mtk.manpages@gmail.com>
Cc: <stable@kernel.org>
Cc: Cyrill Gorcunov <gorcunov@gmail.com>
Reported-by: Vegard Nossum <vegardno@ifi.uio.no>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2008-12-01 19:55:24 -08:00
..
2007-10-23 13:47:31 -05:00
2006-11-30 04:58:40 +01:00
2005-11-22 09:14:30 -08:00
2006-10-03 22:54:15 +02:00
2005-04-16 15:20:36 -07:00
2005-04-16 15:20:36 -07:00
2005-04-16 15:20:36 -07:00
2006-10-03 22:47:42 +02:00
2007-10-22 08:13:21 -07:00
2006-10-03 22:52:05 +02:00
2008-10-08 19:44:18 -04:00
2006-12-30 10:56:45 -08:00
2008-06-27 09:39:53 +01:00
2006-04-25 15:44:04 -04:00
2005-04-16 15:20:36 -07:00
2007-07-31 15:39:38 -07:00
2007-05-09 08:58:15 +02:00
2008-02-08 09:22:38 -08:00
2008-10-30 11:38:45 -07:00
2005-04-16 15:20:36 -07:00
2008-09-02 19:21:37 -07:00
2008-12-01 14:46:49 -08:00
2008-07-26 12:00:05 -07:00
2005-04-16 15:20:36 -07:00
2008-04-25 11:56:37 -06:00
2005-04-16 15:20:36 -07:00
2006-11-30 04:58:40 +01:00
2006-12-07 08:39:44 -08:00
2007-02-12 09:48:40 -08:00
2008-11-06 15:41:21 -08:00
2008-10-30 11:38:45 -07:00
2008-11-12 17:17:17 -08:00