]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - releases/4.4.13/mips-avoid-using-unwind_stack-with-usermode.patch
4.9-stable patches
[thirdparty/kernel/stable-queue.git] / releases / 4.4.13 / mips-avoid-using-unwind_stack-with-usermode.patch
1 From 81a76d7119f63c359750e4adeff922a31ad1135f Mon Sep 17 00:00:00 2001
2 From: James Hogan <james.hogan@imgtec.com>
3 Date: Fri, 4 Dec 2015 22:25:02 +0000
4 Subject: MIPS: Avoid using unwind_stack() with usermode
5
6 From: James Hogan <james.hogan@imgtec.com>
7
8 commit 81a76d7119f63c359750e4adeff922a31ad1135f upstream.
9
10 When showing backtraces in response to traps, for example crashes and
11 address errors (usually unaligned accesses) when they are set in debugfs
12 to be reported, unwind_stack will be used if the PC was in the kernel
13 text address range. However since EVA it is possible for user and kernel
14 address ranges to overlap, and even without EVA userland can still
15 trigger an address error by jumping to a KSeg0 address.
16
17 Adjust the check to also ensure that it was running in kernel mode. I
18 don't believe any harm can come of this problem, since unwind_stack() is
19 sufficiently defensive, however it is only meant for unwinding kernel
20 code, so to be correct it should use the raw backtracing instead.
21
22 Signed-off-by: James Hogan <james.hogan@imgtec.com>
23 Reviewed-by: Leonid Yegoshin <Leonid.Yegoshin@imgtec.com>
24 Cc: linux-mips@linux-mips.org
25 Patchwork: https://patchwork.linux-mips.org/patch/11701/
26 Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
27 (cherry picked from commit d2941a975ac745c607dfb590e92bb30bc352dad9)
28 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
29
30 ---
31 arch/mips/kernel/traps.c | 2 +-
32 1 file changed, 1 insertion(+), 1 deletion(-)
33
34 --- a/arch/mips/kernel/traps.c
35 +++ b/arch/mips/kernel/traps.c
36 @@ -144,7 +144,7 @@ static void show_backtrace(struct task_s
37 if (!task)
38 task = current;
39
40 - if (raw_show_trace || !__kernel_text_address(pc)) {
41 + if (raw_show_trace || user_mode(regs) || !__kernel_text_address(pc)) {
42 show_raw_backtrace(sp);
43 return;
44 }