Received: by 10.192.165.156 with SMTP id m28csp248010imm; Tue, 17 Apr 2018 09:28:36 -0700 (PDT) X-Google-Smtp-Source: AIpwx491gH8wKd9czwV3U1QB3HId/GVrlSOCpMCMe31BkVi6HsYwslafwetYBLTgmrfjbSFsLSkw X-Received: by 10.98.234.13 with SMTP id t13mr2603961pfh.56.1523982516003; Tue, 17 Apr 2018 09:28:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523982515; cv=none; d=google.com; s=arc-20160816; b=WnWxsKD7Cj9nn1vG4nBcFz3o+VQ4mxQFtyuuLVKACwlAW3T1zNuxAJbh4yrfMtNmm/ C+gsn5nVr7FrVrsdcb3iDVDNMwGqSLVWg6mXa5NpvhWJkGydeAlRNT+oNRAXZH/DR4tg E+7yA/hQCnk/bgZmAdGSt9ZpOjRNiCRdaT8gM86LyMRyHhJyOf8b+mTNmgWD1IL8Q6Xu ADxUTcRVPrdFQFM0q6kqhwD46MwP/aHCoeVSsBOK//t2u2Gb0Z/XIEC3jTAutO44PJda P3vUaykpr8sJc1pzsKjdypvMF+IH4/0mGTZ2kkPJesTlX1I5+i+EV0fAlZaTGMzA5pVn Bkbw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=Q3my5xXK0mfvB60vTbwXNqheySbNaNlt32879HSCQzc=; b=m/CoZl0HvnFfFIif72esQ9z5r1QqEKgZz6sRZ5lT/Zeh2ReyraZI5uXqX85M5Bl6wv PHZewVboyzc7tvja4H+7mHMbr4/BwgleO0aUYI7tbZ2G9kfgiyXKXoo1fghxw6emLggW FD4t/o7DJkYbC181YohCPF/6Ne5qSAeVqYg73liFNZO9yj3m5jhWyt+Yto8AG3BdM9IY 0cFpsfVPsMr1iIMDIEbqzQfFGvpZbvjDvaiH9114EZbdS2xO2v/6xbDIfSpt5RyDQcYv nu2QCs6+wdkmpNHdUwOP98eFKNisU0MSAojSS0FZfjzYbsg/RiJRIWbOw7rj3Qvdc9ts F31A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-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 p8-v6si5022674pls.86.2018.04.17.09.28.21; Tue, 17 Apr 2018 09:28:35 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-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 linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755571AbeDQQJD (ORCPT + 99 others); Tue, 17 Apr 2018 12:09:03 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:35636 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755553AbeDQQJB (ORCPT ); Tue, 17 Apr 2018 12:09:01 -0400 Received: from localhost (unknown [46.44.180.42]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 4A7E8E66; Tue, 17 Apr 2018 16:09:00 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Greg Kroah-Hartman , Dan Hettena , Marc Zyngier , Will Deacon , Catalin Marinas , Greg Hackmann , Mark Rutland Subject: [PATCH 4.9 29/66] arm64: entry: Apply BP hardening for high-priority synchronous exceptions Date: Tue, 17 Apr 2018 17:59:02 +0200 Message-Id: <20180417155647.135110935@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180417155645.868055442@linuxfoundation.org> References: <20180417155645.868055442@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.9-stable review patch. If anyone has any objections, please let me know. ------------------ From: Mark Rutland From: Will Deacon commit 5dfc6ed27710c42cbc15db5c0d4475699991da0a upstream. Software-step and PC alignment fault exceptions have higher priority than instruction abort exceptions, so apply the BP hardening hooks there too if the user PC appears to reside in kernel space. Reported-by: Dan Hettena Reviewed-by: Marc Zyngier Signed-off-by: Will Deacon Signed-off-by: Catalin Marinas Signed-off-by: Mark Rutland [v4.9 backport] Tested-by: Greg Hackmann Signed-off-by: Greg Kroah-Hartman --- arch/arm64/kernel/entry.S | 6 ++++-- arch/arm64/mm/fault.c | 9 +++++++++ 2 files changed, 13 insertions(+), 2 deletions(-) --- a/arch/arm64/kernel/entry.S +++ b/arch/arm64/kernel/entry.S @@ -624,8 +624,10 @@ el0_sp_pc: * Stack or PC alignment exception handling */ mrs x26, far_el1 - // enable interrupts before calling the main handler - enable_dbg_and_irq + enable_dbg +#ifdef CONFIG_TRACE_IRQFLAGS + bl trace_hardirqs_off +#endif ct_user_exit mov x0, x26 mov x1, x25 --- a/arch/arm64/mm/fault.c +++ b/arch/arm64/mm/fault.c @@ -617,6 +617,12 @@ asmlinkage void __exception do_sp_pc_abo struct siginfo info; struct task_struct *tsk = current; + if (user_mode(regs)) { + if (instruction_pointer(regs) > TASK_SIZE) + arm64_apply_bp_hardening(); + local_irq_enable(); + } + if (show_unhandled_signals && unhandled_signal(tsk, SIGBUS)) pr_info_ratelimited("%s[%d]: %s exception: pc=%p sp=%p\n", tsk->comm, task_pid_nr(tsk), @@ -676,6 +682,9 @@ asmlinkage int __exception do_debug_exce if (interrupts_enabled(regs)) trace_hardirqs_off(); + if (user_mode(regs) && instruction_pointer(regs) > TASK_SIZE) + arm64_apply_bp_hardening(); + if (!inf->fn(addr, esr, regs)) { rv = 1; } else {