Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp1851342pxu; Fri, 9 Oct 2020 01:04:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyevIdkb6vl0+A/ltd/UauGQPaCOptyvCLPpsO6j2Xz8jzS4NqKl9iE/aVcAHhCC7gRSew6 X-Received: by 2002:a17:906:564d:: with SMTP id v13mr13679839ejr.217.1602230641955; Fri, 09 Oct 2020 01:04:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1602230641; cv=none; d=google.com; s=arc-20160816; b=r1Ox0u2srAPtSW2NUtB5eSXqFQK404DAImIDjPpA813Fr+WTV0vY3Xy0wjumAuvKOC xNOcrWD2BOph7ClN4e1h2LfUC9zw6oiSPKCx0BvF2Nsr2VkE2YjLyLdIw8Rrx+N7RCEV 2nUkusInQFaSro2pivmOtDgG92XCOHNly+ZxuJCC7kyWpiYVmvBO6uB/S7pN37i5wyIK yb90UtO2FGkOwefr2CvY8kbmEemSCMwVtH64t5kXv10x4Z10bnO23ZaGSf20yoZK94Jy UQJcECx2VXcBAUU0KJJrRbhVVfUinNRjmWoJ3gkXX9DT/zR/sKBvFUvzJsfAeqj05vTF whTQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=wmwB9Z/7FVglDZWYDB3VpUpqGyq1/x8GNLvhcH47P34=; b=asvgTaPe0zhKRW21OoTGr/O2AHrwD/0SRfjmx+u5FRkvdkFv1qgUma/oEXndJ0F4wq ypmOdiCxJlbIfIgvwLAOpkfD8EqgEcjVvef9yS0TwndmihUxMu5cZhvAPi0YSSbxqdi3 F1QDz6i5oJ/hlE0cO+447Rnw9teLGFtmkXPBFGTAu1VH3MOmYdS2twuGuoj1gPq2JAVK KR8qw7nI/c9Cy/zHOtSeHcdoef1mGaZiGL5hwP2qK4Twy67iyV0MMwDWHe483b7OeiXO ZkFkfjUzSU0pE5U+9ZJpgz7TFrNoRJ8p+tVK8P44gyZe4gaXCTPRNM13QtSGjosOyuCN h+UA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z30si5478878edi.478.2020.10.09.01.03.38; Fri, 09 Oct 2020 01:04:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732898AbgJIIBq (ORCPT + 99 others); Fri, 9 Oct 2020 04:01:46 -0400 Received: from szxga06-in.huawei.com ([45.249.212.32]:55812 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1732492AbgJIIAM (ORCPT ); Fri, 9 Oct 2020 04:00:12 -0400 Received: from DGGEMS408-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id E6128CA9D00C89EF206C; Fri, 9 Oct 2020 16:00:09 +0800 (CST) Received: from use12-sp2.huawei.com (10.67.189.174) by DGGEMS408-HUB.china.huawei.com (10.3.19.208) with Microsoft SMTP Server id 14.3.487.0; Fri, 9 Oct 2020 16:00:02 +0800 From: Xiaoming Ni To: , , , , , , , , , , , , , , CC: , , , , Subject: [PATCH] arm:traps: Don't print stack or raw PC/LR values in backtraces Date: Fri, 9 Oct 2020 15:59:57 +0800 Message-ID: <20201009075957.110017-1-nixiaoming@huawei.com> X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.67.189.174] X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Printing raw pointer values in backtraces has potential security implications and are of questionable value anyway. This patch follows x86 and arm64's lead and removes the "Exception stack:" dump from kernel backtraces: commit a25ffd3a6302a6 ("arm64: traps: Don't print stack or raw PC/LR values in backtraces") commit 0ee1dd9f5e7eae ("x86/dumpstack: Remove raw stack dump") commit bb5e5ce545f203 ("x86/dumpstack: Remove kernel text addresses from stack dump") Signed-off-by: Xiaoming Ni --- arch/arm/kernel/process.c | 3 +-- arch/arm/kernel/traps.c | 12 +++++------- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/arch/arm/kernel/process.c b/arch/arm/kernel/process.c index 8e6ace03e960..71c9e5597d39 100644 --- a/arch/arm/kernel/process.c +++ b/arch/arm/kernel/process.c @@ -121,8 +121,7 @@ void __show_regs(struct pt_regs *regs) printk("PC is at %pS\n", (void *)instruction_pointer(regs)); printk("LR is at %pS\n", (void *)regs->ARM_lr); - printk("pc : [<%08lx>] lr : [<%08lx>] psr: %08lx\n", - regs->ARM_pc, regs->ARM_lr, regs->ARM_cpsr); + printk("psr: %08lx\n", regs->ARM_cpsr); printk("sp : %08lx ip : %08lx fp : %08lx\n", regs->ARM_sp, regs->ARM_ip, regs->ARM_fp); printk("r10: %08lx r9 : %08lx r8 : %08lx\n", diff --git a/arch/arm/kernel/traps.c b/arch/arm/kernel/traps.c index 17d5a785df28..b0b188e01070 100644 --- a/arch/arm/kernel/traps.c +++ b/arch/arm/kernel/traps.c @@ -60,23 +60,18 @@ static int __init user_debug_setup(char *str) __setup("user_debug=", user_debug_setup); #endif -static void dump_mem(const char *, const char *, unsigned long, unsigned long); - void dump_backtrace_entry(unsigned long where, unsigned long from, unsigned long frame, const char *loglvl) { unsigned long end = frame + 4 + sizeof(struct pt_regs); #ifdef CONFIG_KALLSYMS - printk("%s[<%08lx>] (%ps) from [<%08lx>] (%pS)\n", - loglvl, where, (void *)where, from, (void *)from); + printk("%s (%ps) from (%pS)\n", + loglvl, (void *)where, (void *)from); #else printk("%sFunction entered at [<%08lx>] from [<%08lx>]\n", loglvl, where, from); #endif - - if (in_entry_text(from) && end <= ALIGN(frame, THREAD_SIZE)) - dump_mem(loglvl, "Exception stack", frame + 4, end); } void dump_backtrace_stm(u32 *stack, u32 instruction, const char *loglvl) @@ -125,6 +120,9 @@ static void dump_mem(const char *lvl, const char *str, unsigned long bottom, mm_segment_t fs; int i; + /* Do not print virtual addresses in non-reset scenarios */ + if (!panic_on_oops) + return; /* * We need to switch to kernel mode so that we can use __get_user * to safely read from kernel space. Note that we now dump the -- 2.27.0