linux-user: Ensure mmap_min_addr is non-zero
authorRichard Henderson <richard.henderson@linaro.org>
Fri, 24 Jul 2020 21:23:14 +0000 (14:23 -0700)
committerLaurent Vivier <laurent@vivier.eu>
Mon, 27 Jul 2020 20:02:40 +0000 (22:02 +0200)
commitc9f8066697e0d3e77b97f6df423e9d6540b693be
treeb29b36e7cc438e1403ccf09ba99be4b9db678169
parent9303ecb658a0194560d1eecde165a1511223c2d8
linux-user: Ensure mmap_min_addr is non-zero

When the chroot does not have /proc mounted, we can read neither
/proc/sys/vm/mmap_min_addr nor /proc/sys/maps.

The enforcement of mmap_min_addr in the host kernel is done by
the security module, and so does not apply to processes owned
by root.  Which leads pgd_find_hole_fallback to succeed in probing
a reservation at address 0.  Which confuses pgb_reserved_va to
believe that guest_base has not actually been initialized.

We don't actually want NULL addresses to become accessible, so
make sure that mmap_min_addr is initialized with a non-zero value.

Buglink: https://bugs.launchpad.net/qemu/+bug/1888728
Reported-by: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Tested-by: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
Acked-by: Laurent Vivier <laurent@vivier.eu>
Message-Id: <20200724212314.545877-1-richard.henderson@linaro.org>
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
linux-user/main.c