qemu-x86_64 don't support unshare(CLONE_NEWUSER)

Host environment

  • Operating system: Ubuntu 20.04
  • OS/kernel version: Linux ubuntu 5.13.0-27-generic #29~20.04.1-Ubuntu SMP Fri Jan 14 00:32:30 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
  • Architecture: x86
  • QEMU flavor: qemu-x86_64
  • QEMU version: qemu-x86_64 -version qemu-x86_64 version 4.2.1 (Debian 1:4.2-3ubuntu6.19) Copyright (c) 2003-2019 Fabrice Bellard and the QEMU Project developers
  • QEMU command line: qemu-x86_64 /bin/unshare --user /bin/bash

Description of problem

Why qemu-x86_64 call unshare(CLONE_NEWUSER) fail?

    fuzzing@ubuntu:~/Desktop/afl/AFLplusplus$ qemu-x86_64 /bin/unshare --user /bin/bash
    unshare: unshare failed: Invalid argument
    fuzzing@ubuntu:~/Desktop/afl/AFLplusplus$ /bin/unshare --user /bin/bash
    nobody@ubuntu:~/Desktop/afl/AFLplusplus$

Steps to reproduce

1.execute qemu-x86_64 /bin/unshare --user /bin/bash ,it will fail
2.execute /bin/unshare --user /bin/bash ,it will ok

How i fix that?

Edited by Thomas Huth
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information