1
0
Fork 0
alistair23-linux/arch/mips/kernel
Paul Burton ea7e0480a4
MIPS: VDSO: Always map near top of user memory
When using the legacy mmap layout, for example triggered using ulimit -s
unlimited, get_unmapped_area() fills memory from bottom to top starting
from a fairly low address near TASK_UNMAPPED_BASE.

This placement is suboptimal if the user application wishes to allocate
large amounts of heap memory using the brk syscall. With the VDSO being
located low in the user's virtual address space, the amount of space
available for access using brk is limited much more than it was prior to
the introduction of the VDSO.

For example:

  # ulimit -s unlimited; cat /proc/self/maps
  00400000-004ec000 r-xp 00000000 08:00 71436      /usr/bin/coreutils
  004fc000-004fd000 rwxp 000ec000 08:00 71436      /usr/bin/coreutils
  004fd000-0050f000 rwxp 00000000 00:00 0
  00cc3000-00ce4000 rwxp 00000000 00:00 0          [heap]
  2ab96000-2ab98000 r--p 00000000 00:00 0          [vvar]
  2ab98000-2ab99000 r-xp 00000000 00:00 0          [vdso]
  2ab99000-2ab9d000 rwxp 00000000 00:00 0
  ...

Resolve this by adjusting STACK_TOP to reserve space for the VDSO &
providing an address hint to get_unmapped_area() causing it to use this
space even when using the legacy mmap layout.

We reserve enough space for the VDSO, plus 1MB or 256MB for 32 bit & 64
bit systems respectively within which we randomize the VDSO base
address. Previously this randomization was taken care of by the mmap
base address randomization performed by arch_mmap_rnd(). The 1MB & 256MB
sizes are somewhat arbitrary but chosen such that we have some
randomization without taking up too much of the user's virtual address
space, which is often in short supply for 32 bit systems.

With this the VDSO is always mapped at a high address, leaving lots of
space for statically linked programs to make use of brk:

  # ulimit -s unlimited; cat /proc/self/maps
  00400000-004ec000 r-xp 00000000 08:00 71436      /usr/bin/coreutils
  004fc000-004fd000 rwxp 000ec000 08:00 71436      /usr/bin/coreutils
  004fd000-0050f000 rwxp 00000000 00:00 0
  00c28000-00c49000 rwxp 00000000 00:00 0          [heap]
  ...
  7f67c000-7f69d000 rwxp 00000000 00:00 0          [stack]
  7f7fc000-7f7fd000 rwxp 00000000 00:00 0
  7fcf1000-7fcf3000 r--p 00000000 00:00 0          [vvar]
  7fcf3000-7fcf4000 r-xp 00000000 00:00 0          [vdso]

Signed-off-by: Paul Burton <paul.burton@mips.com>
Reported-by: Huacai Chen <chenhc@lemote.com>
Fixes: ebb5e78cc6 ("MIPS: Initial implementation of a VDSO")
Cc: Huacai Chen <chenhc@lemote.com>
Cc: linux-mips@linux-mips.org
Cc: stable@vger.kernel.org # v4.4+
2018-09-28 12:09:00 -07:00
..
.gitignore
8250-platform.c mips: remove needless include of module.h from core kernel files. 2011-10-31 19:30:57 -04:00
Makefile License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
asm-offsets.c Kbuild: rename CC_STACKPROTECTOR[_STRONG] config variables 2018-06-14 12:21:18 +09:00
binfmt_elfn32.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
binfmt_elfo32.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
bmips_5xxx_init.S MIPS: BMIPS: Make whitespacely correct. 2016-05-09 12:00:01 +02:00
bmips_vec.S MIPS: BMIPS: Add Whirlwind (BMIPS5200) initialization code 2016-05-09 12:00:01 +02:00
branch.c MIPS: Use proper kernel-doc Return keyword 2018-01-18 22:29:02 +00:00
cacheinfo.c MIPS: Fix cacheinfo overflow 2017-02-13 18:57:34 +00:00
cevt-bcm1480.c MIPS: clockevent drivers: Set ->min_delta_ticks and ->max_delta_ticks 2017-04-14 13:11:16 -07:00
cevt-ds1287.c MIPS: clockevent drivers: Set ->min_delta_ticks and ->max_delta_ticks 2017-04-14 13:11:16 -07:00
cevt-gt641xx.c MIPS: clockevent drivers: Set ->min_delta_ticks and ->max_delta_ticks 2017-04-14 13:11:16 -07:00
cevt-r4k.c MIPS: cevt-r4k: Fix out-of-bounds array access 2017-04-10 13:31:12 +02:00
cevt-sb1250.c MIPS: clockevent drivers: Set ->min_delta_ticks and ->max_delta_ticks 2017-04-14 13:11:16 -07:00
cevt-txx9.c MIPS: clockevent drivers: Set ->min_delta_ticks and ->max_delta_ticks 2017-04-14 13:11:16 -07:00
cmpxchg.c Update MIPS email addresses 2017-11-03 09:02:30 -07:00
cps-vec-ns16550.S Update MIPS email addresses 2017-11-03 09:02:30 -07:00
cps-vec.S MIPS: CPS: Fix MIPS_ISA_LEVEL_RAW fallout 2018-02-05 11:53:06 +00:00
cpu-bugs64.c MIPS: Fix printk continuations in cpu-bugs64.c 2017-01-24 18:30:34 +01:00
cpu-probe.c MIPS: Loongson: Add Loongson-3A R3.1 basic support 2018-07-23 17:53:34 -07:00
crash.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
crash_dump.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
csrc-bcm1480.c clocksource: Use a plain u64 instead of cycle_t 2016-12-25 11:04:12 +01:00
csrc-ioasic.c clocksource: Use a plain u64 instead of cycle_t 2016-12-25 11:04:12 +01:00
csrc-r4k.c clocksource: Use a plain u64 instead of cycle_t 2016-12-25 11:04:12 +01:00
csrc-sb1250.c clocksource: Use a plain u64 instead of cycle_t 2016-12-25 11:04:12 +01:00
early_printk.c mips: unify prom_putchar() declarations 2018-07-17 09:40:17 -07:00
early_printk_8250.c mips: unify prom_putchar() declarations 2018-07-17 09:40:17 -07:00
elf.c Update MIPS email addresses 2017-11-03 09:02:30 -07:00
entry.S MIPS: Add syscall detection for restartable sequences 2018-06-19 21:13:56 -07:00
ftrace.c MIPS: ftrace: Remove pointer comparison to 0 in prepare_ftrace_return 2018-01-18 21:59:24 +00:00
genex.S MIPS: Fix ejtag handler on SMP 2018-06-24 09:27:27 -07:00
gpio_txx9.c MIPS: txx9: switch to gpiochip_add_data() 2016-02-19 09:51:44 +01:00
head.S MIPS: head: Reorder instructions missing a delay slot 2017-06-27 23:35:21 +02:00
i8253.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
idle.c MIPS: Annotate cpu_wait implementations with __cpuidle 2018-06-28 14:18:54 -07:00
irq-gt641xx.c MIPS: Whitespace cleanup. 2013-02-01 10:00:22 +01:00
irq-msc01.c MIPS: MSC: Prevent out-of-bounds writes to MIPS SC ioremap'd region 2014-06-26 10:48:23 +01:00
irq-rm7000.c MIPS: Whitespace cleanup. 2013-02-01 10:00:22 +01:00
irq.c MIPS: Introduce irq_stack 2017-01-03 16:34:34 +01:00
irq_txx9.c MIPS: Whitespace cleanup. 2013-02-01 10:00:22 +01:00
jump_label.c jump_label: Reorder hotplug lock and jump_label_lock 2017-05-26 10:10:45 +02:00
kgdb.c MIPS: KGDB: Use kernel context for sleeping threads 2017-04-12 22:29:22 +02:00
kprobes.c bpf/error-inject/kprobes: Clear current_kprobe and enable preempt in kprobe 2018-06-21 12:33:19 +02:00
linux32.c MIPS: Delete unused code in linux32.c 2018-08-01 13:20:27 -07:00
machine_kexec.c MIPS: kexec: add debug info about the new kexec'ed image 2017-01-03 16:34:46 +01:00
mcount.S mips: ftrace: fix static function graph tracing 2018-06-19 15:00:12 -07:00
mips-cm.c MIPS: CM: Drop WARN_ON(vp != 0) 2018-01-10 16:47:25 +01:00
mips-cpc.c MIPS: CPC: Map registers using DT in mips_cpc_default_phys_base() 2018-02-08 14:02:01 +00:00
mips-mt-fpaff.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
mips-mt.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
mips-r2-to-r6-emul.c MIPS: Declare various variables & functions static 2017-08-29 15:21:55 +02:00
mips_machine.c MIPS: move mips_{set,get}_machine_name() to a more generic place 2013-05-08 01:19:07 +02:00
module.c Merge branch 'upstream' of git://git.linux-mips.org/pub/scm/ralf/upstream-linus 2017-07-15 10:59:54 -07:00
octeon_switch.S Kbuild: rename CC_STACKPROTECTOR[_STRONG] config variables 2018-06-14 12:21:18 +09:00
perf_event.c sched/headers: Prepare for new header dependencies before moving code to <linux/sched/task_stack.h> 2017-03-02 08:42:36 +01:00
perf_event_mipsxx.c MIPS: perf: Fix perf with MT counting other threads 2018-05-15 15:53:44 +01:00
pm-cps.c MIPS: pm-cps: Block system suspend when a JTAG probe is present 2018-03-09 13:53:26 +00:00
pm.c MIPS: Fix watchpoint restoration 2016-05-09 12:00:02 +02:00
probes-common.h MIPS: Update email address for Marcin Nowakowski 2017-11-02 10:58:43 +00:00
proc.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
process.c MIPS: VDSO: Always map near top of user memory 2018-09-28 12:09:00 -07:00
prom.c mips: remove arch specific early_init_dt_alloc_memory_arch 2018-01-30 11:15:55 -06:00
ptrace.c MIPS: Add FP_MODE regset support 2018-07-19 13:58:44 -07:00
ptrace32.c MIPS: Correct the 64-bit DSP accumulator register size 2018-07-19 13:47:21 -07:00
r4k_fpu.S MIPS: Fix MIPS64 FP save/restore on 32-bit kernels 2017-11-09 14:13:40 +00:00
r4k_switch.S Kbuild: rename CC_STACKPROTECTOR[_STRONG] config variables 2018-06-14 12:21:18 +09:00
r2300_fpu.S MIPS: Move r2300 FP code from r2300_switch.S to r2300_fpu.S 2017-08-29 15:21:51 +02:00
r2300_switch.S Kbuild: rename CC_STACKPROTECTOR[_STRONG] config variables 2018-06-14 12:21:18 +09:00
relocate.c Update MIPS email addresses 2017-11-03 09:02:30 -07:00
relocate_kernel.S MIPS: kexec: fix typos 2018-06-24 09:26:01 -07:00
reset.c MIPS: Hang more efficiently on halt/powerdown/restart 2018-03-09 11:22:43 +00:00
rtlx-cmp.c MIPS: APRP: Fix an issue when device_create() fails. 2014-08-01 17:30:35 +02:00
rtlx-mt.c MIPS: APRP: Fix an issue when device_create() fails. 2014-08-01 17:30:35 +02:00
rtlx.c vfs: do bulk POLL* -> EPOLL* replacement 2018-02-11 14:34:03 -08:00
scall32-o32.S MIPS: Wire up io_pgetevents syscall 2018-06-19 21:14:29 -07:00
scall64-64.S MIPS: Wire up io_pgetevents syscall 2018-06-19 21:14:29 -07:00
scall64-n32.S MIPS: Wire up io_pgetevents syscall 2018-06-19 21:14:29 -07:00
scall64-o32.S MIPS: Wire up io_pgetevents syscall 2018-06-19 21:14:29 -07:00
segment.c MIPS: Print segment physical address when EU=1 2016-07-28 11:44:30 +02:00
setup.c MIPS: Allow auto-dection of ARCH_PFN_OFFSET & PHYS_OFFSET 2018-07-30 10:27:32 -07:00
signal-common.h MIPS: Save MSA extended context around signals 2015-09-03 12:07:59 +02:00
signal.c Here are the main MIPS changes for 4.19. 2018-08-13 19:24:32 -07:00
signal32.c compat: Move compat_timespec/ timeval to compat_time.h 2018-04-19 13:29:54 +02:00
signal_n32.c MIPS: Remove nabi_no_regargs 2018-08-01 13:20:15 -07:00
signal_o32.c MIPS: Remove nabi_no_regargs 2018-08-01 13:20:15 -07:00
smp-bmips.c MIPS: BMIPS: Do not mask IPIs during suspend 2018-03-05 23:35:04 +00:00
smp-cmp.c MIPS: smp-cmp: Fix vpe_id build error 2017-11-01 23:23:00 +00:00
smp-cps.c MIPS: SMP-CPS: Remove duplicate assignment of core in play_dead 2018-02-05 14:36:06 +00:00
smp-mt.c MIPS: Use mips_gic_present() in place of gic_present 2017-09-04 13:53:14 +02:00
smp-up.c MIPS: SMP: Allow boot_secondary SMP op to return errors 2017-08-30 00:57:27 +02:00
smp.c MIPS changes for 4.15 2017-11-15 11:36:08 -08:00
spinlock_test.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
spram.c MIPS: Add P6600 cases to CPU switch statements 2016-05-13 14:01:52 +02:00
stacktrace.c sched/headers: Prepare for new header dependencies before moving code to <linux/sched/task_stack.h> 2017-03-02 08:42:36 +01:00
sync-r4k.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
syscall.c mm: add ksys_mmap_pgoff() helper; remove in-kernel calls to sys_mmap_pgoff() 2018-04-02 20:16:11 +02:00
sysrq.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
time.c MIPS: Convert update_persistent_clock() to update_persistent_clock64() 2018-05-14 23:58:23 +01:00
topology.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
traps.c A few MIPS fixes for 4.19: 2018-08-23 14:23:08 -07:00
unaligned.c MIPS: Declare various variables & functions static 2017-08-29 15:21:55 +02:00
uprobes.c Uprobe: Additional argument arch_uprobe to uprobe_write_opcode() 2018-08-13 20:08:33 -04:00
vdso.c MIPS: VDSO: Always map near top of user memory 2018-09-28 12:09:00 -07:00
vmlinux.lds.S License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
vpe-cmp.c MIPS: APRP: Add VPE loader support for CMP platforms. 2014-01-22 20:19:02 +01:00
vpe-mt.c MIPS: MT: Remove SMTC support 2014-05-24 00:07:01 +02:00
vpe.c MIPS: VPE: Fix spelling mistake: "uneeded" -> "unneeded" 2018-05-14 23:58:23 +01:00
watch.c MIPS: Watch: Avoid duplication of bits in mips_read_watch_registers 2018-01-23 15:46:01 +00:00