Re: running binary in chroot using qemu-arm-static fails to mmap after r320318

From: Alan Cox <alan.l.cox_at_gmail.com>
Date: Sat, 1 Jul 2017 15:07:18 -0500
On Sat, Jul 1, 2017 at 2:46 PM, Guy Yur <guyyur_at_gmail.com> wrote:

> Hi,
>
> I tried to run armv6 /bin/sh in a chroot on an
> amd64 host using qemu-arm-static.
> It failed on invalid argument to mmap.
>
> # cp /usr/local/bin/qemu-arm-static /chroots/armv6/root/
> # chroot /chroots/armv6 /root/qemu-arm-static /bin/sh
> /lib/libedit.so.7: mmap of entire address space failed: Invalid argument
>
> rtld-elf only passes MAP_GUARD but ktrace shows mmap
> is called with MAP_FIXED and MAP_ANON too.
> I think qemu-user-static adds the flags in bsd-user/mmap.c target_mmap().
> Does the qemu-user-static port need patching to support MAP_GUARD?
>
>
MAP_ANON should not be passed to mmap(2) at the same time as MAP_GUARD.
Passing MAP_FIXED at the same time is okay.


> ktrace snipet:
>   1072 qemu-arm-static CALL
> openat(AT_FDCWD,0xf4ff9020,0x300000<O_RDONLY|O_CLOEXEC|O_VERIFY>)
>   1072 qemu-arm-static NAMI  "/lib/libc.so.7"
>   1072 qemu-arm-static RET   openat 3
>   1072 qemu-arm-static CALL  fstat(0x3,0x7ffffffe9680)
>   1072 qemu-arm-static STRU  struct stat {dev=687931144, ino=192007,
> mode=0100444, nlink=1, uid=0, gid=0, rdev=1548632,
> atime=1498921861.605975000, mtime=1498921861.608547000,
> ctime=1498921861.609724000, birthtime=1498921861.605973000,
> size=1720888, blksize=32768, blocks=3456, flags=0x20000 }
>   1072 qemu-arm-static RET   fstat 0
>   1072 qemu-arm-static CALL
> mmap(0xf4ff7000,0x1000,0x1<PROT_READ>,0x41012<MAP_
> PRIVATE|MAP_FIXED|MAP_ANON|MAP_PREFAULT_READ>,0xffffffff,0)
>   1072 qemu-arm-static RET   mmap 4110381056/0xf4ff7000
>   1072 qemu-arm-static CALL
> mmap(0xf4ff7000,0x1000,0x1<PROT_READ>,0x40012<MAP_PRIVATE|MAP_FIXED|MAP_
> PREFAULT_READ>,0x3,0)
>   1072 qemu-arm-static RET   mmap 4110381056/0xf4ff7000
>   1072 qemu-arm-static CALL
> mmap(0xf4e37000,0x1c0000,0<PROT_NONE>,0x3010<MAP_FIXED|
> MAP_ANON|MAP_GUARD>,0xffffffff,0)
>   1072 qemu-arm-static RET   mmap -1 errno 22 Invalid argument
>
> Thanks,
> Guy
> _______________________________________________
> freebsd-current_at_freebsd.org mailing list
> https://lists.freebsd.org/mailman/listinfo/freebsd-current
> To unsubscribe, send any mail to "freebsd-current-unsubscribe_at_freebsd.org"
>
Received on Sat Jul 01 2017 - 18:07:20 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:41:12 UTC