Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 138494
b: refs/heads/master
c: 912f9ee
h: refs/heads/master
v: v3
  • Loading branch information
Anton Blanchard authored and Benjamin Herrenschmidt committed Feb 23, 2009
1 parent 02313e7 commit a1a0e01
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 1 deletion.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: d839088caec6891a5070f0b1ce61031e458533a9
refs/heads/master: 912f9ee21c836081e3c96dfe61025841ebeb95da
3 changes: 3 additions & 0 deletions trunk/arch/powerpc/include/asm/elf.h
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,9 @@ extern int arch_setup_additional_pages(struct linux_binprm *bprm,
(0x7ff >> (PAGE_SHIFT - 12)) : \
(0x3ffff >> (PAGE_SHIFT - 12)))

extern unsigned long arch_randomize_brk(struct mm_struct *mm);
#define arch_randomize_brk arch_randomize_brk

#endif /* __KERNEL__ */

/*
Expand Down
23 changes: 23 additions & 0 deletions trunk/arch/powerpc/kernel/process.c
Original file line number Diff line number Diff line change
Expand Up @@ -1147,3 +1147,26 @@ unsigned long arch_align_stack(unsigned long sp)
sp -= get_random_int() & ~PAGE_MASK;
return sp & ~0xf;
}

static inline unsigned long brk_rnd(void)
{
unsigned long rnd = 0;

/* 8MB for 32bit, 1GB for 64bit */
if (is_32bit_task())
rnd = (long)(get_random_int() % (1<<(23-PAGE_SHIFT)));
else
rnd = (long)(get_random_int() % (1<<(30-PAGE_SHIFT)));

return rnd << PAGE_SHIFT;
}

unsigned long arch_randomize_brk(struct mm_struct *mm)
{
unsigned long ret = PAGE_ALIGN(mm->brk + brk_rnd());

if (ret < mm->brk)
return mm->brk;

return ret;
}

0 comments on commit a1a0e01

Please sign in to comment.