Skip to content

Commit a25ffd3

Browse files
committed
arm64: traps: Don't print stack or raw PC/LR values in backtraces
Printing raw pointer values in backtraces has potential security implications and are of questionable value anyway. This patch follows x86's lead and removes the "Exception stack:" dump from kernel backtraces, as well as converting PC/LR values to symbols such as "sysrq_handle_crash+0x20/0x30". Tested-by: Laura Abbott <labbott@redhat.com> Signed-off-by: Will Deacon <will.deacon@arm.com>
1 parent 42dbf54 commit a25ffd3

2 files changed

Lines changed: 6 additions & 67 deletions

File tree

‎arch/arm64/kernel/process.c‎

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -186,11 +186,9 @@ void __show_regs(struct pt_regs *regs)
186186
}
187187

188188
show_regs_print_info(KERN_DEFAULT);
189-
print_symbol("PC is at %s\n", instruction_pointer(regs));
190-
print_symbol("LR is at %s\n", lr);
191-
printk("pc : [<%016llx>] lr : [<%016llx>] pstate: %08llx\n",
192-
regs->pc, lr, regs->pstate);
193-
printk("sp : %016llx\n", sp);
189+
print_symbol("pc : %s\n", regs->pc);
190+
print_symbol("lr : %s\n", lr);
191+
printk("sp : %016llx pstate : %08llx\n", sp, regs->pstate);
194192

195193
i = top_reg;
196194

‎arch/arm64/kernel/traps.c‎

Lines changed: 3 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -58,55 +58,9 @@ static const char *handler[]= {
5858

5959
int show_unhandled_signals = 1;
6060

61-
/*
62-
* Dump out the contents of some kernel memory nicely...
63-
*/
64-
static void dump_mem(const char *lvl, const char *str, unsigned long bottom,
65-
unsigned long top)
66-
{
67-
unsigned long first;
68-
mm_segment_t fs;
69-
int i;
70-
71-
/*
72-
* We need to switch to kernel mode so that we can use __get_user
73-
* to safely read from kernel space.
74-
*/
75-
fs = get_fs();
76-
set_fs(KERNEL_DS);
77-
78-
printk("%s%s(0x%016lx to 0x%016lx)\n", lvl, str, bottom, top);
79-
80-
for (first = bottom & ~31; first < top; first += 32) {
81-
unsigned long p;
82-
char str[sizeof(" 12345678") * 8 + 1];
83-
84-
memset(str, ' ', sizeof(str));
85-
str[sizeof(str) - 1] = '\0';
86-
87-
for (p = first, i = 0; i < (32 / 8)
88-
&& p < top; i++, p += 8) {
89-
if (p >= bottom && p < top) {
90-
unsigned long val;
91-
92-
if (__get_user(val, (unsigned long *)p) == 0)
93-
sprintf(str + i * 17, " %016lx", val);
94-
else
95-
sprintf(str + i * 17, " ????????????????");
96-
}
97-
}
98-
printk("%s%04lx:%s\n", lvl, first & 0xffff, str);
99-
}
100-
101-
set_fs(fs);
102-
}
103-
10461
static void dump_backtrace_entry(unsigned long where)
10562
{
106-
/*
107-
* Note that 'where' can have a physical address, but it's not handled.
108-
*/
109-
print_ip_sym(where);
63+
printk(" %pS\n", (void *)where);
11064
}
11165

11266
static void __dump_instr(const char *lvl, struct pt_regs *regs)
@@ -171,10 +125,7 @@ void dump_backtrace(struct pt_regs *regs, struct task_struct *tsk)
171125

172126
skip = !!regs;
173127
printk("Call trace:\n");
174-
while (1) {
175-
unsigned long stack;
176-
int ret;
177-
128+
do {
178129
/* skip until specified stack frame */
179130
if (!skip) {
180131
dump_backtrace_entry(frame.pc);
@@ -189,17 +140,7 @@ void dump_backtrace(struct pt_regs *regs, struct task_struct *tsk)
189140
*/
190141
dump_backtrace_entry(regs->pc);
191142
}
192-
ret = unwind_frame(tsk, &frame);
193-
if (ret < 0)
194-
break;
195-
if (in_entry_text(frame.pc)) {
196-
stack = frame.fp - offsetof(struct pt_regs, stackframe);
197-
198-
if (on_accessible_stack(tsk, stack))
199-
dump_mem("", "Exception stack", stack,
200-
stack + sizeof(struct pt_regs));
201-
}
202-
}
143+
} while (!unwind_frame(tsk, &frame));
203144

204145
put_task_stack(tsk);
205146
}

0 commit comments

Comments
 (0)