From patchwork Mon Apr 8 17:12:37 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Will Deacon X-Patchwork-Id: 161944 Delivered-To: patch@linaro.org Received: by 2002:a02:c6d8:0:0:0:0:0 with SMTP id r24csp3932845jan; Mon, 8 Apr 2019 10:12:44 -0700 (PDT) X-Google-Smtp-Source: APXvYqynWVzqoFrfMpzcs/zFfx8scCQtnyRYn5JTlhGIhl5Pg6mtN6dY41HCaC+l9k7IBauVfoCk X-Received: by 2002:aa7:9a89:: with SMTP id w9mr23579430pfi.213.1554743564305; Mon, 08 Apr 2019 10:12:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554743564; cv=none; d=google.com; s=arc-20160816; b=QFlJu0jreEPCzYIQCXcYyfRFeL+AadlCqCaaSRspdxSGQ/7SKZQIDqM5lM3wS5p/uW NsbFv+5uopZlN3KLVSbWcJn+ho8DlFskcUwedfoi90sTf7FCPOQor3/KNeLcArBJ6fKm rbc3WXbWjcGfSiBWAhb81QNUzTdRHa7JD/MJutVTIjxpBnsPxaNMw+Q20KZ4LnVTbWf1 O1fpg6esWMwFIYwnCy/BbcWlhCIeYm3ZoWCeI7ADsy8LH/6+fXP8j9QK7DHrYJIx6e9D 2N6GonFHECrZBS9e704fDKcpUgyjqdtrzMHIhmSNTmhZYoCfmdXJn+CC4D/v+e8lWS/0 2cfQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from; bh=Dje8zNFnzM1Dtxl2hup3sBpaXlu71VhMfGK8OU8VkYU=; b=jxqlh7EZu5g00U9wDMdLGBIlB+CW11MBzxelIwgroqxqeojLINosrO3eV0mBWjcEqg 9msj+qRn5m0OB9533u2mqTH2VnZqhIWnUMGITt4zXZAXWAyk7tgLY2Xdr5VuctaWrqkL Kqyj1zrrSNDx1nFPIZI6sp0hYzxd4TU8epu6xURpqWavzCzjr15Qpk+QmT7H/Lm4OlhB hJoJRc3zQrKBYAdcvQZqRteTCxDkdzxiYIpedFVZxqVJZZPZJPLryhkuBST5zhlihErC PuVwFEEqPH3MIYJU+K1G0KCZ2vkkZej7TRmJpFVxKeXgZQoQh0sYpBBKznGTgoP5tYev jLww== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p8si26485176pgb.77.2019.04.08.10.12.44; Mon, 08 Apr 2019 10:12:44 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729107AbfDHRMn (ORCPT + 14 others); Mon, 8 Apr 2019 13:12:43 -0400 Received: from foss.arm.com ([217.140.101.70]:52314 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729095AbfDHRMn (ORCPT ); Mon, 8 Apr 2019 13:12:43 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 428BE15BE; Mon, 8 Apr 2019 10:12:43 -0700 (PDT) Received: from fuggles.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.72.51.249]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 55C7B3F718; Mon, 8 Apr 2019 10:12:42 -0700 (PDT) From: Will Deacon To: linux-arm-kernel@lists.infradead.org Cc: mark.rutland@arm.com, Will Deacon , stable@vger.kernel.org Subject: [PATCH] arm64: backtrace: Don't bother trying to unwind the userspace stack Date: Mon, 8 Apr 2019 18:12:37 +0100 Message-Id: <20190408171237.12045-1-will.deacon@arm.com> X-Mailer: git-send-email 2.11.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org Calling dump_backtrace() with a pt_regs argument corresponding to userspace doesn't make any sense and our unwinder will simply print "Call trace:" before unwinding the stack looking for user frames. Rather than go through this song and dance, just return early if we're passed a user register state. Cc: Fixes: 1149aad10b1e ("arm64: Add dump_backtrace() in show_regs") Reported-by: Kefeng Wang Signed-off-by: Will Deacon --- arch/arm64/kernel/traps.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) -- 2.11.0 diff --git a/arch/arm64/kernel/traps.c b/arch/arm64/kernel/traps.c index 8ad119c3f665..29755989f616 100644 --- a/arch/arm64/kernel/traps.c +++ b/arch/arm64/kernel/traps.c @@ -102,10 +102,16 @@ static void dump_instr(const char *lvl, struct pt_regs *regs) void dump_backtrace(struct pt_regs *regs, struct task_struct *tsk) { struct stackframe frame; - int skip; + int skip = 0; pr_debug("%s(regs = %p tsk = %p)\n", __func__, regs, tsk); + if (regs) { + if (user_mode(regs)) + return; + skip = 1; + } + if (!tsk) tsk = current; @@ -126,7 +132,6 @@ void dump_backtrace(struct pt_regs *regs, struct task_struct *tsk) frame.graph = 0; #endif - skip = !!regs; printk("Call trace:\n"); do { /* skip until specified stack frame */ @@ -176,15 +181,13 @@ static int __die(const char *str, int err, struct pt_regs *regs) return ret; print_modules(); - __show_regs(regs); pr_emerg("Process %.*s (pid: %d, stack limit = 0x%p)\n", TASK_COMM_LEN, tsk->comm, task_pid_nr(tsk), end_of_stack(tsk)); + show_regs(regs); - if (!user_mode(regs)) { - dump_backtrace(regs, tsk); + if (!user_mode(regs)) dump_instr(KERN_EMERG, regs); - } return ret; }