]> git.baikalelectronics.ru Git - kernel.git/commit
MIPS: Avoid clobbering struct pt_regs in kthreads
authorDavid Daney <ddaney@caviumnetworks.com>
Wed, 8 Jul 2009 17:07:50 +0000 (10:07 -0700)
committerRalf Baechle <ralf@linux-mips.org>
Mon, 3 Aug 2009 16:52:41 +0000 (17:52 +0100)
commitb7da2b9fb0d6ec1421bc55611df4992f57d31c30
treef511d75b729c331260bc544a0f03b7d5bea26d9a
parent453c1afb500a2d156931d03223bd7e42f02c8bf8
MIPS: Avoid clobbering struct pt_regs in kthreads

The resume() implementation octeon_switch.S examines the saved cp0_status
register.  We were clobbering the entire pt_regs structure in kernel
threads leading to random crashes.

When switching away from a kernel thread, the saved cp0_status is examined
and if bit 30 is set it is cleared and the CP2 state saved into the pt_regs
structure.  Since the kernel thread stack overlaid the pt_regs structure
this resulted in a corrupt stack.  When the kthread with the corrupt stack
was resumed, it could crash if it used any of the data in the stack that was
clobbered.

We fix it by moving the kernel thread stack down so it doesn't overlay
pt_regs.

Signed-off-by: David Daney <ddaney@caviumnetworks.com>
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
arch/mips/include/asm/processor.h
arch/mips/kernel/head.S
arch/mips/kernel/process.c