]> git.baikalelectronics.ru Git - kernel.git/commit
fs/exec.c: restrict initial stack space expansion to rlimit
authorMichael Neuling <mikey@neuling.org>
Wed, 10 Feb 2010 21:56:42 +0000 (13:56 -0800)
committerLinus Torvalds <torvalds@linux-foundation.org>
Thu, 11 Feb 2010 21:59:43 +0000 (13:59 -0800)
commitcf7b079448133e51132187341b9798b4f805293c
treeed159cfdf254f6b139ffc6b4a1e8437c6362b474
parent11b374698a70ed92b4012db49ee28aa3f1f4295b
fs/exec.c: restrict initial stack space expansion to rlimit

When reserving stack space for a new process, make sure we're not
attempting to expand the stack by more than rlimit allows.

This fixes a bug caused by b73cdb49c6a7dbb6b90e7b3f1f010ce2a7ffe481 ("mm:
variable length argument support") and unmasked by
fb485080fb71921f3ba4ea1a480eefc82ab8698f ("exec: setup_arg_pages() fails
to return errors").

This bug means that when limiting the stack to less the 20*PAGE_SIZE (eg.
80K on 4K pages or 'ulimit -s 79') all processes will be killed before
they start.  This is particularly bad with 64K pages, where a ulimit below
1280K will kill every process.

To test, do:

  'ulimit -s 15; ls'

before and after the patch is applied.  Before it's applied, 'ls' should
be killed.  After the patch is applied, 'ls' should no longer be killed.

A stack limit of 15KB since it's small enough to trigger 20*PAGE_SIZE.
Also 15KB not a multiple of PAGE_SIZE, which is a trickier case to handle
correctly with this code.

4K pages should be fine to test with.

[kosaki.motohiro@jp.fujitsu.com: cleanup]
[akpm@linux-foundation.org: cleanup cleanup]
Signed-off-by: Michael Neuling <mikey@neuling.org>
Signed-off-by: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
Cc: Americo Wang <xiyou.wangcong@gmail.com>
Cc: Anton Blanchard <anton@samba.org>
Cc: Oleg Nesterov <oleg@redhat.com>
Cc: James Morris <jmorris@namei.org>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Serge Hallyn <serue@us.ibm.com>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: <stable@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
fs/exec.c