Skip to content

Commit

Permalink
sh: Fix kernel thread stack corruption with preempt.
Browse files Browse the repository at this point in the history
When I run a preemptive kernel-2.6.20 for SH7780, a created
kthread(pdflush) can not exit by do_exit() in kernel_thread_helper. I
think that the created kthread should have a room for 'struct pt_regs'
space on the stack top, because __switch_to() will refer to the space as
follows using 'regs = task_pt_regs(prev)' and next condition may be true.

Signed-off-by: Hideo Saito <[email protected]>
Signed-off-by: Paul Mundt <[email protected]>
  • Loading branch information
Hideo Saito authored and pmundt committed Mar 5, 2007
1 parent e523d93 commit e6bcf56
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions arch/sh/kernel/process.c
Original file line number Diff line number Diff line change
Expand Up @@ -250,12 +250,11 @@ int copy_thread(int nr, unsigned long clone_flags, unsigned long usp,
childregs->regs[15] = usp;
ti->addr_limit = USER_DS;
} else {
childregs->regs[15] = (unsigned long)task_stack_page(p) +
THREAD_SIZE;
childregs->regs[15] = (unsigned long)childregs;
ti->addr_limit = KERNEL_DS;
}

if (clone_flags & CLONE_SETTLS)
if (clone_flags & CLONE_SETTLS)
childregs->gbr = childregs->regs[0];

childregs->regs[0] = 0; /* Set return value for child */
Expand Down

0 comments on commit e6bcf56

Please sign in to comment.