Received: by 10.223.185.116 with SMTP id b49csp2169845wrg; Thu, 15 Feb 2018 07:34:20 -0800 (PST) X-Google-Smtp-Source: AH8x225wxzDmSP8XMhcqJosUja2rrld7Fu31p2Ryk9kPVjM0h6JYh3obxnNKbs4ZK9mqWBrelep4 X-Received: by 10.101.80.69 with SMTP id k5mr2553680pgo.431.1518708860739; Thu, 15 Feb 2018 07:34:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518708860; cv=none; d=google.com; s=arc-20160816; b=J0JC1O2dYBcCLaMkJJg5huwLHD8G56EoN/QQlnzog7TwSlQHBRhYHvykD9vY6Nbn68 nVOHQF9zT594rtA6cHDH4OCscqUXPQyr+fWmQjCiDefAXkVUMgnI1dR3fWisA4LTdzIu XaKsYBgrm3jraUMcnevWxgd/Piy9RJiojaZcNQMp9Lenth2WtN7n2rSnponqDEUtWUxn hZhqR4i2Y8WefBoQlJpaGYxu8mnSrYm2KbjQFdNQtjWPPb6QM5JLbz+pSshkAgT6pPt4 ULfIYioIlKoiH9DAUf/jLtF+nyJiAkU8hrwlJAS/vxNbbKSVcwcZClztP1nC9nmSlxeB 2i4g== 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=h+fWMlVpPKysrD4+3ED8+N0hJYD1AsecrAB2CKjh0/w=; b=AZQ7QR++U1p2olIkdjMXzNsbKMal/+WAieaE2gAEGa2mtxdv0m5QQSJS1qEhfTKTnn KyCwRx8eje6OhrlkLUbwb5s1FEkV2Zr9BXVpAK5AVMU81cnsImzmF0X9LxQQpij1mHOy HTyx05bZB4jzzj1K+NBDfj+v9rzftP0lM3dU27Z2sHXoUOB/74yu0e7KgSlkbA5jrBAi f9SPSOpc7NEIRucSRLWSgCmwd88xo+LjukQaSvzPes3iWe02GfoD10YCIPk42W2x31mh sveg5EEzhiciLs+NEwd3o4vDZKu8gEv0lYdSJrsJ9dPvmlZAsiHp7prx28oa9FQacz7v itRg== 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 k12si2582751pgt.734.2018.02.15.07.34.05; Thu, 15 Feb 2018 07:34:20 -0800 (PST) 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 S1164718AbeBOPcu (ORCPT + 99 others); Thu, 15 Feb 2018 10:32:50 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:56540 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1164702AbeBOPcr (ORCPT ); Thu, 15 Feb 2018 10:32:47 -0500 Received: from localhost (LFbn-1-12258-90.w90-92.abo.wanadoo.fr [90.92.71.90]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id B8FE2F97; Thu, 15 Feb 2018 15:32:46 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dan Hettena , Marc Zyngier , Will Deacon , Catalin Marinas , Ard Biesheuvel Subject: [PATCH 4.14 073/195] [Variant 2/Spectre-v2] arm64: entry: Apply BP hardening for high-priority synchronous exceptions Date: Thu, 15 Feb 2018 16:16:04 +0100 Message-Id: <20180215151709.358499659@linuxfoundation.org> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180215151705.738773577@linuxfoundation.org> References: <20180215151705.738773577@linuxfoundation.org> User-Agent: quilt/0.65 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.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Will Deacon Commit 5dfc6ed27710 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: Ard Biesheuvel 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 @@ -759,8 +759,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 @@ -778,6 +778,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), @@ -837,6 +843,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 {