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
..
2008-11-27 10:11:53 +01:00
2008-11-30 10:03:37 -08:00
2008-10-16 11:21:30 -07:00
2008-03-30 14:18:41 -07:00
2008-09-14 16:25:35 +02:00
2008-11-19 18:49:58 -08:00
2008-07-28 14:37:38 +02:00
2007-07-16 09:05:50 -07:00
2008-08-13 12:55:10 +02:00
2008-09-02 19:21:40 -07:00
2008-11-30 10:03:37 -08:00
2008-11-30 11:00:15 -08:00
2008-10-21 15:59:53 +02:00
2008-11-18 15:08:56 +01:00
2008-11-11 11:57:22 +01:00
2008-11-05 10:30:14 +01:00
2007-07-16 09:05:50 -07:00
2008-11-06 08:41:56 +01:00
2008-10-16 11:21:31 -07:00
2008-02-06 10:41:02 -08:00
2008-11-19 18:49:57 -08:00
2008-07-25 10:53:45 -07:00
2008-10-16 11:21:47 -07:00
2008-10-16 11:21:31 -07:00