diff options
Diffstat (limited to 'arch/parisc/kernel/process.c')
-rw-r--r-- | arch/parisc/kernel/process.c | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/arch/parisc/kernel/process.c b/arch/parisc/kernel/process.c index 55f92b614182..0bbbf0d3f608 100644 --- a/arch/parisc/kernel/process.c +++ b/arch/parisc/kernel/process.c | |||
@@ -13,7 +13,7 @@ | |||
13 | * Copyright (C) 2000 Grant Grundler <grundler with parisc-linux.org> | 13 | * Copyright (C) 2000 Grant Grundler <grundler with parisc-linux.org> |
14 | * Copyright (C) 2001 Alan Modra <amodra at parisc-linux.org> | 14 | * Copyright (C) 2001 Alan Modra <amodra at parisc-linux.org> |
15 | * Copyright (C) 2001-2002 Ryan Bradetich <rbrad at parisc-linux.org> | 15 | * Copyright (C) 2001-2002 Ryan Bradetich <rbrad at parisc-linux.org> |
16 | * Copyright (C) 2001-2007 Helge Deller <deller at parisc-linux.org> | 16 | * Copyright (C) 2001-2014 Helge Deller <deller@gmx.de> |
17 | * Copyright (C) 2002 Randolph Chung <tausq with parisc-linux.org> | 17 | * Copyright (C) 2002 Randolph Chung <tausq with parisc-linux.org> |
18 | * | 18 | * |
19 | * | 19 | * |
@@ -49,6 +49,7 @@ | |||
49 | #include <linux/kallsyms.h> | 49 | #include <linux/kallsyms.h> |
50 | #include <linux/uaccess.h> | 50 | #include <linux/uaccess.h> |
51 | #include <linux/rcupdate.h> | 51 | #include <linux/rcupdate.h> |
52 | #include <linux/random.h> | ||
52 | 53 | ||
53 | #include <asm/io.h> | 54 | #include <asm/io.h> |
54 | #include <asm/asm-offsets.h> | 55 | #include <asm/asm-offsets.h> |
@@ -286,3 +287,21 @@ void *dereference_function_descriptor(void *ptr) | |||
286 | return ptr; | 287 | return ptr; |
287 | } | 288 | } |
288 | #endif | 289 | #endif |
290 | |||
291 | static inline unsigned long brk_rnd(void) | ||
292 | { | ||
293 | /* 8MB for 32bit, 1GB for 64bit */ | ||
294 | if (is_32bit_task()) | ||
295 | return (get_random_int() & 0x7ffUL) << PAGE_SHIFT; | ||
296 | else | ||
297 | return (get_random_int() & 0x3ffffUL) << PAGE_SHIFT; | ||
298 | } | ||
299 | |||
300 | unsigned long arch_randomize_brk(struct mm_struct *mm) | ||
301 | { | ||
302 | unsigned long ret = PAGE_ALIGN(mm->brk + brk_rnd()); | ||
303 | |||
304 | if (ret < mm->brk) | ||
305 | return mm->brk; | ||
306 | return ret; | ||
307 | } | ||