qemu seems to lack support for pid namespace.

Bug #1829459 reported by crocket on 2019-05-17
This bug affects 4 people
Affects Status Importance Assigned to Milestone

Bug Description

# Version


# commands used to launch qemu-aarch64 in user mode.


printf '%s\n' ':qemu-aarch64:M::\x7fELF\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\xb7\x00:\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff:/usr/bin/qemu-aarch64:'"${QEMU_BINFMT_FLAGS}" >/proc/sys/fs/binfmt_misc/register

> sudo cp /usr/bin/qemu-aarch64 $RPI/usr/bin
> sudo chroot $RPI /bin/ksh -l

# host

Gentoo Linux amd64

# Guest

Gentoo Linux aarch64

# The problem that I have

"emerge" program fails due to the error, "qemu: qemu_thread_create: Invalid argument".
"emerge" is Gentoo's package manager that compiles and installs packages.

# Workaround

Disable pid-sandbox in emerge.

# How to reproduce the issue


unshare --pid -- echo hello world


python -c "import portage.process; portage.process.spawn(['echo', 'hello', 'world'], unshare_pid=True)"

crocket (crockabiscuit) on 2019-05-17
description: updated
description: updated
description: updated
crocket (crockabiscuit) on 2019-12-29
summary: - qemu: qemu_thread_create: Invalid argument
+ qemu seems to lack support for pid namespace.
Laurent Vivier (laurent-vivier) wrote :

PID namespace prevents to execute some syscalls, even if you use --map-root-user. This is managed at kernel level by the capabilities.

Could you try to do the exact same thing with the native architecture binaries in the chroot to see if the problem really comes from qemu-user?

Could you try to use the latest unshare version (util-linux package) that adds a "--keep-caps" parameter (v2.35-rc1) to preserve the capabilities?

crocket (crockabiscuit) wrote :

In a native chroot, `sudo unshare --pid -- echo hello world` works without a problem.

In a qemu-aarch64 chroot, `sudo unshare --keep-caps --pid -- echo hello world` fails with the same error described in this issue.

`qemu: qemu_thread_create: Invalid argument`

crocket (crockabiscuit) wrote :

According to `man unshare`, --keep-caps seems to apply only to user namespace.

crocket (crockabiscuit) wrote :

I think you should investigate

`qemu: qemu_thread_create: Invalid argument`

To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers