diff options
Diffstat (limited to 'fs/binfmt_elf.c')
-rw-r--r-- | fs/binfmt_elf.c | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c index c2eac2a50bd2..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 | ||
@@ -1334,7 +1339,7 @@ static int fill_psinfo(struct elf_prpsinfo *psinfo, struct task_struct *p, | |||
1334 | 1339 | ||
1335 | i = p->state ? ffz(~p->state) + 1 : 0; | 1340 | i = p->state ? ffz(~p->state) + 1 : 0; |
1336 | psinfo->pr_state = i; | 1341 | psinfo->pr_state = i; |
1337 | psinfo->pr_sname = (i < 0 || i > 5) ? '.' : "RSDTZW"[i]; | 1342 | psinfo->pr_sname = (i > 5) ? '.' : "RSDTZW"[i]; |
1338 | psinfo->pr_zomb = psinfo->pr_sname == 'Z'; | 1343 | psinfo->pr_zomb = psinfo->pr_sname == 'Z'; |
1339 | psinfo->pr_nice = task_nice(p); | 1344 | psinfo->pr_nice = task_nice(p); |
1340 | psinfo->pr_flag = p->flags; | 1345 | psinfo->pr_flag = p->flags; |
@@ -1465,12 +1470,11 @@ static int elf_core_dump(long signr, struct pt_regs * regs, struct file * file) | |||
1465 | read_lock(&tasklist_lock); | 1470 | read_lock(&tasklist_lock); |
1466 | do_each_thread(g,p) | 1471 | do_each_thread(g,p) |
1467 | if (current->mm == p->mm && current != p) { | 1472 | if (current->mm == p->mm && current != p) { |
1468 | tmp = kmalloc(sizeof(*tmp), GFP_ATOMIC); | 1473 | tmp = kzalloc(sizeof(*tmp), GFP_ATOMIC); |
1469 | if (!tmp) { | 1474 | if (!tmp) { |
1470 | read_unlock(&tasklist_lock); | 1475 | read_unlock(&tasklist_lock); |
1471 | goto cleanup; | 1476 | goto cleanup; |
1472 | } | 1477 | } |
1473 | memset(tmp, 0, sizeof(*tmp)); | ||
1474 | INIT_LIST_HEAD(&tmp->list); | 1478 | INIT_LIST_HEAD(&tmp->list); |
1475 | tmp->thread = p; | 1479 | tmp->thread = p; |
1476 | list_add(&tmp->list, &thread_list); | 1480 | list_add(&tmp->list, &thread_list); |