]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - queue-4.19/arm64-backtrace-don-t-bother-trying-to-unwind-the-userspace-stack.patch
Linux 4.14.112
[thirdparty/kernel/stable-queue.git] / queue-4.19 / arm64-backtrace-don-t-bother-trying-to-unwind-the-userspace-stack.patch
1 From 1e6f5440a6814d28c32d347f338bfef68bc3e69d Mon Sep 17 00:00:00 2001
2 From: Will Deacon <will.deacon@arm.com>
3 Date: Mon, 8 Apr 2019 17:56:34 +0100
4 Subject: arm64: backtrace: Don't bother trying to unwind the userspace stack
5
6 From: Will Deacon <will.deacon@arm.com>
7
8 commit 1e6f5440a6814d28c32d347f338bfef68bc3e69d upstream.
9
10 Calling dump_backtrace() with a pt_regs argument corresponding to
11 userspace doesn't make any sense and our unwinder will simply print
12 "Call trace:" before unwinding the stack looking for user frames.
13
14 Rather than go through this song and dance, just return early if we're
15 passed a user register state.
16
17 Cc: <stable@vger.kernel.org>
18 Fixes: 1149aad10b1e ("arm64: Add dump_backtrace() in show_regs")
19 Reported-by: Kefeng Wang <wangkefeng.wang@huawei.com>
20 Signed-off-by: Will Deacon <will.deacon@arm.com>
21 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
22
23 ---
24 arch/arm64/kernel/traps.c | 15 +++++++++------
25 1 file changed, 9 insertions(+), 6 deletions(-)
26
27 --- a/arch/arm64/kernel/traps.c
28 +++ b/arch/arm64/kernel/traps.c
29 @@ -101,10 +101,16 @@ static void dump_instr(const char *lvl,
30 void dump_backtrace(struct pt_regs *regs, struct task_struct *tsk)
31 {
32 struct stackframe frame;
33 - int skip;
34 + int skip = 0;
35
36 pr_debug("%s(regs = %p tsk = %p)\n", __func__, regs, tsk);
37
38 + if (regs) {
39 + if (user_mode(regs))
40 + return;
41 + skip = 1;
42 + }
43 +
44 if (!tsk)
45 tsk = current;
46
47 @@ -125,7 +131,6 @@ void dump_backtrace(struct pt_regs *regs
48 frame.graph = tsk->curr_ret_stack;
49 #endif
50
51 - skip = !!regs;
52 printk("Call trace:\n");
53 do {
54 /* skip until specified stack frame */
55 @@ -175,15 +180,13 @@ static int __die(const char *str, int er
56 return ret;
57
58 print_modules();
59 - __show_regs(regs);
60 pr_emerg("Process %.*s (pid: %d, stack limit = 0x%p)\n",
61 TASK_COMM_LEN, tsk->comm, task_pid_nr(tsk),
62 end_of_stack(tsk));
63 + show_regs(regs);
64
65 - if (!user_mode(regs)) {
66 - dump_backtrace(regs, tsk);
67 + if (!user_mode(regs))
68 dump_instr(KERN_EMERG, regs);
69 - }
70
71 return ret;
72 }