qemu-e2k/linux-user
Vincent Fazio 0266e8e3b3 linux-user/elfload: fix address calculation in fallback scenario
Previously, guest_loaddr was not taken into account when returning an
address from pgb_find_hole when /proc/self/maps was unavailable which
caused an improper guest_base address to be calculated.

This could cause a SIGSEGV later in load_elf_image -> target_mmap for
ET_EXEC type images since the mmap MAP_FIXED flag is specified which
could clobber existing mappings at the address returnd by g2h().

  mmap(0xd87000, 16846912, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS|MAP_NORESERVE|0x100000, -1, 0) = 0xd87000
  munmap(0xd87000, 16846912)              = 0
  write(2, "Locating guest address space @ 0"..., 40Locating guest address space @ 0xd87000) = 40
  mmap(0x1187000, 16850944, PROT_NONE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS|MAP_NORESERVE, -1, 0) = 0x1187000
  --- SIGSEGV {si_signo=SIGSEGV, si_code=SEGV_ACCERR, si_addr=0x2188310} ---
  +++ killed by SIGSEGV +++

Now, pgd_find_hole accounts for guest_loaddr in this scenario.

Fixes: ad592e37df ("linux-user: provide fallback pgd_find_hole for bare chroots")
Signed-off-by: Vincent Fazio <vfazio@gmail.com>
Reviewed-by: Laurent Vivier <laurent@vivier.eu>
Message-Id: <20210131061948.15990-1-vfazio@xes-inc.com>
[lv: updated it to check if ret == -1]
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
2021-03-13 10:45:11 +01:00
..
aarch64 semihosting: Move include/hw/semihosting/ -> include/semihosting/ 2021-03-10 15:34:12 +00:00
alpha linux-user: target: signal: Support TARGET_SS_AUTODISARM 2021-02-13 22:50:50 +01:00
arm semihosting: Move include/hw/semihosting/ -> include/semihosting/ 2021-03-10 15:34:12 +00:00
cris linux user: Fix Lesser GPL version number 2020-11-15 16:41:26 +01:00
generic linux-user: target: signal: Support TARGET_SS_AUTODISARM 2021-02-13 22:50:50 +01:00
hexagon Hexagon (linux-user/hexagon) Linux user emulation 2021-02-18 07:48:22 -08:00
host linux-user/: fix some comment spelling errors 2020-09-17 20:39:22 +02:00
hppa linux-user: Use cpu_untagged_addr in access_ok; split out *_untagged 2021-02-16 11:04:53 +00:00
i386 linux-user: Use cpu_untagged_addr in access_ok; split out *_untagged 2021-02-16 11:04:53 +00:00
m68k linux-user: Correct definition of stack_t 2020-11-11 10:59:39 +01:00
microblaze linux user: Fix Lesser GPL version number 2020-11-15 16:41:26 +01:00
mips linux-user: target: signal: Support TARGET_SS_AUTODISARM 2021-02-13 22:50:50 +01:00
mips64 linux-user/mips: Support the n32 ABI for the R5900 2021-02-15 12:10:03 +01:00
nios2 linux user: Fix Lesser GPL version number 2020-11-15 16:41:26 +01:00
openrisc linux-user: update syscall_nr.h to Linux 5.9-rc7 2020-10-26 11:39:23 +01:00
ppc exec: Use cpu_untagged_addr in g2h; split out g2h_untagged 2021-02-16 11:04:53 +00:00
riscv semihosting: Move include/hw/semihosting/ -> include/semihosting/ 2021-03-10 15:34:12 +00:00
s390x linux user: Fix Lesser GPL version number 2020-11-15 16:41:26 +01:00
sh4 accel/tcg: Precompute curr_cflags into cpu->tcg_cflags 2021-03-06 11:53:57 -08:00
sparc linux-user: target: signal: Support TARGET_SS_AUTODISARM 2021-02-13 22:50:50 +01:00
sparc64 linux user: Fix Lesser GPL version number 2020-11-15 16:41:26 +01:00
x86_64 linux user: Fix Lesser GPL version number 2020-11-15 16:41:26 +01:00
xtensa linux-user: update syscall.tbl to Linux 5.9-rc7 2020-10-26 11:39:23 +01:00
cpu_loop-common.h cpu: Replace ENV_GET_CPU with env_cpu 2019-06-10 07:03:34 -07:00
elfload.c linux-user/elfload: fix address calculation in fallback scenario 2021-03-13 10:45:11 +01:00
errno_defs.h Supply missing header guards 2019-06-12 13:20:21 +02:00
exit.c gdbstub: drop CPUEnv from gdb_exit() 2021-01-18 10:05:06 +00:00
fd-trans.c linux-user,netlink: add IFLA_BRPORT_MRP_RING_OPEN, IFLA_BRPORT_MRP_IN_OPEN 2020-11-17 15:22:52 +01:00
fd-trans.h linux-user: move TargetFdTrans functions to their own file 2018-09-25 22:36:47 +02:00
flat.h linux-user/: fix some comment spelling errors 2020-09-17 20:39:22 +02:00
flatload.c exec: Use cpu_untagged_addr in g2h; split out g2h_untagged 2021-02-16 11:04:53 +00:00
ioctls.h linux-user: Conditionalize TUNSETVNETLE 2021-01-07 05:09:06 -10:00
linux_loop.h linux-user: Add loop control ioctls 2016-07-19 15:22:33 +03:00
linuxload.c avoid TABs in files that only contain a few 2019-01-11 15:46:56 +01:00
main.c linux-user: manage binfmt-misc preserve-arg[0] flag 2021-03-13 10:45:11 +01:00
meson.build semihosting: Move ARM semihosting code to shared directories 2021-01-18 10:05:06 +00:00
mmap.c linux-user/aarch64: Implement PROT_MTE 2021-02-16 13:08:46 +00:00
qemu.h Hexagon (linux-user/hexagon) Linux user emulation 2021-02-18 07:48:22 -08:00
safe-syscall.S linux-user: Provide safe_syscall for fixing races between signals and syscalls 2016-05-27 14:49:51 +03:00
semihost.c semihosting: Move include/hw/semihosting/ -> include/semihosting/ 2021-03-10 15:34:12 +00:00
signal-common.h linux-user: Make sigaltstack stacks per-thread 2019-07-26 19:24:33 +02:00
signal.c linux-user/signal: Decode waitid si_code 2021-02-13 22:50:49 +01:00
socket.h Supply missing header guards 2019-06-12 13:20:21 +02:00
strace.c linux-user: Add IPv6 options to do_print_sockopt() 2021-01-21 13:27:08 +01:00
strace.list linux-user: Add strace support for printing arguments of some clock and time functions 2020-08-27 12:29:50 +02:00
syscall.c linux-user: Fix executable page of /proc/self/maps 2021-03-13 10:45:11 +01:00
syscall_defs.h Remove deprecated target tilegx 2021-03-09 11:26:32 +01:00
syscall_types.h linux-user: Add support for btrfs ioctls used to scrub a filesystem 2020-09-03 01:09:35 +02:00
target_flat.h Supply missing header guards 2019-06-12 13:20:21 +02:00
trace-events linux-user: fix use of SIGRTMIN 2020-02-12 18:56:41 +01:00
trace.h trace: switch position of headers to what Meson requires 2020-08-21 06:18:24 -04:00
uaccess.c linux-user: Handle tags in lock_user/unlock_user 2021-02-16 13:06:11 +00:00
uname.c cpu: Replace ENV_GET_CPU with env_cpu 2019-06-10 07:03:34 -07:00
uname.h Clean up decorations and whitespace around header guards 2016-07-12 16:20:46 +02:00
vm86.c linux-user: Use `qemu_log' for non-strace logging 2020-02-19 11:17:40 +01:00