Message ID | 20230717213545.142598-7-deller@gmx.de |
---|---|
State | New |
Headers | show |
Series | linux-user: brk() syscall fixes and armhf static binary fix | expand |
18.07.2023 00:35, Helge Deller wrote: > qemu-user crashes immediately when running static binaries on the armhf > architecture. The problem is the memory layout where the executable is > loaded before the interpreter library, in which case the reserved brk > region clashes with the interpreter code and is released before qemu > tries to start the program. > > Fix it by ncreasing the brk value to the highest brk value of > interpreter or executable. Nitpick: increasing, not ncreasing. /mjt
diff --git a/linux-user/elfload.c b/linux-user/elfload.c index a26200d9f3..94951630b1 100644 --- a/linux-user/elfload.c +++ b/linux-user/elfload.c @@ -3615,6 +3615,13 @@ int load_elf_binary(struct linux_binprm *bprm, struct image_info *info) if (elf_interpreter) { load_elf_interp(elf_interpreter, &interp_info, bprm->buf); + /* + * adjust brk address if the interpreter was loaded above the main + * executable, e.g. happens with static binaries on armhf + */ + if (interp_info.brk > info->brk) { + info->brk = interp_info.brk; + } /* If the program interpreter is one of these two, then assume an iBCS2 image. Otherwise assume a native linux image. */
qemu-user crashes immediately when running static binaries on the armhf architecture. The problem is the memory layout where the executable is loaded before the interpreter library, in which case the reserved brk region clashes with the interpreter code and is released before qemu tries to start the program. Fix it by ncreasing the brk value to the highest brk value of interpreter or executable. Signed-off-by: Helge Deller <deller@gmx.de> Reported-by: Venkata.Pyla@toshiba-tsip.com Closes: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1040981 --- linux-user/elfload.c | 7 +++++++ 1 file changed, 7 insertions(+) -- 2.41.0