Skip to content

Commit bc4cf2b

Browse files
arch/tile: handle CLONE_SETTLS in copy_thread(), not user space
Previously we were just setting up the "tp" register in the new task as started by clone() in libc. However, this is not quite right, since in principle a signal might be delivered to the new task before it had its TLS set up. (Of course, this race window still exists for resetting the libc getpid() cached value in the new task, in principle. But in any case, we are now doing this exactly the way all other architectures do it.) This change is important for 2.6.37 since the tile glibc we will be submitting upstream will not set TLS in user space any more, so it will only work on a kernel that has this fix. It should also be taken for 2.6.36.x in the stable tree if possible. Signed-off-by: Chris Metcalf <[email protected]> Cc: stable <[email protected]>
1 parent 5111711 commit bc4cf2b

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

arch/tile/kernel/process.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,13 @@ int copy_thread(unsigned long clone_flags, unsigned long sp,
211211
childregs->regs[0] = 0; /* return value is zero */
212212
childregs->sp = sp; /* override with new user stack pointer */
213213

214+
/*
215+
* If CLONE_SETTLS is set, set "tp" in the new task to "r4",
216+
* which is passed in as arg #5 to sys_clone().
217+
*/
218+
if (clone_flags & CLONE_SETTLS)
219+
childregs->tp = regs->regs[4];
220+
214221
/*
215222
* Copy the callee-saved registers from the passed pt_regs struct
216223
* into the context-switch callee-saved registers area.
@@ -539,6 +546,7 @@ struct task_struct *__sched _switch_to(struct task_struct *prev,
539546
return __switch_to(prev, next, next_current_ksp0(next));
540547
}
541548

549+
/* Note there is an implicit fifth argument if (clone_flags & CLONE_SETTLS). */
542550
SYSCALL_DEFINE5(clone, unsigned long, clone_flags, unsigned long, newsp,
543551
void __user *, parent_tidptr, void __user *, child_tidptr,
544552
struct pt_regs *, regs)

0 commit comments

Comments
 (0)