Merge tag 'riscv/for-v5.4-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/riscv...
[linux-2.6-block.git] / fs / binfmt_elf.c
index d4e11b2e04f68aa34869594a4c7d07d2a1c5b83c..ad4c6b1d5074aa9cab8de782d000433f3410a778 100644 (file)
@@ -670,26 +670,6 @@ out:
  * libraries.  There is no binary dependent code anywhere else.
  */
 
-#ifndef STACK_RND_MASK
-#define STACK_RND_MASK (0x7ff >> (PAGE_SHIFT - 12))    /* 8MB of VA */
-#endif
-
-static unsigned long randomize_stack_top(unsigned long stack_top)
-{
-       unsigned long random_variable = 0;
-
-       if (current->flags & PF_RANDOMIZE) {
-               random_variable = get_random_long();
-               random_variable &= STACK_RND_MASK;
-               random_variable <<= PAGE_SHIFT;
-       }
-#ifdef CONFIG_STACK_GROWSUP
-       return PAGE_ALIGN(stack_top) + random_variable;
-#else
-       return PAGE_ALIGN(stack_top) - random_variable;
-#endif
-}
-
 static int load_elf_binary(struct linux_binprm *bprm)
 {
        struct file *interpreter = NULL; /* to shut gcc up */
@@ -1141,7 +1121,8 @@ out_free_interp:
                 * (since it grows up, and may collide early with the stack
                 * growing down), and into the unused ELF_ET_DYN_BASE region.
                 */
-               if (IS_ENABLED(CONFIG_ARCH_HAS_ELF_RANDOMIZE) && !interpreter)
+               if (IS_ENABLED(CONFIG_ARCH_HAS_ELF_RANDOMIZE) &&
+                   loc->elf_ex.e_type == ET_DYN && !interpreter)
                        current->mm->brk = current->mm->start_brk =
                                ELF_ET_DYN_BASE;