linux-user: Emulate CLONE_PIDFD flag in clone()

Add emulation for the CLONE_PIDFD flag of the clone() syscall.
This flag was added in Linux kernel 5.2.

Successfully tested on a x86-64 Linux host with hppa-linux target.
Can be verified by running the testsuite of the qcoro debian package,
which breaks hard and kills the currently logged-in user without this
patch.

Signed-off-by: Helge Deller <deller@gmx.de>
Reviewed-by: Laurent Vivier <laurent@vivier.eu>

Message-Id: <Y4XoJCpvUA1JD7Sj@p100>
[lv: define CLONE_PIDFD if it is not]
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
This commit is contained in:
Helge Deller 2022-11-29 12:08:20 +01:00 committed by Laurent Vivier
parent fe080593dd
commit 895ce8bb53
2 changed files with 35 additions and 1 deletions

View file

@ -1111,11 +1111,16 @@ UNUSED static const struct flags mmap_flags[] = {
FLAG_END,
};
#ifndef CLONE_PIDFD
# define CLONE_PIDFD 0x00001000
#endif
UNUSED static const struct flags clone_flags[] = {
FLAG_GENERIC(CLONE_VM),
FLAG_GENERIC(CLONE_FS),
FLAG_GENERIC(CLONE_FILES),
FLAG_GENERIC(CLONE_SIGHAND),
FLAG_GENERIC(CLONE_PIDFD),
FLAG_GENERIC(CLONE_PTRACE),
FLAG_GENERIC(CLONE_VFORK),
FLAG_GENERIC(CLONE_PARENT),