Skip to content

Commit bbc46b2

Browse files
Simon Schusterbrauner
authored andcommitted
arch: copy_thread: pass clone_flags as u64
With the introduction of clone3 in commit 7f192e3 ("fork: add clone3") the effective bit width of clone_flags on all architectures was increased from 32-bit to 64-bit, with a new type of u64 for the flags. However, for most consumers of clone_flags the interface was not changed from the previous type of unsigned long. While this works fine as long as none of the new 64-bit flag bits (CLONE_CLEAR_SIGHAND and CLONE_INTO_CGROUP) are evaluated, this is still undesirable in terms of the principle of least surprise. Thus, this commit fixes all relevant interfaces of the copy_thread function that is called from copy_process to consistently pass clone_flags as u64, so that no truncation to 32-bit integers occurs on 32-bit architectures. Signed-off-by: Simon Schuster <schuster.simon@siemens-energy.com> Link: https://lore.kernel.org/20250901-nios2-implement-clone3-v2-3-53fcf5577d57@siemens-energy.com Fixes: c5febea ("fork: Pass struct kernel_clone_args into copy_thread") Acked-by: Guo Ren (Alibaba Damo Academy) <guoren@kernel.org> Acked-by: Andreas Larsson <andreas@gaisler.com> # sparc Acked-by: David Hildenbrand <david@redhat.com> Acked-by: Geert Uytterhoeven <geert@linux-m68k.org> # m68k Reviewed-by: Arnd Bergmann <arnd@arndb.de> Signed-off-by: Christian Brauner <brauner@kernel.org>
1 parent edd3cb0 commit bbc46b2

26 files changed

Lines changed: 27 additions & 27 deletions

File tree

arch/alpha/kernel/process.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ flush_thread(void)
231231
*/
232232
int copy_thread(struct task_struct *p, const struct kernel_clone_args *args)
233233
{
234-
unsigned long clone_flags = args->flags;
234+
u64 clone_flags = args->flags;
235235
unsigned long usp = args->stack;
236236
unsigned long tls = args->tls;
237237
extern void ret_from_fork(void);

arch/arc/kernel/process.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ asmlinkage void ret_from_fork(void);
166166
*/
167167
int copy_thread(struct task_struct *p, const struct kernel_clone_args *args)
168168
{
169-
unsigned long clone_flags = args->flags;
169+
u64 clone_flags = args->flags;
170170
unsigned long usp = args->stack;
171171
unsigned long tls = args->tls;
172172
struct pt_regs *c_regs; /* child's pt_regs */

arch/arm/kernel/process.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ asmlinkage void ret_from_fork(void) __asm__("ret_from_fork");
234234

235235
int copy_thread(struct task_struct *p, const struct kernel_clone_args *args)
236236
{
237-
unsigned long clone_flags = args->flags;
237+
u64 clone_flags = args->flags;
238238
unsigned long stack_start = args->stack;
239239
unsigned long tls = args->tls;
240240
struct thread_info *thread = task_thread_info(p);

arch/arm64/kernel/process.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -409,7 +409,7 @@ asmlinkage void ret_from_fork(void) asm("ret_from_fork");
409409

410410
int copy_thread(struct task_struct *p, const struct kernel_clone_args *args)
411411
{
412-
unsigned long clone_flags = args->flags;
412+
u64 clone_flags = args->flags;
413413
unsigned long stack_start = args->stack;
414414
unsigned long tls = args->tls;
415415
struct pt_regs *childregs = task_pt_regs(p);

arch/csky/kernel/process.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ void flush_thread(void){}
3232

3333
int copy_thread(struct task_struct *p, const struct kernel_clone_args *args)
3434
{
35-
unsigned long clone_flags = args->flags;
35+
u64 clone_flags = args->flags;
3636
unsigned long usp = args->stack;
3737
unsigned long tls = args->tls;
3838
struct switch_stack *childstack;

arch/hexagon/kernel/process.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ void arch_cpu_idle(void)
5252
*/
5353
int copy_thread(struct task_struct *p, const struct kernel_clone_args *args)
5454
{
55-
unsigned long clone_flags = args->flags;
55+
u64 clone_flags = args->flags;
5656
unsigned long usp = args->stack;
5757
unsigned long tls = args->tls;
5858
struct thread_info *ti = task_thread_info(p);

arch/loongarch/kernel/process.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ int copy_thread(struct task_struct *p, const struct kernel_clone_args *args)
167167
unsigned long childksp;
168168
unsigned long tls = args->tls;
169169
unsigned long usp = args->stack;
170-
unsigned long clone_flags = args->flags;
170+
u64 clone_flags = args->flags;
171171
struct pt_regs *childregs, *regs = current_pt_regs();
172172

173173
childksp = (unsigned long)task_stack_page(p) + THREAD_SIZE;

arch/m68k/kernel/process.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ asmlinkage int m68k_clone3(struct pt_regs *regs)
141141

142142
int copy_thread(struct task_struct *p, const struct kernel_clone_args *args)
143143
{
144-
unsigned long clone_flags = args->flags;
144+
u64 clone_flags = args->flags;
145145
unsigned long usp = args->stack;
146146
unsigned long tls = args->tls;
147147
struct fork_frame {

arch/microblaze/kernel/process.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ void flush_thread(void)
5454

5555
int copy_thread(struct task_struct *p, const struct kernel_clone_args *args)
5656
{
57-
unsigned long clone_flags = args->flags;
57+
u64 clone_flags = args->flags;
5858
unsigned long usp = args->stack;
5959
unsigned long tls = args->tls;
6060
struct pt_regs *childregs = task_pt_regs(p);

arch/mips/kernel/process.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ int arch_dup_task_struct(struct task_struct *dst, struct task_struct *src)
107107
*/
108108
int copy_thread(struct task_struct *p, const struct kernel_clone_args *args)
109109
{
110-
unsigned long clone_flags = args->flags;
110+
u64 clone_flags = args->flags;
111111
unsigned long usp = args->stack;
112112
unsigned long tls = args->tls;
113113
struct thread_info *ti = task_thread_info(p);

0 commit comments

Comments
 (0)