From patchwork Wed Apr 3 10:34:08 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Will Deacon X-Patchwork-Id: 161694 Delivered-To: patch@linaro.org Received: by 2002:a02:c6d8:0:0:0:0:0 with SMTP id r24csp152670jan; Wed, 3 Apr 2019 03:34:17 -0700 (PDT) X-Google-Smtp-Source: APXvYqycKbbVk1M34J14x61BptpRoyWtjGxfrTi0YUFe45SrYIC+Zs4/1lLxsgKBLGPxcPRCJ/DU X-Received: by 2002:aa7:85d9:: with SMTP id z25mr64079559pfn.31.1554287656970; Wed, 03 Apr 2019 03:34:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554287656; cv=none; d=google.com; s=arc-20160816; b=gZ7SN8F3RAP1CeHr6vTwFc4TgJwaFor/EgXm8AwrYr1yfkEqWNTjeZls4PsLyUkK5Y xQ764NXv4kw6p+h9lB5S64VESkD6iA4kR+acgwkV2tZPonn73tdQmmYAfzHUVsenXVsY Em+KZASXzVMLSwjSj3J78noN48FW5K6cJl04V1bj6uQW2kDJekiGi7T2JvK3m5MNjdkK pRLPN9wXlBOxCYzm8Qf3HWHhclBuhhIaqCuMwrUPUNWsxGyqKdOO9uFKfRuYJVlmbqku 6MHVA5k8QtsNXepzVaij7LlBK6egfFZ7BpflL/2Eq2PlBtBAQl4u3kG9+acbZJxiE3pz c+/A== 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=3aIscBVJ8koETH9PBVclZnHElQAA75Im6LST7Gnm5MU=; b=CftpLGUs1cRT/OL5qifUvXghXMrJFEkVuoonfjhjDEL+dM+6kF5bqab11rzkFcGfGN VYZU0Xuzu3MGRgXTNd7R0+HOS6emUW1/uN4RnrcPxPJUyw2GzsuJpuHVieugpDT+L+FD RgqNBxGZumblDTw3rgm1Vt0TVGGcJ3yRli3+SQjPY78Uw19mtdW678YbDYcr4CTzMa6x h00EmB+WTwgFmnkn411ZHfsDUOrb0U6QpPsmCZsvmBKpFwYQDYyu8nRe5U9HJCMhdRqq LwGt6KrVW/7LeW7Ie8gnbXsXRw4mrGXGVAFm1P+Jgz1e45RuJN51VtZ8MGsC33qxcmWj okKA== 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 v124si13173478pgb.475.2019.04.03.03.34.16; Wed, 03 Apr 2019 03:34:16 -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 S1726415AbfDCKeQ (ORCPT + 14 others); Wed, 3 Apr 2019 06:34:16 -0400 Received: from foss.arm.com ([217.140.101.70]:37054 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726199AbfDCKeQ (ORCPT ); Wed, 3 Apr 2019 06:34:16 -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 652B080D; Wed, 3 Apr 2019 03:34:15 -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 31AE73F59C; Wed, 3 Apr 2019 03:34:14 -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.19 BACKPORT] arm64: debug: Don't propagate UNKNOWN FAR into si_code for debug signals Date: Wed, 3 Apr 2019 11:34:08 +0100 Message-Id: <20190403103408.29209-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.19.y Reviewed-by: Mark Rutland Signed-off-by: Will Deacon Signed-off-by: Catalin Marinas --- arch/arm64/mm/fault.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) -- 2.11.0 diff --git a/arch/arm64/mm/fault.c b/arch/arm64/mm/fault.c index 50b30ff30de4..a4c134677285 100644 --- a/arch/arm64/mm/fault.c +++ b/arch/arm64/mm/fault.c @@ -827,11 +827,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); int rv; /* @@ -841,10 +842,10 @@ 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 { struct siginfo info; @@ -853,7 +854,7 @@ asmlinkage int __exception do_debug_exception(unsigned long addr, 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(inf->name, regs, &info, esr); rv = 0; }