diff -uraN fs.orig/binfmt_aout.c fs/binfmt_aout.c --- fs.orig/binfmt_aout.c 2004-12-06 13:40:22.886079000 +0300 +++ fs/binfmt_aout.c 2004-12-06 13:52:16.506592320 +0300 @@ -43,13 +43,16 @@ NULL, THIS_MODULE, load_aout_binary, load_aout_library, aout_core_dump, PAGE_SIZE }; -static void set_brk(unsigned long start, unsigned long end) +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 ((unsigned long) addr >= TASK_SIZE) + return addr; + } + return 0; } /* @@ -452,9 +455,16 @@ #ifdef CONFIG_MOSIX /* if DEPUTY, the REMOTE already did "set_brk" in aout_remote_init_mm */ - if(!(current->mosix.dflags & DDEPUTY)) + if(!(current->mosix.dflags & DDEPUTY)) { +#endif /* CONFIG_MOSIX */ + retval = set_brk(current->mm->start_brk, current->mm->brk); + if (retval < 0) { + send_sig(SIGKILL, current, 0); + return retval; + } +#ifdef CONFIG_MOSIX + } #endif /* CONFIG_MOSIX */ - set_brk(current->mm->start_brk, current->mm->brk); #ifdef CONFIG_MOSIX if(current->mosix.dflags & DDEPUTY) diff -uraN fs.orig/exec.c fs/exec.c --- fs.orig/exec.c 2004-12-06 13:40:22.912075000 +0300 +++ fs/exec.c 2004-12-06 13:50:08.776010320 +0300 @@ -357,6 +357,7 @@ down_write(¤t->mm->mmap_sem); { + struct vm_area_struct *vma; mpnt->vm_mm = current->mm; mpnt->vm_start = PAGE_MASK & (unsigned long) bprm->p; mpnt->vm_end = STACK_TOP; @@ -366,6 +367,12 @@ mpnt->vm_pgoff = 0; mpnt->vm_file = NULL; mpnt->vm_private_data = (void *) 0; + vma = find_vma(current->mm, mpnt->vm_start); + if (vma) { + up_write(¤t->mm->mmap_sem); + kmem_cache_free(vm_area_cachep, mpnt); + return -ENOMEM; + } insert_vm_struct(current->mm, mpnt); current->mm->total_vm = (mpnt->vm_end - mpnt->vm_start) >> PAGE_SHIFT; }