Merge branch 'upstream' of git://electric-eye.fr.zoreil.com/home/romieu/linux-2.6...
[cascardo/linux.git] / fs / binfmt_elf.c
index 4349113..8a04216 100644 (file)
@@ -500,17 +500,22 @@ out:
 #define INTERPRETER_AOUT 1
 #define INTERPRETER_ELF 2
 
+#ifndef STACK_RND_MASK
+#define STACK_RND_MASK 0x7ff           /* with 4K pages 8MB of VA */
+#endif
 
 static unsigned long randomize_stack_top(unsigned long stack_top)
 {
        unsigned int random_variable = 0;
 
-       if (current->flags & PF_RANDOMIZE)
-               random_variable = get_random_int() % (8*1024*1024);
+       if (current->flags & PF_RANDOMIZE) {
+               random_variable = get_random_int() & STACK_RND_MASK;
+               random_variable <<= PAGE_SHIFT;
+       }
 #ifdef CONFIG_STACK_GROWSUP
-       return PAGE_ALIGN(stack_top + random_variable);
+       return PAGE_ALIGN(stack_top) + random_variable;
 #else
-       return PAGE_ALIGN(stack_top - random_variable);
+       return PAGE_ALIGN(stack_top) - random_variable;
 #endif
 }
 
@@ -754,7 +759,6 @@ static int load_elf_binary(struct linux_binprm * bprm, struct pt_regs * regs)
 
        /* Discard our unneeded old files struct */
        if (files) {
-               steal_locks(files);
                put_files_struct(files);
                files = NULL;
        }