]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blame - 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
CommitLineData
87d2113e
GKH
1From 81a76d7119f63c359750e4adeff922a31ad1135f Mon Sep 17 00:00:00 2001
2From: James Hogan <james.hogan@imgtec.com>
3Date: Fri, 4 Dec 2015 22:25:02 +0000
4Subject: MIPS: Avoid using unwind_stack() with usermode
5
6From: James Hogan <james.hogan@imgtec.com>
7
8commit 81a76d7119f63c359750e4adeff922a31ad1135f upstream.
9
10When showing backtraces in response to traps, for example crashes and
11address errors (usually unaligned accesses) when they are set in debugfs
12to be reported, unwind_stack will be used if the PC was in the kernel
13text address range. However since EVA it is possible for user and kernel
14address ranges to overlap, and even without EVA userland can still
15trigger an address error by jumping to a KSeg0 address.
16
17Adjust the check to also ensure that it was running in kernel mode. I
18don't believe any harm can come of this problem, since unwind_stack() is
19sufficiently defensive, however it is only meant for unwinding kernel
20code, so to be correct it should use the raw backtracing instead.
21
22Signed-off-by: James Hogan <james.hogan@imgtec.com>
23Reviewed-by: Leonid Yegoshin <Leonid.Yegoshin@imgtec.com>
24Cc: linux-mips@linux-mips.org
25Patchwork: https://patchwork.linux-mips.org/patch/11701/
26Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
27(cherry picked from commit d2941a975ac745c607dfb590e92bb30bc352dad9)
28Signed-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 }