Skip to content

Commit

Permalink
clone3: drop __ARCH_WANT_SYS_CLONE3 macro
Browse files Browse the repository at this point in the history
When clone3() was introduced, it was not obvious how each architecture
deals with setting up the stack and keeping the register contents in
a fork()-like system call, so this was left for the architecture
maintainers to implement, with __ARCH_WANT_SYS_CLONE3 defined by those
that already implement it.

Five years later, we still have a few architectures left that are missing
clone3(), and the macro keeps getting in the way as it's fundamentally
different from all the other __ARCH_WANT_SYS_* macros that are meant
to provide backwards-compatibility with applications using older
syscalls that are no longer provided by default.

Address this by reversing the polarity of the macro, adding an
__ARCH_BROKEN_SYS_CLONE3 macro to all architectures that don't
already provide the syscall, and remove __ARCH_WANT_SYS_CLONE3
from all the other ones.

Acked-by: Geert Uytterhoeven <geert@linux-m68k.org>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
  • Loading branch information
Arnd Bergmann committed Jul 10, 2024
1 parent fbb5c06 commit 505d66d
Show file tree
Hide file tree
Showing 24 changed files with 13 additions and 29 deletions.
1 change: 0 additions & 1 deletion arch/arc/include/uapi/asm/unistd.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
#define __ARCH_WANT_SET_GET_RLIMIT
#define __ARCH_WANT_SYS_EXECVE
#define __ARCH_WANT_SYS_CLONE
#define __ARCH_WANT_SYS_CLONE3
#define __ARCH_WANT_SYS_VFORK
#define __ARCH_WANT_SYS_FORK
#define __ARCH_WANT_TIME32_SYSCALLS
Expand Down
1 change: 0 additions & 1 deletion arch/arm/include/asm/unistd.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
#define __ARCH_WANT_SYS_FORK
#define __ARCH_WANT_SYS_VFORK
#define __ARCH_WANT_SYS_CLONE
#define __ARCH_WANT_SYS_CLONE3

/*
* Unimplemented (or alternatively implemented) syscalls
Expand Down
1 change: 0 additions & 1 deletion arch/arm64/include/uapi/asm/unistd.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
#define __ARCH_WANT_NEW_STAT
#define __ARCH_WANT_SET_GET_RLIMIT
#define __ARCH_WANT_TIME32_SYSCALLS
#define __ARCH_WANT_SYS_CLONE3
#define __ARCH_WANT_MEMFD_SECRET

#include <asm-generic/unistd.h>
1 change: 0 additions & 1 deletion arch/csky/include/uapi/asm/unistd.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
#define __ARCH_WANT_STAT64
#define __ARCH_WANT_NEW_STAT
#define __ARCH_WANT_SYS_CLONE
#define __ARCH_WANT_SYS_CLONE3
#define __ARCH_WANT_SET_GET_RLIMIT
#define __ARCH_WANT_TIME32_SYSCALLS
#define __ARCH_WANT_SYNC_FILE_RANGE2
Expand Down
2 changes: 2 additions & 0 deletions arch/hexagon/include/uapi/asm/unistd.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,6 @@
#define __ARCH_WANT_TIME32_SYSCALLS
#define __ARCH_WANT_SYNC_FILE_RANGE2

#define __ARCH_BROKEN_SYS_CLONE3

#include <asm-generic/unistd.h>
1 change: 0 additions & 1 deletion arch/loongarch/include/uapi/asm/unistd.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
#define __ARCH_WANT_SYS_CLONE
#define __ARCH_WANT_SYS_CLONE3

#include <asm-generic/unistd.h>
1 change: 0 additions & 1 deletion arch/m68k/include/asm/unistd.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,5 @@
#define __ARCH_WANT_SYS_SIGPROCMASK
#define __ARCH_WANT_SYS_FORK
#define __ARCH_WANT_SYS_VFORK
#define __ARCH_WANT_SYS_CLONE3

#endif /* _ASM_M68K_UNISTD_H_ */
1 change: 0 additions & 1 deletion arch/mips/include/asm/unistd.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@
# endif
#define __ARCH_WANT_SYS_FORK
#define __ARCH_WANT_SYS_CLONE
#define __ARCH_WANT_SYS_CLONE3

/* whitelists for checksyscalls */
#define __IGNORE_fadvise64_64
Expand Down
2 changes: 2 additions & 0 deletions arch/nios2/include/uapi/asm/unistd.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
#define __ARCH_WANT_SET_GET_RLIMIT
#define __ARCH_WANT_TIME32_SYSCALLS

#define __ARCH_BROKEN_SYS_CLONE3

/* Use the standard ABI for syscalls */
#include <asm-generic/unistd.h>

Expand Down
1 change: 0 additions & 1 deletion arch/openrisc/include/uapi/asm/unistd.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
#define __ARCH_WANT_SET_GET_RLIMIT
#define __ARCH_WANT_SYS_FORK
#define __ARCH_WANT_SYS_CLONE
#define __ARCH_WANT_SYS_CLONE3
#define __ARCH_WANT_TIME32_SYSCALLS

#include <asm-generic/unistd.h>
Expand Down
1 change: 0 additions & 1 deletion arch/parisc/include/asm/unistd.h
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,6 @@ type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4, type5 arg5) \
#define __ARCH_WANT_SYS_FORK
#define __ARCH_WANT_SYS_VFORK
#define __ARCH_WANT_SYS_CLONE
#define __ARCH_WANT_SYS_CLONE3
#define __ARCH_WANT_COMPAT_SYS_SENDFILE
#define __ARCH_WANT_COMPAT_STAT

Expand Down
1 change: 0 additions & 1 deletion arch/powerpc/include/asm/unistd.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@
#define __ARCH_WANT_SYS_FORK
#define __ARCH_WANT_SYS_VFORK
#define __ARCH_WANT_SYS_CLONE
#define __ARCH_WANT_SYS_CLONE3

#endif /* __ASSEMBLY__ */
#endif /* _ASM_POWERPC_UNISTD_H_ */
1 change: 0 additions & 1 deletion arch/riscv/include/uapi/asm/unistd.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
#define __ARCH_WANT_SET_GET_RLIMIT
#endif /* __LP64__ */

#define __ARCH_WANT_SYS_CLONE3
#define __ARCH_WANT_MEMFD_SECRET

#include <asm-generic/unistd.h>
Expand Down
1 change: 0 additions & 1 deletion arch/s390/include/asm/unistd.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,5 @@
#define __ARCH_WANT_SYS_FORK
#define __ARCH_WANT_SYS_VFORK
#define __ARCH_WANT_SYS_CLONE
#define __ARCH_WANT_SYS_CLONE3

#endif /* _ASM_S390_UNISTD_H_ */
2 changes: 2 additions & 0 deletions arch/sh/include/asm/unistd.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,6 @@
# define __ARCH_WANT_SYS_VFORK
# define __ARCH_WANT_SYS_CLONE

#define __ARCH_BROKEN_SYS_CLONE3

#include <uapi/asm/unistd.h>
2 changes: 2 additions & 0 deletions arch/sparc/include/asm/unistd.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@
#define __ARCH_WANT_COMPAT_STAT
#endif

#define __ARCH_BROKEN_SYS_CLONE3

#ifdef __32bit_syscall_numbers__
/* Sparc 32-bit only has the "setresuid32", "getresuid32" variants,
* it never had the plain ones and there is no value to adding those
Expand Down
1 change: 0 additions & 1 deletion arch/x86/include/asm/unistd.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,5 @@
# define __ARCH_WANT_SYS_FORK
# define __ARCH_WANT_SYS_VFORK
# define __ARCH_WANT_SYS_CLONE
# define __ARCH_WANT_SYS_CLONE3

#endif /* _ASM_X86_UNISTD_H */
1 change: 0 additions & 1 deletion arch/xtensa/include/asm/unistd.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
#define _XTENSA_UNISTD_H

#define __ARCH_WANT_SYS_CLONE
#define __ARCH_WANT_SYS_CLONE3
#include <uapi/asm/unistd.h>

#define __ARCH_WANT_NEW_STAT
Expand Down
4 changes: 0 additions & 4 deletions include/uapi/asm-generic/unistd.h
Original file line number Diff line number Diff line change
Expand Up @@ -776,12 +776,8 @@ __SYSCALL(__NR_fsmount, sys_fsmount)
__SYSCALL(__NR_fspick, sys_fspick)
#define __NR_pidfd_open 434
__SYSCALL(__NR_pidfd_open, sys_pidfd_open)

#ifdef __ARCH_WANT_SYS_CLONE3
#define __NR_clone3 435
__SYSCALL(__NR_clone3, sys_clone3)
#endif

#define __NR_close_range 436
__SYSCALL(__NR_close_range, sys_close_range)
#define __NR_openat2 437
Expand Down
8 changes: 5 additions & 3 deletions kernel/fork.c
Original file line number Diff line number Diff line change
Expand Up @@ -2941,8 +2941,6 @@ SYSCALL_DEFINE5(clone, unsigned long, clone_flags, unsigned long, newsp,
}
#endif

#ifdef __ARCH_WANT_SYS_CLONE3

noinline static int copy_clone_args_from_user(struct kernel_clone_args *kargs,
struct clone_args __user *uargs,
size_t usize)
Expand Down Expand Up @@ -3086,6 +3084,11 @@ SYSCALL_DEFINE2(clone3, struct clone_args __user *, uargs, size_t, size)
struct kernel_clone_args kargs;
pid_t set_tid[MAX_PID_NS_LEVEL];

#ifdef __ARCH_BROKEN_SYS_CLONE3
#warning clone3() entry point is missing, please fix
return -ENOSYS;
#endif

kargs.set_tid = set_tid;

err = copy_clone_args_from_user(&kargs, uargs, size);
Expand All @@ -3097,7 +3100,6 @@ SYSCALL_DEFINE2(clone3, struct clone_args __user *, uargs, size_t, size)

return kernel_clone(&kargs);
}
#endif

void walk_process_tree(struct task_struct *top, proc_visitor visitor, void *data)
{
Expand Down
2 changes: 0 additions & 2 deletions kernel/sys_ni.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,6 @@ COND_SYSCALL(timerfd_gettime32);
COND_SYSCALL(acct);
COND_SYSCALL(capget);
COND_SYSCALL(capset);
/* __ARCH_WANT_SYS_CLONE3 */
COND_SYSCALL(clone3);
COND_SYSCALL(futex);
COND_SYSCALL(futex_time32);
COND_SYSCALL(set_robust_list);
Expand Down
1 change: 0 additions & 1 deletion tools/arch/arm64/include/uapi/asm/unistd.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
#define __ARCH_WANT_NEW_STAT
#define __ARCH_WANT_SET_GET_RLIMIT
#define __ARCH_WANT_TIME32_SYSCALLS
#define __ARCH_WANT_SYS_CLONE3
#define __ARCH_WANT_MEMFD_SECRET

#include <asm-generic/unistd.h>
1 change: 0 additions & 1 deletion tools/arch/loongarch/include/uapi/asm/unistd.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,5 @@
*/

#define __ARCH_WANT_SYS_CLONE
#define __ARCH_WANT_SYS_CLONE3

#include <asm-generic/unistd.h>
4 changes: 0 additions & 4 deletions tools/include/uapi/asm-generic/unistd.h
Original file line number Diff line number Diff line change
Expand Up @@ -776,12 +776,8 @@ __SYSCALL(__NR_fsmount, sys_fsmount)
__SYSCALL(__NR_fspick, sys_fspick)
#define __NR_pidfd_open 434
__SYSCALL(__NR_pidfd_open, sys_pidfd_open)

#ifdef __ARCH_WANT_SYS_CLONE3
#define __NR_clone3 435
__SYSCALL(__NR_clone3, sys_clone3)
#endif

#define __NR_close_range 436
__SYSCALL(__NR_close_range, sys_close_range)
#define __NR_openat2 437
Expand Down

0 comments on commit 505d66d

Please sign in to comment.