Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

arch: handle arches who do not yet define clone3

This cleanly handles arches who do not yet define clone3.

clone3() was initially placed under __ARCH_WANT_SYS_CLONE under the
assumption that this would cleanly handle all architectures. It does
not.
Architectures such as nios2 or h8300 simply take the asm-generic syscall
definitions and generate their syscall table from it. Since they don't
define __ARCH_WANT_SYS_CLONE the build would fail complaining about
sys_clone3 missing. The reason this doesn't happen for legacy clone is
that nios2 and h8300 provide assembly stubs for sys_clone. This seems to
be done for architectural reasons.

The build failures for nios2 and h8300 were caught int -next luckily.
The solution is to define __ARCH_WANT_SYS_CLONE3 that architectures can
add. Additionally, we need a cond_syscall(clone3) for architectures such
as nios2 or h8300 that generate their syscall table in the way I
explained above.

Fixes: 8f3220a80654 ("arch: wire-up clone3() syscall")
Signed-off-by: Christian Brauner <christian@brauner.io>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Kees Cook <keescook@chromium.org>
Cc: David Howells <dhowells@redhat.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Oleg Nesterov <oleg@redhat.com>
Cc: Adrian Reber <adrian@lisas.de>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: Florian Weimer <fweimer@redhat.com>
Cc: linux-api@vger.kernel.org
Cc: linux-arch@vger.kernel.org
Cc: x86@kernel.org

+8
+1
arch/arm/include/asm/unistd.h
··· 40 40 #define __ARCH_WANT_SYS_FORK 41 41 #define __ARCH_WANT_SYS_VFORK 42 42 #define __ARCH_WANT_SYS_CLONE 43 + #define __ARCH_WANT_SYS_CLONE3 43 44 44 45 /* 45 46 * Unimplemented (or alternatively implemented) syscalls
+1
arch/arm64/include/asm/unistd.h
··· 48 48 #endif 49 49 50 50 #define __ARCH_WANT_SYS_CLONE 51 + #define __ARCH_WANT_SYS_CLONE3 51 52 52 53 #ifndef __COMPAT_SYSCALL_NR 53 54 #include <uapi/asm/unistd.h>
+1
arch/x86/include/asm/unistd.h
··· 54 54 # define __ARCH_WANT_SYS_FORK 55 55 # define __ARCH_WANT_SYS_VFORK 56 56 # define __ARCH_WANT_SYS_CLONE 57 + # define __ARCH_WANT_SYS_CLONE3 57 58 58 59 #endif /* _ASM_X86_UNISTD_H */
+1
arch/xtensa/include/asm/unistd.h
··· 3 3 #define _XTENSA_UNISTD_H 4 4 5 5 #define __ARCH_WANT_SYS_CLONE 6 + #define __ARCH_WANT_SYS_CLONE3 6 7 #include <uapi/asm/unistd.h> 7 8 8 9 #define __ARCH_WANT_NEW_STAT
+2
kernel/fork.c
··· 2490 2490 2491 2491 return _do_fork(&args); 2492 2492 } 2493 + #endif 2493 2494 2495 + #ifdef __ARCH_WANT_SYS_CLONE3 2494 2496 noinline static int copy_clone_args_from_user(struct kernel_clone_args *kargs, 2495 2497 struct clone_args __user *uargs, 2496 2498 size_t size)
+2
kernel/sys_ni.c
··· 137 137 /* kernel/exit.c */ 138 138 139 139 /* kernel/fork.c */ 140 + /* __ARCH_WANT_SYS_CLONE3 */ 141 + COND_SYSCALL(clone3); 140 142 141 143 /* kernel/futex.c */ 142 144 COND_SYSCALL(futex);