mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-11-26 07:30:52 +07:00
[S390] Randomise the brk region
Randomize heap address like other architectures do already. Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com> Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
This commit is contained in:
parent
a05c90f194
commit
3351918282
@ -220,4 +220,7 @@ struct linux_binprm;
|
||||
#define ARCH_HAS_SETUP_ADDITIONAL_PAGES 1
|
||||
int arch_setup_additional_pages(struct linux_binprm *, int);
|
||||
|
||||
extern unsigned long arch_randomize_brk(struct mm_struct *mm);
|
||||
#define arch_randomize_brk arch_randomize_brk
|
||||
|
||||
#endif
|
||||
|
@ -341,3 +341,21 @@ unsigned long arch_align_stack(unsigned long sp)
|
||||
sp -= get_random_int() & ~PAGE_MASK;
|
||||
return sp & ~0xf;
|
||||
}
|
||||
|
||||
static inline unsigned long brk_rnd(void)
|
||||
{
|
||||
/* 8MB for 32bit, 1GB for 64bit */
|
||||
if (is_32bit_task())
|
||||
return (get_random_int() & 0x7ffUL) << PAGE_SHIFT;
|
||||
else
|
||||
return (get_random_int() & 0x3ffffUL) << 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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user