aboutsummaryrefslogtreecommitdiffstats
path: root/arch/s390/kernel/process.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/s390/kernel/process.c')
-rw-r--r--arch/s390/kernel/process.c38
1 files changed, 38 insertions, 0 deletions
diff --git a/arch/s390/kernel/process.c b/arch/s390/kernel/process.c
index 6ba42222b542..a895e69379f7 100644
--- a/arch/s390/kernel/process.c
+++ b/arch/s390/kernel/process.c
@@ -30,9 +30,11 @@
30#include <linux/tick.h> 30#include <linux/tick.h>
31#include <linux/elfcore.h> 31#include <linux/elfcore.h>
32#include <linux/kernel_stat.h> 32#include <linux/kernel_stat.h>
33#include <linux/personality.h>
33#include <linux/syscalls.h> 34#include <linux/syscalls.h>
34#include <linux/compat.h> 35#include <linux/compat.h>
35#include <linux/kprobes.h> 36#include <linux/kprobes.h>
37#include <linux/random.h>
36#include <asm/compat.h> 38#include <asm/compat.h>
37#include <asm/uaccess.h> 39#include <asm/uaccess.h>
38#include <asm/pgtable.h> 40#include <asm/pgtable.h>
@@ -332,3 +334,39 @@ unsigned long get_wchan(struct task_struct *p)
332 } 334 }
333 return 0; 335 return 0;
334} 336}
337
338unsigned long arch_align_stack(unsigned long sp)
339{
340 if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
341 sp -= get_random_int() & ~PAGE_MASK;
342 return sp & ~0xf;
343}
344
345static inline unsigned long brk_rnd(void)
346{
347 /* 8MB for 32bit, 1GB for 64bit */
348 if (is_32bit_task())
349 return (get_random_int() & 0x7ffUL) << PAGE_SHIFT;
350 else
351 return (get_random_int() & 0x3ffffUL) << PAGE_SHIFT;
352}
353
354unsigned long arch_randomize_brk(struct mm_struct *mm)
355{
356 unsigned long ret = PAGE_ALIGN(mm->brk + brk_rnd());
357
358 if (ret < mm->brk)
359 return mm->brk;
360 return ret;
361}
362
363unsigned long randomize_et_dyn(unsigned long base)
364{
365 unsigned long ret = PAGE_ALIGN(base + brk_rnd());
366
367 if (!(current->flags & PF_RANDOMIZE))
368 return base;
369 if (ret < base)
370 return base;
371 return ret;
372}