Skip to content

Commit 457677c

Browse files
AmanieuChristian Brauner
authored andcommitted
um: Implement copy_thread_tls
This is required for clone3 which passes the TLS value through a struct rather than a register. Signed-off-by: Amanieu d'Antras <[email protected]> Cc: [email protected] Cc: <[email protected]> # 5.3.x Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Christian Brauner <[email protected]>
1 parent dd499f7 commit 457677c

File tree

5 files changed

+10
-12
lines changed

5 files changed

+10
-12
lines changed

arch/um/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ config UML
1414
select HAVE_FUTEX_CMPXCHG if FUTEX
1515
select HAVE_DEBUG_KMEMLEAK
1616
select HAVE_DEBUG_BUGVERBOSE
17+
select HAVE_COPY_THREAD_TLS
1718
select GENERIC_IRQ_SHOW
1819
select GENERIC_CPU_DEVICES
1920
select GENERIC_CLOCKEVENTS

arch/um/include/asm/ptrace-generic.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ extern long subarch_ptrace(struct task_struct *child, long request,
3636
extern unsigned long getreg(struct task_struct *child, int regno);
3737
extern int putreg(struct task_struct *child, int regno, unsigned long value);
3838

39-
extern int arch_copy_tls(struct task_struct *new);
39+
extern int arch_set_tls(struct task_struct *new, unsigned long tls);
4040
extern void clear_flushed_tls(struct task_struct *task);
4141
extern int syscall_trace_enter(struct pt_regs *regs);
4242
extern void syscall_trace_leave(struct pt_regs *regs);

arch/um/kernel/process.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -153,8 +153,8 @@ void fork_handler(void)
153153
userspace(&current->thread.regs.regs, current_thread_info()->aux_fp_regs);
154154
}
155155

156-
int copy_thread(unsigned long clone_flags, unsigned long sp,
157-
unsigned long arg, struct task_struct * p)
156+
int copy_thread_tls(unsigned long clone_flags, unsigned long sp,
157+
unsigned long arg, struct task_struct * p, unsigned long tls)
158158
{
159159
void (*handler)(void);
160160
int kthread = current->flags & PF_KTHREAD;
@@ -188,7 +188,7 @@ int copy_thread(unsigned long clone_flags, unsigned long sp,
188188
* Set a new TLS for the child thread?
189189
*/
190190
if (clone_flags & CLONE_SETTLS)
191-
ret = arch_copy_tls(p);
191+
ret = arch_set_tls(p, tls);
192192
}
193193

194194
return ret;

arch/x86/um/tls_32.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -215,14 +215,12 @@ static int set_tls_entry(struct task_struct* task, struct user_desc *info,
215215
return 0;
216216
}
217217

218-
int arch_copy_tls(struct task_struct *new)
218+
int arch_set_tls(struct task_struct *new, unsigned long tls)
219219
{
220220
struct user_desc info;
221221
int idx, ret = -EFAULT;
222222

223-
if (copy_from_user(&info,
224-
(void __user *) UPT_SI(&new->thread.regs.regs),
225-
sizeof(info)))
223+
if (copy_from_user(&info, (void __user *) tls, sizeof(info)))
226224
goto out;
227225

228226
ret = -EINVAL;

arch/x86/um/tls_64.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,13 @@ void clear_flushed_tls(struct task_struct *task)
66
{
77
}
88

9-
int arch_copy_tls(struct task_struct *t)
9+
int arch_set_tls(struct task_struct *t, unsigned long tls)
1010
{
1111
/*
1212
* If CLONE_SETTLS is set, we need to save the thread id
13-
* (which is argument 5, child_tid, of clone) so it can be set
14-
* during context switches.
13+
* so it can be set during context switches.
1514
*/
16-
t->thread.arch.fs = t->thread.regs.regs.gp[R8 / sizeof(long)];
15+
t->thread.arch.fs = tls;
1716

1817
return 0;
1918
}

0 commit comments

Comments
 (0)