From patchwork Wed Apr 3 10:33:25 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Will Deacon X-Patchwork-Id: 161692 Delivered-To: patch@linaro.org Received: by 2002:a02:c6d8:0:0:0:0:0 with SMTP id r24csp152019jan; Wed, 3 Apr 2019 03:33:37 -0700 (PDT) X-Google-Smtp-Source: APXvYqwZ9in8XqoDlr/69DmP8+f2dXMIsK3bhzui8rc/3LK+6pjjj7WG83Wh8DXYMMktFQSGVeHY X-Received: by 2002:a17:902:820c:: with SMTP id x12mr63524479pln.199.1554287617756; Wed, 03 Apr 2019 03:33:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554287617; cv=none; d=google.com; s=arc-20160816; b=A9fWF5yFOr1sz+6jBbvQn+Qs478QOTclzb3TIT4bQoU53BMIx+S40OOwFEmqva+KLR XBtmzPgKTbwRZZ4LAVmXR+3T7NQJbWEu4HK1xf9XtxGKkUDu34vmjjhAz6f0KrUzkM5H lymuj0yWdODdRPpWmCA9QdU3HvjKh7BfN9mzGN437WseDGSrjy6vpp+7M8B2bb92K8Yz r3ifjCgb+mWHUOZQdjMHR3pk9RNn8NGMmsIgcI5k2xXqGVQmL6mN/TxEAhciRp8CTnLI AJpPme82CErzqeLYG7VK97bhi0KfKBcaRfBfKbplFNyy7Qv2jZmlTTx2g+jK/Yf+VbNh T0RQ== 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=gYBuuWGDiy80iktIu1HYnH5XP1fTgxi31WG8lo18Do0=; b=qpfGLlHY4VPRefguHVuYXk7Wk9FFMMylxBg4QIkIkhwNda8CICjECjPt/ahM7Zm9Sr kRxsHp9vQw5OL5kawM4Gsp2wyiFEeVDTWk5YgT22Gdk/en83N3eadTkpbh2DM0iRcdaz KJmYfJqNs3IGCVUy/2EFJD6YhJmf6lFgn8Rqh7el0BJXYw6IGts2zMMxV0Ob381sIk9G B9giA+vVhYpKYfkq0/0gFxSDbnr3QCAkpisIrB7EkLcymCIEQFUs0dTUC2WPd7RQJhyh O37iqBywqGRt9HmJv2mB0uUy79boEMF3LQh46E+k8V6brx/IheMBlBl6rGyO7lxBXpWa hrIg== 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 s34si13630095pgl.97.2019.04.03.03.33.37; Wed, 03 Apr 2019 03:33:37 -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 S1726263AbfDCKdh (ORCPT + 14 others); Wed, 3 Apr 2019 06:33:37 -0400 Received: from foss.arm.com ([217.140.101.70]:37030 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726199AbfDCKdg (ORCPT ); Wed, 3 Apr 2019 06:33:36 -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 3B02880D; Wed, 3 Apr 2019 03:33:36 -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 06AB53F59C; Wed, 3 Apr 2019 03:33:34 -0700 (PDT) From: Will Deacon To: gregkh@linuxfoundation.org Cc: stable@vger.kernel.org, linux-kernel@vger.kernel.org, sashal@kernel.org, Will Deacon , Catalin Marinas Subject: [PATCH 4.9/4.14 BACKPORT 1/2] arm64: debug: Don't propagate UNKNOWN FAR into si_code for debug signals Date: Wed, 3 Apr 2019 11:33:25 +0100 Message-Id: <20190403103326.29161-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 Commit b9a4b9d084d978f80eb9210727c81804588b42ff upstream. FAR_EL1 is UNKNOWN for all debug exceptions other than those caused by taking a hardware watchpoint. Unfortunately, if a debug handler returns a non-zero value, then we will propagate the UNKNOWN FAR value to userspace via the si_addr field of the SIGTRAP siginfo_t. Instead, let's set si_addr to take on the PC of the faulting instruction, which we have available in the current pt_regs. Cc: # 4.9.y and 4.14.y Reviewed-by: Mark Rutland Signed-off-by: Will Deacon Signed-off-by: Catalin Marinas --- arch/arm64/mm/fault.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) -- 2.11.0 diff --git a/arch/arm64/mm/fault.c b/arch/arm64/mm/fault.c index ad49ae8f3967..051b32084776 100644 --- a/arch/arm64/mm/fault.c +++ b/arch/arm64/mm/fault.c @@ -673,11 +673,12 @@ void __init hook_debug_fault_code(int nr, debug_fault_info[nr].name = name; } -asmlinkage int __exception do_debug_exception(unsigned long addr, +asmlinkage int __exception do_debug_exception(unsigned long addr_if_watchpoint, unsigned int esr, struct pt_regs *regs) { const struct fault_info *inf = debug_fault_info + DBG_ESR_EVT(esr); + unsigned long pc = instruction_pointer(regs); struct siginfo info; int rv; @@ -688,19 +689,19 @@ asmlinkage int __exception do_debug_exception(unsigned long addr, if (interrupts_enabled(regs)) trace_hardirqs_off(); - if (user_mode(regs) && instruction_pointer(regs) > TASK_SIZE) + if (user_mode(regs) && pc > TASK_SIZE) arm64_apply_bp_hardening(); - if (!inf->fn(addr, esr, regs)) { + if (!inf->fn(addr_if_watchpoint, esr, regs)) { rv = 1; } else { pr_alert("Unhandled debug exception: %s (0x%08x) at 0x%016lx\n", - inf->name, esr, addr); + inf->name, esr, pc); info.si_signo = inf->sig; info.si_errno = 0; info.si_code = inf->code; - info.si_addr = (void __user *)addr; + info.si_addr = (void __user *)pc; arm64_notify_die("", regs, &info, 0); rv = 0; }