|
@@ -31,9 +31,6 @@
|
|
|
#include <linux/security.h>
|
|
|
#include <asm/pgalloc.h>
|
|
|
|
|
|
-unsigned long mmap_rnd_mask;
|
|
|
-static unsigned long mmap_align_mask;
|
|
|
-
|
|
|
static unsigned long stack_maxrandom_size(void)
|
|
|
{
|
|
|
if (!(current->flags & PF_RANDOMIZE))
|
|
@@ -62,10 +59,7 @@ static inline int mmap_is_legacy(void)
|
|
|
|
|
|
unsigned long arch_mmap_rnd(void)
|
|
|
{
|
|
|
- if (is_32bit_task())
|
|
|
- return (get_random_int() & 0x7ff) << PAGE_SHIFT;
|
|
|
- else
|
|
|
- return (get_random_int() & mmap_rnd_mask) << PAGE_SHIFT;
|
|
|
+ return (get_random_int() & MMAP_RND_MASK) << PAGE_SHIFT;
|
|
|
}
|
|
|
|
|
|
static unsigned long mmap_base_legacy(unsigned long rnd)
|
|
@@ -92,7 +86,6 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
|
|
|
struct mm_struct *mm = current->mm;
|
|
|
struct vm_area_struct *vma;
|
|
|
struct vm_unmapped_area_info info;
|
|
|
- int do_color_align;
|
|
|
|
|
|
if (len > TASK_SIZE - mmap_min_addr)
|
|
|
return -ENOMEM;
|
|
@@ -108,15 +101,14 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
|
|
|
return addr;
|
|
|
}
|
|
|
|
|
|
- do_color_align = 0;
|
|
|
- if (filp || (flags & MAP_SHARED))
|
|
|
- do_color_align = !is_32bit_task();
|
|
|
-
|
|
|
info.flags = 0;
|
|
|
info.length = len;
|
|
|
info.low_limit = mm->mmap_base;
|
|
|
info.high_limit = TASK_SIZE;
|
|
|
- info.align_mask = do_color_align ? (mmap_align_mask << PAGE_SHIFT) : 0;
|
|
|
+ if (filp || (flags & MAP_SHARED))
|
|
|
+ info.align_mask = MMAP_ALIGN_MASK << PAGE_SHIFT;
|
|
|
+ else
|
|
|
+ info.align_mask = 0;
|
|
|
info.align_offset = pgoff << PAGE_SHIFT;
|
|
|
return vm_unmapped_area(&info);
|
|
|
}
|
|
@@ -130,7 +122,6 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
|
|
|
struct mm_struct *mm = current->mm;
|
|
|
unsigned long addr = addr0;
|
|
|
struct vm_unmapped_area_info info;
|
|
|
- int do_color_align;
|
|
|
|
|
|
/* requested length too big for entire address space */
|
|
|
if (len > TASK_SIZE - mmap_min_addr)
|
|
@@ -148,15 +139,14 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
|
|
|
return addr;
|
|
|
}
|
|
|
|
|
|
- do_color_align = 0;
|
|
|
- if (filp || (flags & MAP_SHARED))
|
|
|
- do_color_align = !is_32bit_task();
|
|
|
-
|
|
|
info.flags = VM_UNMAPPED_AREA_TOPDOWN;
|
|
|
info.length = len;
|
|
|
info.low_limit = max(PAGE_SIZE, mmap_min_addr);
|
|
|
info.high_limit = mm->mmap_base;
|
|
|
- info.align_mask = do_color_align ? (mmap_align_mask << PAGE_SHIFT) : 0;
|
|
|
+ if (filp || (flags & MAP_SHARED))
|
|
|
+ info.align_mask = MMAP_ALIGN_MASK << PAGE_SHIFT;
|
|
|
+ else
|
|
|
+ info.align_mask = 0;
|
|
|
info.align_offset = pgoff << PAGE_SHIFT;
|
|
|
addr = vm_unmapped_area(&info);
|
|
|
|
|
@@ -254,35 +244,3 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
|
|
|
mm->get_unmapped_area = s390_get_unmapped_area_topdown;
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
-static int __init setup_mmap_rnd(void)
|
|
|
-{
|
|
|
- struct cpuid cpu_id;
|
|
|
-
|
|
|
- get_cpu_id(&cpu_id);
|
|
|
- switch (cpu_id.machine) {
|
|
|
- case 0x9672:
|
|
|
- case 0x2064:
|
|
|
- case 0x2066:
|
|
|
- case 0x2084:
|
|
|
- case 0x2086:
|
|
|
- case 0x2094:
|
|
|
- case 0x2096:
|
|
|
- case 0x2097:
|
|
|
- case 0x2098:
|
|
|
- case 0x2817:
|
|
|
- case 0x2818:
|
|
|
- case 0x2827:
|
|
|
- case 0x2828:
|
|
|
- mmap_rnd_mask = 0x7ffUL;
|
|
|
- mmap_align_mask = 0UL;
|
|
|
- break;
|
|
|
- case 0x2964: /* z13 */
|
|
|
- default:
|
|
|
- mmap_rnd_mask = 0x3ff80UL;
|
|
|
- mmap_align_mask = 0x7fUL;
|
|
|
- break;
|
|
|
- }
|
|
|
- return 0;
|
|
|
-}
|
|
|
-early_initcall(setup_mmap_rnd);
|