Skip to content

Commit c5febea

Browse files
committed
fork: Pass struct kernel_clone_args into copy_thread
With io_uring we have started supporting tasks that are for most purposes user space tasks that exclusively run code in kernel mode. The kernel task that exec's init and tasks that exec user mode helpers are also user mode tasks that just run kernel code until they call kernel execve. Pass kernel_clone_args into copy_thread so these oddball tasks can be supported more cleanly and easily. v2: Fix spelling of kenrel_clone_args on h8300 Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: "Eric W. Biederman" <[email protected]>
1 parent 343f4c4 commit c5febea

File tree

25 files changed

+116
-58
lines changed

25 files changed

+116
-58
lines changed

arch/alpha/kernel/process.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -233,10 +233,12 @@ release_thread(struct task_struct *dead_task)
233233
/*
234234
* Copy architecture-specific thread state
235235
*/
236-
int copy_thread(unsigned long clone_flags, unsigned long usp,
237-
unsigned long kthread_arg, struct task_struct *p,
238-
unsigned long tls)
236+
int copy_thread(struct task_struct *p, const struct kernel_clone_args *args)
239237
{
238+
unsigned long clone_flags = args->flags;
239+
unsigned long usp = args->stack;
240+
unsigned long kthread_arg = args->stack_size;
241+
unsigned long tls = args->tls;
240242
extern void ret_from_fork(void);
241243
extern void ret_from_kernel_thread(void);
242244

arch/arc/kernel/process.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -162,10 +162,12 @@ asmlinkage void ret_from_fork(void);
162162
* | user_r25 |
163163
* ------------------ <===== END of PAGE
164164
*/
165-
int copy_thread(unsigned long clone_flags, unsigned long usp,
166-
unsigned long kthread_arg, struct task_struct *p,
167-
unsigned long tls)
165+
int copy_thread(struct task_struct *p, const struct kernel_clone_args *args)
168166
{
167+
unsigned long clone_flags = args->flags;
168+
unsigned long usp = args->stack;
169+
unsigned long kthread_arg = args->stack_size;
170+
unsigned long tls = args->tls;
169171
struct pt_regs *c_regs; /* child's pt_regs */
170172
unsigned long *childksp; /* to unwind out of __switch_to() */
171173
struct callee_regs *c_callee; /* child's callee regs */

arch/arm/kernel/process.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -238,9 +238,12 @@ void release_thread(struct task_struct *dead_task)
238238

239239
asmlinkage void ret_from_fork(void) __asm__("ret_from_fork");
240240

241-
int copy_thread(unsigned long clone_flags, unsigned long stack_start,
242-
unsigned long stk_sz, struct task_struct *p, unsigned long tls)
241+
int copy_thread(struct task_struct *p, const struct kernel_clone_args *args)
243242
{
243+
unsigned long clone_flags = args->flags;
244+
unsigned long stack_start = args->stack;
245+
unsigned long stk_sz = args->stack_size;
246+
unsigned long tls = args->tls;
244247
struct thread_info *thread = task_thread_info(p);
245248
struct pt_regs *childregs = task_pt_regs(p);
246249

arch/arm64/kernel/process.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -316,9 +316,12 @@ int arch_dup_task_struct(struct task_struct *dst, struct task_struct *src)
316316

317317
asmlinkage void ret_from_fork(void) asm("ret_from_fork");
318318

319-
int copy_thread(unsigned long clone_flags, unsigned long stack_start,
320-
unsigned long stk_sz, struct task_struct *p, unsigned long tls)
319+
int copy_thread(struct task_struct *p, const struct kernel_clone_args *args)
321320
{
321+
unsigned long clone_flags = args->flags;
322+
unsigned long stack_start = args->stack;
323+
unsigned long stk_sz = args->stack_size;
324+
unsigned long tls = args->tls;
322325
struct pt_regs *childregs = task_pt_regs(p);
323326

324327
memset(&p->thread.cpu_context, 0, sizeof(struct cpu_context));

arch/csky/kernel/process.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,12 @@ asmlinkage void ret_from_kernel_thread(void);
3030
*/
3131
void flush_thread(void){}
3232

33-
int copy_thread(unsigned long clone_flags,
34-
unsigned long usp,
35-
unsigned long kthread_arg,
36-
struct task_struct *p,
37-
unsigned long tls)
33+
int copy_thread(struct task_struct *p, const struct kernel_clone_args *args)
3834
{
35+
unsigned long clone_flags = args->flags;
36+
unsigned long usp = args->stack;
37+
unsigned long kthread_arg = args->stack_size;
38+
unsigned long tls = args->tls;
3939
struct switch_stack *childstack;
4040
struct pt_regs *childregs = task_pt_regs(p);
4141

arch/h8300/kernel/process.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,10 @@ void flush_thread(void)
105105
{
106106
}
107107

108-
int copy_thread(unsigned long clone_flags, unsigned long usp,
109-
unsigned long topstk, struct task_struct *p, unsigned long tls)
108+
int copy_thread(struct task_struct *p, const struct kernel_clone_args *args)
110109
{
110+
unsigned long usp = args->stack;
111+
unsigned long topstk = args->stack_size;
111112
struct pt_regs *childregs;
112113

113114
childregs = (struct pt_regs *) (THREAD_SIZE + task_stack_page(p)) - 1;

arch/hexagon/kernel/process.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,12 @@ void arch_cpu_idle(void)
5050
/*
5151
* Copy architecture-specific thread state
5252
*/
53-
int copy_thread(unsigned long clone_flags, unsigned long usp, unsigned long arg,
54-
struct task_struct *p, unsigned long tls)
53+
int copy_thread(struct task_struct *p, const struct kernel_clone_args *args)
5554
{
55+
unsigned long clone_flags = args->flags;
56+
unsigned long usp = args->stack;
57+
unsigned long arg = args->stack_size;
58+
unsigned long tls = args->tls;
5659
struct thread_info *ti = task_thread_info(p);
5760
struct hexagon_switch_stack *ss;
5861
struct pt_regs *childregs;

arch/ia64/kernel/process.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -295,9 +295,12 @@ ia64_load_extra (struct task_struct *task)
295295
* so there is nothing to worry about.
296296
*/
297297
int
298-
copy_thread(unsigned long clone_flags, unsigned long user_stack_base,
299-
unsigned long user_stack_size, struct task_struct *p, unsigned long tls)
298+
copy_thread(struct task_struct *p, const struct kernel_clone_args *args)
300299
{
300+
unsigned long clone_flags = args->flags;
301+
unsigned long user_stack_base = args->stack;
302+
unsigned long user_stack_size = args->stack_size;
303+
unsigned long tls = args->tls;
301304
extern char ia64_ret_from_clone;
302305
struct switch_stack *child_stack, *stack;
303306
unsigned long rbs, child_rbs, rbs_size;

arch/m68k/kernel/process.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,9 +138,12 @@ asmlinkage int m68k_clone3(struct pt_regs *regs)
138138
return sys_clone3((struct clone_args __user *)regs->d1, regs->d2);
139139
}
140140

141-
int copy_thread(unsigned long clone_flags, unsigned long usp, unsigned long arg,
142-
struct task_struct *p, unsigned long tls)
141+
int copy_thread(struct task_struct *p, const struct kernel_clone_args *args)
143142
{
143+
unsigned long clone_flags = args->flags;
144+
unsigned long usp = args->stack;
145+
unsigned long arg = args->stack_size;
146+
unsigned long tls = args->tls;
144147
struct fork_frame {
145148
struct switch_stack sw;
146149
struct pt_regs regs;

arch/microblaze/kernel/process.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,12 @@ void flush_thread(void)
5252
{
5353
}
5454

55-
int copy_thread(unsigned long clone_flags, unsigned long usp, unsigned long arg,
56-
struct task_struct *p, unsigned long tls)
55+
int copy_thread(struct task_struct *p, const struct kernel_clone_args *args)
5756
{
57+
unsigned long clone_flags = args->flags;
58+
unsigned long usp = args->stack;
59+
unsigned long arg = args->stack_size;
60+
unsigned long tls = args->tls;
5861
struct pt_regs *childregs = task_pt_regs(p);
5962
struct thread_info *ti = task_thread_info(p);
6063

0 commit comments

Comments
 (0)