1
0
Fork 0
remarkable-linux/arch/mips
Paul Burton 86717a97f9 MIPS: VDSO: Always map near top of user memory
commit ea7e0480a4 upstream.

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+
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-10-18 09:16:23 +02:00
..
alchemy License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
ar7 MIPS: AR7: ensure the port type's FCR value is used 2018-01-23 19:58:21 +01:00
ath25 MIPS: ath25: Check for kzalloc allocation failure 2018-03-15 10:54:31 +01:00
ath79 MIPS: ath79: fix system restart 2018-09-26 08:38:00 +02:00
bcm47xx Revert "MIPS: BCM47XX: Enable 74K Core ExternalSync for PCIe erratum" 2018-09-05 09:26:30 +02:00
bcm63xx License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
bmips License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
boot MIPS: boot: fix build rule of vmlinux.its.S 2018-10-03 17:00:52 -07:00
cavium-octeon MIPS: Octeon: add missing of_node_put() 2018-09-19 22:43:43 +02:00
cobalt MIPS: Cobalt: Fix typo 2016-08-03 08:16:30 +02:00
configs Merge branch '4.14-features' of git://git.linux-mips.org/pub/scm/ralf/upstream-linus 2017-09-15 20:43:33 -07:00
dec License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
emma MIPS: Avoid old-style declaration 2017-01-25 02:51:11 +01:00
fw License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
generic MIPS: generic: fix missing of_node_put() 2018-09-19 22:43:43 +02:00
include MIPS: VDSO: Always map near top of user memory 2018-10-18 09:16:23 +02:00
jazz License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
jz4740 MIPS: jz4740: Bump zload address 2018-09-26 08:38:03 +02:00
kernel MIPS: VDSO: Always map near top of user memory 2018-10-18 09:16:23 +02:00
kvm KVM: Fix spelling mistake: "cop_unsuable" -> "cop_unusable" 2018-05-30 07:51:47 +02:00
lantiq MIPS: lantiq: ase: Enable MFD_SYSCON 2018-03-28 18:24:28 +02:00
lasat License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
lib MIPS: lib: Provide MIPS64r6 __multi3() for GCC < 7 2018-09-05 09:26:41 +02:00
loongson32 License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
loongson64 MIPS: loongson64: cs5536: Fix PCI_OHCI_INT_REG reads 2018-09-26 08:38:10 +02:00
math-emu MIPS: math-emu: Fix final emulation phase for certain instructions 2017-11-30 08:40:44 +00:00
mm MIPS: WARN_ON invalid DMA cache maintenance, not BUG_ON 2018-09-19 22:43:44 +02:00
mti-malta Update MIPS email addresses 2017-11-03 09:02:30 -07:00
net MIPS: bpf: Fix a typo in build_one_insn() 2017-11-01 00:09:17 +00:00
netlogic License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
oprofile License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
paravirt License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
pci MIPS: Fix off-by-one in pci_resource_to_user() 2018-07-28 07:55:41 +02:00
pic32 License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
pistachio License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
pmcs-msp71xx License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
pnx833x mtd: nand: Rename nand.h into rawnand.h 2017-08-13 10:11:49 +02:00
power License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
ralink MIPS: ralink: Fix booting on MT7621 2018-03-28 18:24:27 +02:00
rb532 License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
sgi-ip22 License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
sgi-ip27 License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
sgi-ip32 MIPS: Add missing include files 2017-03-08 10:38:06 +01:00
sibyte License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
sni License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
tools Update MIPS email addresses 2017-11-03 09:02:30 -07:00
txx9 MIPS: TXx9: use IS_BUILTIN() for CONFIG_LEDS_CLASS 2018-04-26 11:02:17 +02:00
vdso License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
vr41xx License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
xilfpga License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
Kbuild MIPS: Disable Werror when W= is set 2017-04-10 11:56:07 +02:00
Kbuild.platforms MIPS: generic: Convert SEAD-3 to a generic board 2016-10-06 18:04:20 +02:00
Kconfig MIPS: Fix typo BIG_ENDIAN to CPU_BIG_ENDIAN 2018-02-22 15:42:27 +01:00
Kconfig.debug License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
Makefile MIPS: Always use -march=<arch>, not -<arch> shortcuts 2018-09-05 09:26:41 +02:00
Makefile.postlink License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00