On 07/05/2017 13:47, Guy Yur wrote:
> Hi Alan,
> On 1 July 2017 at 23:07, Alan Cox <alan.l....@gmail.com> wrote:
>> On Sat, Jul 1, 2017 at 2:46 PM, Guy Yur <guy...@gmail.com> wrote:
>>> 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
>>> ... snipped
>> 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.
> The problem is definitely in qemu user mode mmap emulation code.
> qemu adds MAP_FIXED | MAP_ANONYMOUS if MAP_FIXED is not
> set in flags when the emulated mmap call is done.
> So rtld-elf passes MAP_GUARD and the kernel receives MAP_GUARD
> and MAP_ANON and rejects the call.
> Do you know if the MAP_ANONYMOUS is needed in the call?
Try removing the MAP_ANON (or MAP_ANONYMOUS). Adding MAP_FIXED should
not imply the addition of MAP_ANON.
> I am currently using a workaround patch to convert
> MAP_GUARD to MAP_PRIVATE | MAP_ANON | MAP_NOCORE
> (like rtld-elf does if OS version doesn't support MAP_GUARD).
> With the patch qemu-arm-static is working.
> I would prefer using a better fix that retains the MAP_GUARD protections.
firstname.lastname@example.org mailing list
To unsubscribe, send any mail to "freebsd-current-unsubscr...@freebsd.org"