[PATCH] limit brk adjustment wrt interp.brk to arm32 only for now

Michael Tokarev posted 1 patch 9 months, 2 weeks ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20230722082616.3254040-1-mjt@tls.msk.ru
Maintainers: Laurent Vivier <laurent@vivier.eu>
linux-user/elfload.c | 3 +++
1 file changed, 3 insertions(+)
[PATCH] limit brk adjustment wrt interp.brk to arm32 only for now
Posted by Michael Tokarev 9 months, 2 weeks ago
Commit 518f32221af7 "linux-user: Fix qemu-arm to run static armhf binaries"
added brk value adjustment to interpreter brk value after loading the
interpreter. Unfortunately this broke aarch64, ppc64el and s390x emulation, -
the error which we had on armhf now happens on at least these 3 architectures.
For the time being, limit the adjustment to aarch32 case only (where the prob
originally observed), to be analyzed in more details later.

This is a quick band-aid, not a real fix.

Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
---
 linux-user/elfload.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/linux-user/elfload.c b/linux-user/elfload.c
index 88c6861d7d..08e09b6863 100644
--- a/linux-user/elfload.c
+++ b/linux-user/elfload.c
@@ -3617,15 +3617,18 @@ int load_elf_binary(struct linux_binprm *bprm, struct image_info *info)
     }
 
     if (elf_interpreter) {
         load_elf_interp(elf_interpreter, &interp_info, bprm->buf);
+#if defined(TARGET_ARM) && !defined(TARGET_AARCH64)
+/* FIXME: this breaks aarch64, ppc64el, s390x, hence the #if for now */
         /*
          * 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;
         }
+#endif
 
         /* If the program interpreter is one of these two, then assume
            an iBCS2 image.  Otherwise assume a native linux image.  */
 
-- 
2.39.2
Re: [PATCH] limit brk adjustment wrt interp.brk to arm32 only for now
Posted by Peter Maydell 9 months, 2 weeks ago
On Sat, 22 Jul 2023 at 09:26, Michael Tokarev <mjt@tls.msk.ru> wrote:
>
> Commit 518f32221af7 "linux-user: Fix qemu-arm to run static armhf binaries"
> added brk value adjustment to interpreter brk value after loading the
> interpreter. Unfortunately this broke aarch64, ppc64el and s390x emulation, -
> the error which we had on armhf now happens on at least these 3 architectures.
> For the time being, limit the adjustment to aarch32 case only (where the prob
> originally observed), to be analyzed in more details later.
>
> This is a quick band-aid, not a real fix.

I think if 518f32221af7 broke things we should revert it,
not put in ifdefs.

thanks
-- PMM