X-Git-Url: http://git.rot13.org/?a=blobdiff_plain;f=fs%2Fbinfmt_elf.c;h=537893a16014cbbdd6d72259e795030625e91a77;hb=28318776a80bc3261f9af91ef79e6e38bb9f5bec;hp=4349113881fbfc79e7fcf2500e2d13217e6fadc5;hpb=b55813a2e50088ca30df33fa62aeed5d3adb1796;p=powerpc.git diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c index 4349113881..537893a160 100644 --- a/fs/binfmt_elf.c +++ b/fs/binfmt_elf.c @@ -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 }