Skip to content

Commit b0f5a8f

Browse files
vegardtorvalds
authored andcommitted
kthread: fix boot hang (regression) on MIPS/OpenRISC
This fixes a regression in commit 4d6501d where I didn't notice that MIPS and OpenRISC were reinitialising p->{set,clear}_child_tid to NULL after our initialisation in copy_process(). We can simply get rid of the arch-specific initialisation here since it is now always done in copy_process() before hitting copy_thread{,_tls}(). Review notes: - As far as I can tell, copy_process() is the only user of copy_thread_tls(), which is the only caller of copy_thread() for architectures that don't implement copy_thread_tls(). - After this patch, there is no arch-specific code touching p->set_child_tid or p->clear_child_tid whatsoever. - It may look like MIPS/OpenRISC wanted to always have these fields be NULL, but that's not true, as copy_process() would unconditionally set them again _after_ calling copy_thread_tls() before commit 4d6501d. Fixes: 4d6501d ("kthread: Fix use-after-free if kthread fork fails") Reported-by: Guenter Roeck <linux@roeck-us.net> Tested-by: Guenter Roeck <linux@roeck-us.net> # MIPS only Acked-by: Stafford Horne <shorne@gmail.com> Acked-by: Oleg Nesterov <oleg@redhat.com> Cc: Ralf Baechle <ralf@linux-mips.org> Cc: linux-mips@linux-mips.org Cc: Jonas Bonn <jonas@southpole.se> Cc: Stefan Kristiansson <stefan.kristiansson@saunalahti.fi> Cc: openrisc@lists.librecores.org Cc: Jamie Iles <jamie.iles@oracle.com> Cc: Thomas Gleixner <tglx@linutronix.de> Signed-off-by: Vegard Nossum <vegard.nossum@oracle.com> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 5ed02db commit b0f5a8f

2 files changed

Lines changed: 0 additions & 3 deletions

File tree

‎arch/mips/kernel/process.c‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,6 @@ int copy_thread_tls(unsigned long clone_flags, unsigned long usp,
120120
struct thread_info *ti = task_thread_info(p);
121121
struct pt_regs *childregs, *regs = current_pt_regs();
122122
unsigned long childksp;
123-
p->set_child_tid = p->clear_child_tid = NULL;
124123

125124
childksp = (unsigned long)task_stack_page(p) + THREAD_SIZE - 32;
126125

‎arch/openrisc/kernel/process.c‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,8 +167,6 @@ copy_thread(unsigned long clone_flags, unsigned long usp,
167167

168168
top_of_kernel_stack = sp;
169169

170-
p->set_child_tid = p->clear_child_tid = NULL;
171-
172170
/* Locate userspace context on stack... */
173171
sp -= STACK_FRAME_OVERHEAD; /* redzone */
174172
sp -= sizeof(struct pt_regs);

0 commit comments

Comments
 (0)