瀏覽代碼

arm64: __show_regs: Only resolve kernel symbols when running at EL1

__show_regs pretty prints PC and LR by attempting to map them to kernel
function names to improve the utility of crash reports. Unfortunately,
this mapping is applied even when the pt_regs corresponds to user mode,
resulting in a KASLR oracle.

Avoid this issue by only looking up the function symbols when the register
state indicates that we're actually running at EL1.

Cc: <stable@vger.kernel.org>
Reported-by: NCSC Security <security@ncsc.gov.uk>
Signed-off-by: Will Deacon <will.deacon@arm.com>
Will Deacon 7 年之前
父節點
當前提交
a06f818a70
共有 1 個文件被更改,包括 9 次插入2 次删除
  1. 9 2
      arch/arm64/kernel/process.c

+ 9 - 2
arch/arm64/kernel/process.c

@@ -220,8 +220,15 @@ void __show_regs(struct pt_regs *regs)
 
 
 	show_regs_print_info(KERN_DEFAULT);
 	show_regs_print_info(KERN_DEFAULT);
 	print_pstate(regs);
 	print_pstate(regs);
-	printk("pc : %pS\n", (void *)regs->pc);
-	printk("lr : %pS\n", (void *)lr);
+
+	if (!user_mode(regs)) {
+		printk("pc : %pS\n", (void *)regs->pc);
+		printk("lr : %pS\n", (void *)lr);
+	} else {
+		printk("pc : %016llx\n", regs->pc);
+		printk("lr : %016llx\n", lr);
+	}
+
 	printk("sp : %016llx\n", sp);
 	printk("sp : %016llx\n", sp);
 
 
 	i = top_reg;
 	i = top_reg;