Received: by 10.223.185.116 with SMTP id b49csp3489687wrg; Mon, 26 Feb 2018 00:26:15 -0800 (PST) X-Google-Smtp-Source: AH8x224WTjAcq1D2vYfmgqP1pJ2AfHxZENdfmC5K8p2DQiPTB0NpG3wt8s2qhWkgnItlmefXY/oO X-Received: by 2002:a17:902:b597:: with SMTP id a23-v6mr10156686pls.227.1519633575790; Mon, 26 Feb 2018 00:26:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519633575; cv=none; d=google.com; s=arc-20160816; b=VY8d+n8SHfQR+xAv8cPfgCIhDR9pGCa/iJroMhhi9V0I/Os5BswjU1iOWh+JbYC2S6 6Q9EVqiQ64+ilM3BRzQobgoJRd5cp4qyH86e/Rk0GwvAxz+IFFnEtT+bCh4TWx9OqseG zwnwNEwkEzQRAOuHW9IeFF/t9l5mPqQz78QYshfX/qIANipQgQZlEO/XXe8vrJGPSddS C6qCfa37qX9uZTLeHDkk4Xp/2VThJCV30FpK6Y7T/2qUULOXyWR/4RxvImBFzVG99IRH pnZ60lmnoEa9IvVwndaj2cN/JlwC23vPYDmK+ycJkbzz6v7+lznhm/P7SgbvmJtizU8k kb1A== 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=FzK6a1fNE879kbvdGIUDRdhnS/j9qjgVazJFy2JMpVWrqbAjOh4R06zs6S8TR53pwX 2ZT0xhrkwsFXaLw2dPKDSjbdytEoffpiJd2LXLkyXogMLBKWIDQOodwi+uXQZHnjciCw u5QW1S42aoNVZ9ALpJ1CJv2OILoYsjAVrMBXyHBXDYVnoeYUORa84jH+CMu0DxouVb/r MguZ+u5NLSFwcjmDX3bHJSj98iJ2TPrybCN3MtRvzxYhM3JA+04t3eeklLgJzRQAPYj5 /IU9zE5L8Y7q8ykXRQ//b5+Z4oUfPelKra8VaiTe8GjeRrSVaK35W2ZN40fXiaRn5bqr 7paA== 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 linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-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 20si6342239pfp.312.2018.02.26.00.26.01; Mon, 26 Feb 2018 00:26:15 -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; dkim=pass header.i=@linaro.org header.s=google header.b=NdY553qP; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751926AbeBZIY0 (ORCPT + 99 others); Mon, 26 Feb 2018 03:24:26 -0500 Received: from mail-pg0-f66.google.com ([74.125.83.66]:38600 "EHLO mail-pg0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752588AbeBZIYQ (ORCPT ); Mon, 26 Feb 2018 03:24:16 -0500 Received: by mail-pg0-f66.google.com with SMTP id l24so5915655pgc.5 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=nuYpBW4E+FLehm5k+UfxyjR6ARK8Ia1kSApaNC6E0OeUMSNAsMkiUboD0kVAY9NrCA hT43IX/0aJnozjUvR/FeslGEb0FV0IWmnnXaachTgaZaZW3AhyJGpmG4nxd0fu6xKDh5 pmmBblWHU1s3aX4lHOUFJeIqYOub5yt9uj1uROll2gN1yvjGEJxfdkhxPw4HcHtts4K0 mx0jVsuWOMOoisLxON7emSonxQ0kLqU4ff1zWYoyu5p0244NWS9H2Pf8NC360Nd+rL6I 8D4t/36FsqmG7IEFqLJ5rQbw3tIs8zS0A6bLQxytGuVcJxlfbLrlJ/yKPolWrI3MWj6Z 3T+Q== X-Gm-Message-State: APf1xPBplw6KJdmqbXNKottokSnbGbEswBUaSmAICJ+5KUVWkL3pUhHI aAtxxDUTFd1qQbAQ3GLL79KIsw== 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: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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(-) 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 { -- 2.7.4