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

Configure Feed

Select the types of activity you want to include in your feed.

fork: kill the pointless lower_32_bits() in create_io_thread(), kernel_thread(), and user_mode_thread()

Unlike sys_clone(), these helpers have only in kernel users which should
pass the correct "flags" argument. lower_32_bits(flags) just adds the
unnecessary confusion and doesn't allow to use the CLONE_ flags which
don't fit into 32 bits.

create_io_thread() looks especially confusing because:

- "flags" is a compile-time constant, so lower_32_bits() simply
has no effect

- .exit_signal = (lower_32_bits(flags) & CSIGNAL) is harmless but
doesn't look right, copy_process(CLONE_THREAD) will ignore this
argument anyway.

None of these helpers actually need CLONE_UNTRACED or "& ~CSIGNAL", but
their presence does not add any confusion and improves code clarity.

Link: https://lkml.kernel.org/r/20250820163946.GA18549@redhat.com
Signed-off-by: Oleg Nesterov <oleg@redhat.com>
Reviewed-by: Jens Axboe <axboe@kernel.dk>
Cc: Christian Brauner <brauner@kernel.org>
Cc: Kees Cook <kees@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Oleg Nesterov and committed by
Andrew Morton
f7071db2 b32730e6

+6 -10
+6 -10
kernel/fork.c
··· 2537 2537 struct task_struct *create_io_thread(int (*fn)(void *), void *arg, int node) 2538 2538 { 2539 2539 unsigned long flags = CLONE_FS|CLONE_FILES|CLONE_SIGHAND|CLONE_THREAD| 2540 - CLONE_IO; 2540 + CLONE_IO|CLONE_VM|CLONE_UNTRACED; 2541 2541 struct kernel_clone_args args = { 2542 - .flags = ((lower_32_bits(flags) | CLONE_VM | 2543 - CLONE_UNTRACED) & ~CSIGNAL), 2544 - .exit_signal = (lower_32_bits(flags) & CSIGNAL), 2542 + .flags = flags, 2545 2543 .fn = fn, 2546 2544 .fn_arg = arg, 2547 2545 .io_thread = 1, ··· 2651 2653 unsigned long flags) 2652 2654 { 2653 2655 struct kernel_clone_args args = { 2654 - .flags = ((lower_32_bits(flags) | CLONE_VM | 2655 - CLONE_UNTRACED) & ~CSIGNAL), 2656 - .exit_signal = (lower_32_bits(flags) & CSIGNAL), 2656 + .flags = ((flags | CLONE_VM | CLONE_UNTRACED) & ~CSIGNAL), 2657 + .exit_signal = (flags & CSIGNAL), 2657 2658 .fn = fn, 2658 2659 .fn_arg = arg, 2659 2660 .name = name, ··· 2668 2671 pid_t user_mode_thread(int (*fn)(void *), void *arg, unsigned long flags) 2669 2672 { 2670 2673 struct kernel_clone_args args = { 2671 - .flags = ((lower_32_bits(flags) | CLONE_VM | 2672 - CLONE_UNTRACED) & ~CSIGNAL), 2673 - .exit_signal = (lower_32_bits(flags) & CSIGNAL), 2674 + .flags = ((flags | CLONE_VM | CLONE_UNTRACED) & ~CSIGNAL), 2675 + .exit_signal = (flags & CSIGNAL), 2674 2676 .fn = fn, 2675 2677 .fn_arg = arg, 2676 2678 };