Message ID | 20230725141009.3372529-3-mjt@tls.msk.ru |
---|---|
State | New |
Headers | show |
Series | Patch Round-up for stable 7.2.5, freeze on 2023-08-05 | expand |
25.07.2023 17:09, Michael Tokarev пишет: > From: Helge Deller <deller@gmx.de> > > 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. > > At load time qemu calculates a brk value for interpreter and executable > each. The fix is to choose the higher one of both. > > Signed-off-by: Helge Deller <deller@gmx.de> > Cc: Andreas Schwab <schwab@suse.de> > Cc: qemu-stable@nongnu.org > Reported-by: Venkata.Pyla@toshiba-tsip.com > Closes: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1040981 > (cherry picked from commit 518f32221af759a29500ac172c4c857bef142067) > Signed-off-by: Michael Tokarev <mjt@tls.msk.ru> > > diff --git a/linux-user/elfload.c b/linux-user/elfload.c > index 20894b633f..fdc95f8cf6 100644 > --- a/linux-user/elfload.c > +++ b/linux-user/elfload.c > @@ -3553,6 +3553,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. */ This obviously should not be there, dropped now. /mjt
diff --git a/linux-user/elfload.c b/linux-user/elfload.c index 20894b633f..fdc95f8cf6 100644 --- a/linux-user/elfload.c +++ b/linux-user/elfload.c @@ -3553,6 +3553,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. */