Commit 7b278e69 authored by Chris Wright's avatar Chris Wright Committed by Linus Torvalds

[PATCH] a.out: error check on set_brk

It's possible for do_brk() to fail during set_brk() when exec'ing and
a.out.  This was noted with Florian's a.out binary and overcommit set to
0. 

Capture this error and terminate properly.
Signed-off-by: default avatarChris Wright <chrisw@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent e69a11be
......@@ -43,13 +43,18 @@ static struct linux_binfmt aout_format = {
.min_coredump = PAGE_SIZE
};
static void set_brk(unsigned long start, unsigned long end)
#define BAD_ADDR(x) ((unsigned long)(x) >= TASK_SIZE)
static int set_brk(unsigned long start, unsigned long end)
{
start = PAGE_ALIGN(start);
end = PAGE_ALIGN(end);
if (end <= start)
return;
do_brk(start, end - start);
if (end > start) {
unsigned long addr = do_brk(start, end - start);
if (BAD_ADDR(addr))
return addr;
}
return 0;
}
/*
......@@ -413,7 +418,11 @@ static int load_aout_binary(struct linux_binprm * bprm, struct pt_regs * regs)
beyond_if:
set_binfmt(&aout_format);
set_brk(current->mm->start_brk, current->mm->brk);
retval = set_brk(current->mm->start_brk, current->mm->brk);
if (retval < 0) {
send_sig(SIGKILL, current, 0);
return retval;
}
retval = setup_arg_pages(bprm, EXSTACK_DEFAULT);
if (retval < 0) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment