diff -Nur linux-2.4.17.old/fs/exec.c linux-2.4.17.new/fs/exec.c --- linux-2.4.17.old/fs/exec.c Sat Jan 19 16:00:53 2002 +++ linux-2.4.17.new/fs/exec.c Sat Jan 19 17:55:26 2002 @@ -572,6 +572,19 @@ permission(bprm->file->f_dentry->d_inode,MAY_READ)) current->mm->dumpable = 0; + if (!current->mm->dumpable) { + /* FIXME FIXME FIXME! This is probably too late. + * We need to use RLIM_INFINITY while setting up + * the executable, but at that time dumpable is + * not yet computed. We probably need to reorder + * parts of the code. + */ + current->rlim[RLIMIT_TUMB].rlim_cur=RLIM_INFINITY; + current->rlim[RLIMIT_TUMB].rlim_max=RLIM_INFINITY; + current->mm->task_unmapped_base=vm_task_unmapped_base; + } + current->rlim[RLIMIT_TUMB].rlim_cur=current->rlim[RLIMIT_TUMB].rlim_max; + /* An exec changes our domain. We are no longer part of the thread group */ diff -Nur linux-2.4.17.old/include/asm-i386/resource.h linux-2.4.17.new/include/asm-i386/resource.h --- linux-2.4.17.old/include/asm-i386/resource.h Sat Jan 19 16:02:51 2002 +++ linux-2.4.17.new/include/asm-i386/resource.h Sat Jan 19 16:04:56 2002 @@ -16,8 +16,9 @@ #define RLIMIT_MEMLOCK 8 /* max locked-in-memory address space */ #define RLIMIT_AS 9 /* address space limit */ #define RLIMIT_LOCKS 10 /* maximum file locks held */ +#define RLIMIT_TUMB 11 /* task_unmapped_base */ -#define RLIM_NLIMITS 11 +#define RLIM_NLIMITS 12 /* * SuS says limits have to be unsigned. @@ -39,6 +40,7 @@ { INR_OPEN, INR_OPEN }, \ { RLIM_INFINITY, RLIM_INFINITY }, \ { RLIM_INFINITY, RLIM_INFINITY }, \ + { RLIM_INFINITY, RLIM_INFINITY }, \ { RLIM_INFINITY, RLIM_INFINITY }, \ } diff -Nur linux-2.4.17.old/include/linux/mm.h linux-2.4.17.new/include/linux/mm.h --- linux-2.4.17.old/include/linux/mm.h Sat Jan 19 16:02:21 2002 +++ linux-2.4.17.new/include/linux/mm.h Sat Jan 19 16:04:41 2002 @@ -115,6 +115,8 @@ extern int vm_min_readahead; extern int vm_max_readahead; +extern int vm_task_unmapped_base; + /* * mapping from the currently active vm_flags protection bits (the * low four bits) to a page protection mask.. diff -Nur linux-2.4.17.old/include/linux/sched.h linux-2.4.17.new/include/linux/sched.h --- linux-2.4.17.old/include/linux/sched.h Sat Jan 19 16:02:15 2002 +++ linux-2.4.17.new/include/linux/sched.h Sat Jan 19 16:04:34 2002 @@ -227,6 +227,8 @@ unsigned dumpable:1; + unsigned long task_unmapped_base; + /* Architecture-specific MM context */ mm_context_t context; }; diff -Nur linux-2.4.17.old/include/linux/sysctl.h linux-2.4.17.new/include/linux/sysctl.h --- linux-2.4.17.old/include/linux/sysctl.h Sat Jan 19 16:02:34 2002 +++ linux-2.4.17.new/include/linux/sysctl.h Sat Jan 19 16:04:47 2002 @@ -140,8 +140,9 @@ VM_PAGERDAEMON=8, /* struct: Control kswapd behaviour */ VM_PGT_CACHE=9, /* struct: Set page table cache parameters */ VM_PAGE_CLUSTER=10, /* int: set number of pages to swap together */ - VM_MIN_READAHEAD=12, /* Min file readahead */ - VM_MAX_READAHEAD=13 /* Max file readahead */ + VM_MIN_READAHEAD=12, /* Min file readahead */ + VM_MAX_READAHEAD=13, /* Max file readahead */ + VM_TASK_UNMAPPED_BASE=14/* task_unmapped_base */ }; diff -Nur linux-2.4.17.old/kernel/fork.c linux-2.4.17.new/kernel/fork.c --- linux-2.4.17.old/kernel/fork.c Sat Jan 19 16:01:50 2002 +++ linux-2.4.17.new/kernel/fork.c Sat Jan 19 17:54:44 2002 @@ -214,6 +214,9 @@ static struct mm_struct * mm_init(struct mm_struct * mm) { + int base=current->rlim[RLIMIT_TUMB].rlim_cur; + if (base==RLIM_INFINITY) base=vm_task_unmapped_base; + mm->task_unmapped_base=base; atomic_set(&mm->mm_users, 1); atomic_set(&mm->mm_count, 1); init_rwsem(&mm->mmap_sem); diff -Nur linux-2.4.17.old/kernel/sys.c linux-2.4.17.new/kernel/sys.c --- linux-2.4.17.old/kernel/sys.c Sat Jan 19 16:01:54 2002 +++ linux-2.4.17.new/kernel/sys.c Sat Jan 19 16:04:21 2002 @@ -1121,10 +1121,12 @@ if(copy_from_user(&new_rlim, rlim, sizeof(*rlim))) return -EFAULT; old_rlim = current->rlim + resource; - if (((new_rlim.rlim_cur > old_rlim->rlim_max) || - (new_rlim.rlim_max > old_rlim->rlim_max)) && - !capable(CAP_SYS_RESOURCE)) - return -EPERM; + if (resource != RLIMIT_TUMB) { + if (((new_rlim.rlim_cur > old_rlim->rlim_max) || + (new_rlim.rlim_max > old_rlim->rlim_max)) && + !capable(CAP_SYS_RESOURCE)) + return -EPERM; + } if (resource == RLIMIT_NOFILE) { if (new_rlim.rlim_cur > NR_OPEN || new_rlim.rlim_max > NR_OPEN) return -EPERM; diff -Nur linux-2.4.17.old/kernel/sysctl.c linux-2.4.17.new/kernel/sysctl.c --- linux-2.4.17.old/kernel/sysctl.c Sat Jan 19 16:01:58 2002 +++ linux-2.4.17.new/kernel/sysctl.c Sat Jan 19 16:04:27 2002 @@ -275,6 +275,8 @@ &vm_min_readahead,sizeof(int), 0644, NULL, &proc_dointvec}, {VM_MAX_READAHEAD, "max-readahead", &vm_max_readahead,sizeof(int), 0644, NULL, &proc_dointvec}, + {VM_TASK_UNMAPPED_BASE, "task_unmapped_base", + &vm_task_unmapped_base,sizeof(int), 0644, NULL, &proc_dointvec}, {0} }; diff -Nur linux-2.4.17.old/mm/mmap.c linux-2.4.17.new/mm/mmap.c --- linux-2.4.17.old/mm/mmap.c Sat Jan 19 16:11:17 2002 +++ linux-2.4.17.new/mm/mmap.c Sat Jan 19 17:52:46 2002 @@ -45,6 +45,8 @@ }; int sysctl_overcommit_memory; +int vm_task_unmapped_base = TASK_UNMAPPED_BASE; +EXPORT_SYMBOL(vm_task_unmapped_base); /* Check that a process has enough memory to allocate a * new virtual mapping. @@ -601,7 +603,7 @@ (!vma || addr + len <= vma->vm_start)) return addr; } - addr = PAGE_ALIGN(TASK_UNMAPPED_BASE); + addr = PAGE_ALIGN(current->mm->task_unmapped_base); for (vma = find_vma(current->mm, addr); ; vma = vma->vm_next) { /* At this point: (!vma || addr < vma->vm_end). */