]> git.karo-electronics.de Git - karo-tx-linux.git/commit
MIPS: Prevent unaligned accesses during stack unwinding
authorPaul Burton <paul.burton@imgtec.com>
Mon, 7 Nov 2016 15:07:03 +0000 (15:07 +0000)
committerRalf Baechle <ralf@linux-mips.org>
Tue, 3 Jan 2017 15:34:36 +0000 (16:34 +0100)
commita3552dace7d1d0cabf573e88fc3025cb90c4a601
tree13c516666d5b27ecca831ab9594f02cb5b4c0ec5
parentccaf7caf2c73c6db920772bf08bf1d47b2170634
MIPS: Prevent unaligned accesses during stack unwinding

During stack unwinding we call a number of functions to determine what
type of instruction we're looking at. The union mips_instruction pointer
provided to them may be pointing at a 2 byte, but not 4 byte, aligned
address & we thus cannot directly access the 4 byte wide members of the
union mips_instruction. To avoid this is_ra_save_ins() copies the
required half-words of the microMIPS instruction to a correctly aligned
union mips_instruction on the stack, which it can then access safely.
The is_jump_ins() & is_sp_move_ins() functions do not correctly perform
this temporary copy, and instead attempt to directly dereference 4 byte
fields which may be misaligned and lead to an address exception.

Fix this by copying the instruction halfwords to a temporary union
mips_instruction in get_frame_info() such that we can provide a 4 byte
aligned union mips_instruction to the is_*_ins() functions and they do
not need to deal with misalignment themselves.

Signed-off-by: Paul Burton <paul.burton@imgtec.com>
Fixes: 34c2f668d0f6 ("MIPS: microMIPS: Add unaligned access support.")
Cc: Leonid Yegoshin <leonid.yegoshin@imgtec.com>
Cc: linux-mips@linux-mips.org
Cc: <stable@vger.kernel.org> # v3.10+
Patchwork: https://patchwork.linux-mips.org/patch/14529/
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
arch/mips/kernel/process.c