Received: by 10.223.185.116 with SMTP id b49csp7394355wrg; Thu, 1 Mar 2018 05:00:31 -0800 (PST) X-Google-Smtp-Source: AG47ELsPqKBT202Qtj607v/JAuEd2YIZxhaPZQSTmQnKlzxr5gN8sUSsf3Scm+TLe78WiN/ZonrO X-Received: by 2002:a17:902:74c3:: with SMTP id f3-v6mr1880842plt.444.1519909230926; Thu, 01 Mar 2018 05:00:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519909230; cv=none; d=google.com; s=arc-20160816; b=Y0jtR4ctb5mQja7/qsBBHgEfvUXGRbnZ8HHdnrAHjZDRSg5/sAZXaTW6pciKBlLUDc z1HO/v0hKDHnnxgPbrMrqlK6Uf6UCCGe0bol/uaL4vCC7eBPJvx5T6oFBQAYquIPv/du dAgo5oIIXEkVTsNelIdwFibUyGm/VLULuKR+B0QOQyMjnoh8ugbfQajC9alVKA7E4R+j Q5CwgJ8sWvOIqBHa1EaeAdRKZypd01h4gQaLzNhkVeOX16EiRp9nAJ7y1T9wgESXHxt+ LPWYKhwdjXfBzocsHorHXw+b+RfJkeGZmdxmlCvDNqCYT2E8O9HiaD/S3XhIihuNiq2z ev2g== 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:cc:to:from:dkim-signature:arc-authentication-results; bh=YaNlfJjXAm7Tj4lsPJi0xUkj7+DnsswK/FzZeoAqgZ8=; b=KJDG6Az37eP8ZgaG0cvkbCqEQT5ZHUB0f0LN2G/d/wXsUVX+OUo8n4wQnvzbxJGRsW m78kchPyFrXBoiXMOfOsIDs7IRekS38Tsvolj7mnsDZ5ehsmgZBMLcRZXfThwh/BOPIA Bpmy4ADIsHZUJDXswT6kEeDUeGR6jlBAQ3m73u606KLlM4WMXxU84Cqz/nrsa/QyOlN8 Q5IKfRWpiS1JbjpRLhC7sNbfmpFNCVaKViDdxnKoRZyJEQ5mR8CjeFJcz9WhMxNF5qQy GZNprvA7FBe/Fj4al+u9oiAB181KztXe0HnL43iDssTi7VxJKEAsawJZncQDUdUaO7sl GuYA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=W450VjVU; 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 a186si2453338pgc.36.2018.03.01.05.00.15; Thu, 01 Mar 2018 05:00:30 -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=W450VjVU; 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 S1030969AbeCAM7D (ORCPT + 99 others); Thu, 1 Mar 2018 07:59:03 -0500 Received: from mail-pg0-f66.google.com ([74.125.83.66]:36977 "EHLO mail-pg0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1030781AbeCAM7A (ORCPT ); Thu, 1 Mar 2018 07:59:00 -0500 Received: by mail-pg0-f66.google.com with SMTP id y26so2276191pgv.4 for ; Thu, 01 Mar 2018 04:59:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=YaNlfJjXAm7Tj4lsPJi0xUkj7+DnsswK/FzZeoAqgZ8=; b=W450VjVULfESSLecI29my/KhkZfCs1kvm52qnoYBk7dus3/opeXMMtXc4bwKVr6C52 0nXc3Iy5mp3iecFj861l3leo91XXIkT4PYmQ1eHVX5MTAlCWacESDG8WTy/T52Ala7rd DmfInnzoyRim0YBzMnZOpYY8LzJPoRJFciJks= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=YaNlfJjXAm7Tj4lsPJi0xUkj7+DnsswK/FzZeoAqgZ8=; b=KH2rN+Igl1QD6bdkP2k5uJX9i9Z7SU4LdWz9+9jNwFYo5Sd0rMXZQElOu1wxTdAWXQ M8bsPp62ElaCvlRcpJMXqiEj8hA8X7sUaIwZiWaklGjBhb0SLmVUFWerytmpp/hd9tr5 cK63mYrf5GnrEMHRx7O18iEnV91G4QhQczo9Gz9kMQVQNdQBLxBzH9ihm4QF+CPqWiVj V8oLnOuCySGDJUbgupR0MTwYiz7h9tytQq6B2EJJJyryVuHW2yYBPQ63UcTwrHowK554 VMSmJtFOmtPINhDZiEp3Jg+UJ4fRYNSsE0YVTAQaqWLldEvoGn1QPMGJDvcnY52rxAkL Mz6g== X-Gm-Message-State: APf1xPAxT2Nm8YzIMj/tNz+pQmq2eO5zM8YUe4jzVz3ZKXLiPoN/R7Y5 HJDTTbBdbbcjaRLDSnK0R20CoA== X-Received: by 10.98.172.18 with SMTP id v18mr1852855pfe.175.1519909139909; Thu, 01 Mar 2018 04:58:59 -0800 (PST) Received: from localhost.localdomain (176.122.172.82.16clouds.com. [176.122.172.82]) by smtp.gmail.com with ESMTPSA id x4sm2289655pfb.46.2018.03.01.04.58.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 01 Mar 2018 04:58:59 -0800 (PST) From: Alex Shi To: Marc Zyngier , Will Deacon , Ard Biesheuvel , Catalin Marinas , stable@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: Alex Shi Subject: [PATCH 26/45] arm64: entry: Apply BP hardening for high-priority synchronous exceptions Date: Thu, 1 Mar 2018 20:54:03 +0800 Message-Id: <1519908862-11425-27-git-send-email-alex.shi@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1519908862-11425-1-git-send-email-alex.shi@linaro.org> References: <1519908862-11425-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 --- 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