diff options
Diffstat (limited to 'fs/binfmt_elf.c')
-rw-r--r-- | fs/binfmt_elf.c | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c index 4349113881fb..537893a16014 100644 --- a/fs/binfmt_elf.c +++ b/fs/binfmt_elf.c | |||
@@ -500,17 +500,22 @@ out: | |||
500 | #define INTERPRETER_AOUT 1 | 500 | #define INTERPRETER_AOUT 1 |
501 | #define INTERPRETER_ELF 2 | 501 | #define INTERPRETER_ELF 2 |
502 | 502 | ||
503 | #ifndef STACK_RND_MASK | ||
504 | #define STACK_RND_MASK 0x7ff /* with 4K pages 8MB of VA */ | ||
505 | #endif | ||
503 | 506 | ||
504 | static unsigned long randomize_stack_top(unsigned long stack_top) | 507 | static unsigned long randomize_stack_top(unsigned long stack_top) |
505 | { | 508 | { |
506 | unsigned int random_variable = 0; | 509 | unsigned int random_variable = 0; |
507 | 510 | ||
508 | if (current->flags & PF_RANDOMIZE) | 511 | if (current->flags & PF_RANDOMIZE) { |
509 | random_variable = get_random_int() % (8*1024*1024); | 512 | random_variable = get_random_int() & STACK_RND_MASK; |
513 | random_variable <<= PAGE_SHIFT; | ||
514 | } | ||
510 | #ifdef CONFIG_STACK_GROWSUP | 515 | #ifdef CONFIG_STACK_GROWSUP |
511 | return PAGE_ALIGN(stack_top + random_variable); | 516 | return PAGE_ALIGN(stack_top) + random_variable; |
512 | #else | 517 | #else |
513 | return PAGE_ALIGN(stack_top - random_variable); | 518 | return PAGE_ALIGN(stack_top) - random_variable; |
514 | #endif | 519 | #endif |
515 | } | 520 | } |
516 | 521 | ||