diff options
author | Tony Lindgren <tony@atomide.com> | 2017-08-10 18:05:53 +0200 |
---|---|---|
committer | Tony Lindgren <tony@atomide.com> | 2017-08-10 18:05:53 +0200 |
commit | c002c27874faaa170b535d03d7efee89ecdd9be4 (patch) | |
tree | 70d91eba77a9c374e4f0bf9eb8636acba57ca173 /arch/powerpc/mm/mmap.c | |
parent | ARM: dts: dra7: Add "max-frequency" property to MMC dt nodes (diff) | |
parent | Linux v4.13-rc1 (diff) | |
download | linux-c002c27874faaa170b535d03d7efee89ecdd9be4.tar.xz linux-c002c27874faaa170b535d03d7efee89ecdd9be4.zip |
Merge tag 'v4.13-rc1' into omap-for-v4.14/mmc-regulator
Linux v4.13-rc1
Diffstat (limited to 'arch/powerpc/mm/mmap.c')
-rw-r--r-- | arch/powerpc/mm/mmap.c | 32 |
1 files changed, 21 insertions, 11 deletions
diff --git a/arch/powerpc/mm/mmap.c b/arch/powerpc/mm/mmap.c index 9dbd2a733d6b..5d78b193fec4 100644 --- a/arch/powerpc/mm/mmap.c +++ b/arch/powerpc/mm/mmap.c @@ -34,16 +34,9 @@ /* * Top of mmap area (just below the process stack). * - * Leave at least a ~128 MB hole on 32bit applications. - * - * On 64bit applications we randomise the stack by 1GB so we need to - * space our mmap start address by a further 1GB, otherwise there is a - * chance the mmap area will end up closer to the stack than our ulimit - * requires. + * Leave at least a ~128 MB hole. */ -#define MIN_GAP32 (128*1024*1024) -#define MIN_GAP64 ((128 + 1024)*1024*1024UL) -#define MIN_GAP ((is_32bit_task()) ? MIN_GAP32 : MIN_GAP64) +#define MIN_GAP (128*1024*1024) #define MAX_GAP (TASK_SIZE/6*5) static inline int mmap_is_legacy(void) @@ -71,9 +64,26 @@ unsigned long arch_mmap_rnd(void) return rnd << PAGE_SHIFT; } +static inline unsigned long stack_maxrandom_size(void) +{ + if (!(current->flags & PF_RANDOMIZE)) + return 0; + + /* 8MB for 32bit, 1GB for 64bit */ + if (is_32bit_task()) + return (1<<23); + else + return (1<<30); +} + static inline unsigned long mmap_base(unsigned long rnd) { unsigned long gap = rlimit(RLIMIT_STACK); + unsigned long pad = stack_maxrandom_size() + stack_guard_gap; + + /* Values close to RLIM_INFINITY can overflow. */ + if (gap + pad > gap) + gap += pad; if (gap < MIN_GAP) gap = MIN_GAP; @@ -112,7 +122,7 @@ radix__arch_get_unmapped_area(struct file *filp, unsigned long addr, addr = PAGE_ALIGN(addr); vma = find_vma(mm, addr); if (mm->task_size - len >= addr && addr >= mmap_min_addr && - (!vma || addr + len <= vma->vm_start)) + (!vma || addr + len <= vm_start_gap(vma))) return addr; } @@ -157,7 +167,7 @@ radix__arch_get_unmapped_area_topdown(struct file *filp, addr = PAGE_ALIGN(addr); vma = find_vma(mm, addr); if (mm->task_size - len >= addr && addr >= mmap_min_addr && - (!vma || addr + len <= vma->vm_start)) + (!vma || addr + len <= vm_start_gap(vma))) return addr; } |