]> bbs.cooldavid.org Git - net-next-2.6.git/commit
rlimits: implement prlimit64 syscall
authorJiri Slaby <jslaby@suse.cz>
Tue, 4 May 2010 16:03:50 +0000 (18:03 +0200)
committerJiri Slaby <jirislaby@gmail.com>
Fri, 16 Jul 2010 07:48:48 +0000 (09:48 +0200)
commitc022a0acad534fd5f5d5f17280f6d4d135e74e81
treeb67cb6f1dd5ca1625b3699577b781d8058a37e93
parentb95183453af2ed14a5c7027e58049c9fd17e92ce
rlimits: implement prlimit64 syscall

This patch adds the code to support the sys_prlimit64 syscall which
modifies-and-returns the rlim values of a selected process atomically.
The first parameter, pid, being 0 means current process.

Unlike the current implementation, it is a generic interface,
architecture indepentent so that we needn't handle compat stuff
anymore. In the future, after glibc start to use this we can deprecate
sys_setrlimit and sys_getrlimit in favor to clean up the code finally.

It also adds a possibility of changing limits of other processes. We
check the user's permissions to do that and if it succeeds, the new
limits are propagated online. This is good for large scale
applications such as SAP or databases where administrators need to
change limits time by time (e.g. on crashes increase core size). And
it is unacceptable to restart the service.

For safety, all rlim users now either use accessors or doesn't need
them due to
- locking
- the fact a process was just forked and nobody else knows about it
  yet (and nobody can't thus read/write limits)
hence it is safe to modify limits now.

The limitation is that we currently stay at ulong internal
representation. So the rlim64_is_infinity check is used where value is
compared against ULONG_MAX on 32-bit which is the maximum value there.

And since internally the limits are held in struct rlimit, converters
which are used before and after do_prlimit call in sys_prlimit64 are
introduced.

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
include/linux/syscalls.h
kernel/sys.c