Return-Path: Received: from shadbolt.e.decadent.org.uk ([88.96.1.126]:39435 "EHLO shadbolt.e.decadent.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933071AbeFGOJK (ORCPT ); Thu, 7 Jun 2018 10:09:10 -0400 Content-Type: text/plain; charset="UTF-8" Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 From: Ben Hutchings To: linux-kernel@vger.kernel.org, stable@vger.kernel.org CC: akpm@linux-foundation.org, "NCSC Security" , "Will Deacon" Date: Thu, 07 Jun 2018 15:05:21 +0100 Message-ID: Subject: [PATCH 3.16 270/410] arm64: __show_regs: Only resolve kernel symbols when running at EL1 In-Reply-To: Sender: stable-owner@vger.kernel.org List-ID: 3.16.57-rc1 review patch. If anyone has any objections, please let me know. ------------------ From: Will Deacon commit a06f818a70de21b4b3b4186816094208fc7accf9 upstream. __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. Reported-by: NCSC Security Signed-off-by: Will Deacon [bwh: Backported to 3.16: adjust context] Signed-off-by: Ben Hutchings --- arch/arm64/kernel/process.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) --- a/arch/arm64/kernel/process.c +++ b/arch/arm64/kernel/process.c @@ -197,8 +197,15 @@ void __show_regs(struct pt_regs *regs) } show_regs_print_info(KERN_DEFAULT); - 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 pstate : %08llx\n", sp, regs->pstate); for (i = top_reg; i >= 0; i--) { printk("x%-2d: %016llx ", i, regs->regs[i]);