From patchwork Mon Feb 26 08:20:00 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Shi X-Patchwork-Id: 129579 Delivered-To: patch@linaro.org Received: by 10.46.66.2 with SMTP id p2csp3357490lja; Mon, 26 Feb 2018 00:24:26 -0800 (PST) X-Google-Smtp-Source: AH8x226EtX6dyj+DwfhjUeIbEApEwlPGoHoV68pmUBFSJD5EfPvEgby7R0j/nPG/NnCZqL8ID58j X-Received: by 10.98.204.69 with SMTP id a66mr9825847pfg.33.1519633466796; Mon, 26 Feb 2018 00:24:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519633466; cv=none; d=google.com; s=arc-20160816; b=IxIAfw/4MNSA8t7bPC3kpsXdHDRwWEEyo7Jf24uCz6zBrJt1mOL9Qpd2o40BMFz3IP 5L9c1LF6vP5+bEYh4gax80U3qUpIOG3SmzsFwdaqq9EWLBaGuWlgP9ni6AzX8qv/7HV8 RLplUftflCtlRHMxrj/PtKL07cMQ3ZFQmQKUYZEaFjZ/xnUnPvdsR+edftWOj/gQt0RX apGyYOs/RUPXz7rleRNohjibHC0Y7Kz9c+3Prg9HcOj5FU4SxfAYfYCxrkixVdY9btbk RLlXbG0YdtowWdWdlZRZg5wUm//K7A/EQK1de59W3xlz+zPhjycKiv8GL+ZsGdWub1IT Ozcg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:to:from:dkim-signature:arc-authentication-results; bh=aecMAEg4UDkugVp6jZTqZagnCNTuf8l+gwqIgnZ36z0=; b=pDXiY31dgjYaWnPwbbuN9tKjbwG6/AVbnEeZhYd0UeAK0ZCHITQPfmvkQbeI4u0DRy CkqFz0XwiD3NEn5WKurjlOalCq3GdHGSj2kQJarnq4XpHlrOYGTO49wyge6AuODGpO1Y G5sfOiXXaanrjdpsl5ig09C8erRSvezTsXj6MaJ+4XrEKmWcVwHuKxq35QAs/5fDa1aS JZRhI6sF3TcBK2EX38JjZfRlgGPtwe9o1ImPC77Xn7nqpzHLpQipBt8fDv4G3zG0KZC9 29vdP8/3QCe86n92DS4t61WQoH5QJ8Q/kNToH1dwTXm/0fZL4R6ajozsepq4IAm0efSz Cz6Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=NdY553qP; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b11si5249076pgr.612.2018.02.26.00.24.26; Mon, 26 Feb 2018 00:24:26 -0800 (PST) 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; dkim=pass header.i=@linaro.org header.s=google header.b=NdY553qP; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752377AbeBZIYZ (ORCPT + 10 others); Mon, 26 Feb 2018 03:24:25 -0500 Received: from mail-pg0-f67.google.com ([74.125.83.67]:34164 "EHLO mail-pg0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751900AbeBZIYQ (ORCPT ); Mon, 26 Feb 2018 03:24:16 -0500 Received: by mail-pg0-f67.google.com with SMTP id m19so5918379pgn.1 for ; Mon, 26 Feb 2018 00:24:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references; bh=aecMAEg4UDkugVp6jZTqZagnCNTuf8l+gwqIgnZ36z0=; b=NdY553qPJUY1vLu+Qho/mPsQGua5qj3L8fVD59qAjUipogrBfvW50yn9SHwpDBnm6z QoNvU4tjDhR21wnxkdQ2tvuNaxywJ/OT6cDGw/nBLp5lrjNG0Fu1hGGQz+LV7XKwuGUw eLMQ5QMZKwsuUrC/XMlGXIfIc6t62DqXLj8WY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=aecMAEg4UDkugVp6jZTqZagnCNTuf8l+gwqIgnZ36z0=; b=gV9zKvZ8s8WNG8TaXhLk9VdBjOWLrDUEiNi7Js6crVOXw5YWJMcN0QJiLHB5sBGkUT q7VAR+dDbhe5lQUOHeijU0mRVkWssxZVbf8sjEiXlp7tXMHcd39iAcsF16QlF+1jr5ZM albrEuMa6n4jpgG/zttpeo5XIHU7pA3tAm3CguPomXHS6BmZlwrbT8qNURQE5r5xa9TF pMUhVMw4eGwAcl0twIV4NNzliQpnZULPx7Jky1A5oMu1bGcdndcrCMoaPhiiJFpsaQxS 9lDWwDQGlH8HoSzX6U42WgP+sC84JDiQx/xT9G3YuD5xAbxN/Njjm6RtZ7D27F1cDfvw whCw== X-Gm-Message-State: APf1xPBy3gOeRGz94JFObvFRKSFJr+j4qDCStjLJScpiJfRIRtxWzMg0 OH5DzvjMF1ORA6RAqe+Iv3RfSA== X-Received: by 10.101.99.205 with SMTP id n13mr7929403pgv.345.1519633455649; Mon, 26 Feb 2018 00:24:15 -0800 (PST) Received: from localhost.localdomain (176.122.172.82.16clouds.com. [176.122.172.82]) by smtp.gmail.com with ESMTPSA id o86sm1422706pfi.87.2018.02.26.00.24.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 26 Feb 2018 00:24:15 -0800 (PST) From: Alex Shi To: Marc Zyngier , Will Deacon , Ard Biesheuvel , Catalin Marinas , stable@vger.kernel.org, linux-arm-kernel@lists.infradead.org (moderated list:ARM64 PORT (AARCH64 ARCHITECTURE)), linux-kernel@vger.kernel.org (open list) Subject: [PATCH 26/52] arm64: entry: Apply BP hardening for high-priority synchronous exceptions Date: Mon, 26 Feb 2018 16:20:00 +0800 Message-Id: <1519633227-29832-27-git-send-email-alex.shi@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1519633227-29832-1-git-send-email-alex.shi@linaro.org> References: <1519633227-29832-1-git-send-email-alex.shi@linaro.org> Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org 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: Alex Shi Conflicts: expand enable_da_f to 'msr daifclr, #(8 | 4 | 1)' in arch/arm64/kernel/entry.S --- arch/arm64/kernel/entry.S | 6 ++++-- arch/arm64/mm/fault.c | 9 +++++++++ 2 files changed, 13 insertions(+), 2 deletions(-) -- 2.7.4 diff --git a/arch/arm64/kernel/entry.S b/arch/arm64/kernel/entry.S index bdb0139..d50c2fe 100644 --- a/arch/arm64/kernel/entry.S +++ b/arch/arm64/kernel/entry.S @@ -584,8 +584,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 + msr daifclr, #(8 | 4 | 1) +#ifdef CONFIG_TRACE_IRQFLAGS + bl trace_hardirqs_off +#endif ct_user_exit mov x0, x26 mov x1, x25 diff --git a/arch/arm64/mm/fault.c b/arch/arm64/mm/fault.c index c95b194..6120a14 100644 --- a/arch/arm64/mm/fault.c +++ b/arch/arm64/mm/fault.c @@ -617,6 +617,12 @@ asmlinkage void __exception do_sp_pc_abort(unsigned long addr, 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_exception(unsigned long addr, 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 {