|
Message-ID: <20100827220258.GF4703@outflux.net> Date: Fri, 27 Aug 2010 15:02:58 -0700 From: Kees Cook <kees.cook@...onical.com> To: linux-kernel@...r.kernel.org Cc: oss-security@...ts.openwall.com, Al Viro <viro@...iv.linux.org.uk>, Andrew Morton <akpm@...ux-foundation.org>, Oleg Nesterov <oleg@...hat.com>, KOSAKI Motohiro <kosaki.motohiro@...fujitsu.com>, Neil Horman <nhorman@...driver.com>, Roland McGrath <roland@...hat.com>, linux-fsdevel@...r.kernel.org Subject: [PATCH] exec argument expansion can inappropriately trigger OOM-killer Brad Spengler published a local memory-allocation DoS that evades the OOM-killer (though not the virtual memory RLIMIT): http://www.grsecurity.net/~spender/64bit_dos.c The recent changes to create a stack guard page helps slightly to discourage this attack, but it is not sufficient. Compiling it statically moves the libraries out of the way, allowing the stack VMA to fill the entire TASK_SIZE. There are two issues: 1) the OOM killer doesn't notice this argv memory explosion 2) the argv expansion does not check if rlim[RLIMIT_STACK].rlim_cur is -1. I figure a quick solution for #2 would be the following patch. However, running multiple copies of this program could result in similar OOM behavior, so issue #1 still needs a solution. Reported-by: Brad Spengler <spender@...ecurity.net> Signed-off-by: Kees Cook <kees.cook@...onical.com> --- fs/exec.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-) diff --git a/fs/exec.c b/fs/exec.c index dab85ec..be40063 100644 --- a/fs/exec.c +++ b/fs/exec.c @@ -194,7 +194,8 @@ static struct page *get_arg_page(struct linux_binprm *bprm, unsigned long pos, * to work from. */ rlim = current->signal->rlim; - if (size > ACCESS_ONCE(rlim[RLIMIT_STACK].rlim_cur) / 4) { + if (size > ACCESS_ONCE(rlim[RLIMIT_STACK].rlim_cur) / 4 || + size > TASK_SIZE / 4) { put_page(page); return NULL; } -- 1.7.1 -- Kees Cook Ubuntu Security Team
Powered by blists - more mailing lists
Please check out the Open Source Software Security Wiki, which is counterpart to this mailing list.
Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.