[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <tip-5932c9fd19e6e5ac84756c5c32fe5155d9a6b458@git.kernel.org>
Date: Tue, 30 Apr 2019 04:14:32 -0700
From: tip-bot for Nadav Amit <tipbot@...or.com>
To: linux-tip-commits@...r.kernel.org
Cc: namit@...are.com, torvalds@...ux-foundation.org,
akpm@...ux-foundation.org, hpa@...or.com, peterz@...radead.org,
ard.biesheuvel@...aro.org, dave.hansen@...ux.intel.com,
kristen@...ux.intel.com, linux_dti@...oud.com,
kernel-hardening@...ts.openwall.com, bp@...en8.de,
riel@...riel.com, rick.p.edgecombe@...el.com, mingo@...nel.org,
will.deacon@....com, tglx@...utronix.de, luto@...nel.org,
linux-kernel@...r.kernel.org, deneen.t.dock@...el.com
Subject: [tip:x86/mm] mm/tlb: Provide default nmi_uaccess_okay()
Commit-ID: 5932c9fd19e6e5ac84756c5c32fe5155d9a6b458
Gitweb: https://git.kernel.org/tip/5932c9fd19e6e5ac84756c5c32fe5155d9a6b458
Author: Nadav Amit <namit@...are.com>
AuthorDate: Thu, 25 Apr 2019 17:11:42 -0700
Committer: Ingo Molnar <mingo@...nel.org>
CommitDate: Tue, 30 Apr 2019 12:37:48 +0200
mm/tlb: Provide default nmi_uaccess_okay()
x86 has an nmi_uaccess_okay(), but other architectures do not.
Arch-independent code might need to know whether access to user
addresses is ok in an NMI context or in other code whose execution
context is unknown. Specifically, this function is needed for
bpf_probe_write_user().
Add a default implementation of nmi_uaccess_okay() for architectures
that do not have such a function.
Signed-off-by: Nadav Amit <namit@...are.com>
Signed-off-by: Rick Edgecombe <rick.p.edgecombe@...el.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@...radead.org>
Cc: <akpm@...ux-foundation.org>
Cc: <ard.biesheuvel@...aro.org>
Cc: <deneen.t.dock@...el.com>
Cc: <kernel-hardening@...ts.openwall.com>
Cc: <kristen@...ux.intel.com>
Cc: <linux_dti@...oud.com>
Cc: <will.deacon@....com>
Cc: Andy Lutomirski <luto@...nel.org>
Cc: Borislav Petkov <bp@...en8.de>
Cc: Dave Hansen <dave.hansen@...ux.intel.com>
Cc: H. Peter Anvin <hpa@...or.com>
Cc: Linus Torvalds <torvalds@...ux-foundation.org>
Cc: Rik van Riel <riel@...riel.com>
Cc: Thomas Gleixner <tglx@...utronix.de>
Link: https://lkml.kernel.org/r/20190426001143.4983-23-namit@vmware.com
Signed-off-by: Ingo Molnar <mingo@...nel.org>
---
arch/x86/include/asm/tlbflush.h | 2 ++
include/asm-generic/tlb.h | 9 +++++++++
2 files changed, 11 insertions(+)
diff --git a/arch/x86/include/asm/tlbflush.h b/arch/x86/include/asm/tlbflush.h
index f4204bf377fc..e9eae3d6ef02 100644
--- a/arch/x86/include/asm/tlbflush.h
+++ b/arch/x86/include/asm/tlbflush.h
@@ -274,6 +274,8 @@ static inline bool nmi_uaccess_okay(void)
return true;
}
+#define nmi_uaccess_okay nmi_uaccess_okay
+
/* Initialize cr4 shadow for this CPU. */
static inline void cr4_init_shadow(void)
{
diff --git a/include/asm-generic/tlb.h b/include/asm-generic/tlb.h
index 6be86c1c5c58..075b353cae86 100644
--- a/include/asm-generic/tlb.h
+++ b/include/asm-generic/tlb.h
@@ -20,6 +20,15 @@
#include <asm/pgalloc.h>
#include <asm/tlbflush.h>
+/*
+ * Blindly accessing user memory from NMI context can be dangerous
+ * if we're in the middle of switching the current user task or switching
+ * the loaded mm.
+ */
+#ifndef nmi_uaccess_okay
+# define nmi_uaccess_okay() true
+#endif
+
#ifdef CONFIG_MMU
#ifdef CONFIG_HAVE_RCU_TABLE_FREE
Powered by blists - more mailing lists