MIPS: MSC: Prevent out-of-bounds writes to MIPS SC ioremap'd region
authorMarkos Chandras <markos.chandras@imgtec.com>
Mon, 23 Jun 2014 08:48:51 +0000 (09:48 +0100)
committerBen Hutchings <ben@decadent.org.uk>
Fri, 11 Jul 2014 12:33:55 +0000 (13:33 +0100)
commit167dc42e69226e50b97b44f0777a387ab1a932cc
tree7d88af66fbc0a509b1ffb1e1f9d94bb672f62057
parentbdcdb4312cfd2f45bfc4887cc34dcc1956db48f4
MIPS: MSC: Prevent out-of-bounds writes to MIPS SC ioremap'd region

commit ab6c15bc6620ebe220970cc040b29bcb2757f373 upstream.

Previously, the lower limit for the MIPS SC initialization loop was
set incorrectly allowing one extra loop leading to writes
beyond the MSC ioremap'd space. More precisely, the value of the 'imp'
in the last loop increased beyond the msc_irqmap_t boundaries and
as a result of which, the 'n' variable was loaded with an incorrect
value. This value was used later on to calculate the offset in the
MSC01_IC_SUP which led to random crashes like the following one:

CPU 0 Unable to handle kernel paging request at virtual address e75c0200,
epc == 8058dba4, ra == 8058db90
[...]
Call Trace:
[<8058dba4>] init_msc_irqs+0x104/0x154
[<8058b5bc>] arch_init_irq+0xd8/0x154
[<805897b0>] start_kernel+0x220/0x36c

Kernel panic - not syncing: Attempted to kill the idle task!

This patch fixes the problem

Signed-off-by: Markos Chandras <markos.chandras@imgtec.com>
Reviewed-by: James Hogan <james.hogan@imgtec.com>
Cc: linux-mips@linux-mips.org
Patchwork: https://patchwork.linux-mips.org/patch/7118/
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
arch/mips/kernel/irq-msc01.c