Skip to content

Commit 5932c9f

Browse files
anadavIngo Molnar
authored andcommitted
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@vmware.com> Signed-off-by: Rick Edgecombe <rick.p.edgecombe@intel.com> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Cc: <akpm@linux-foundation.org> Cc: <ard.biesheuvel@linaro.org> Cc: <deneen.t.dock@intel.com> Cc: <kernel-hardening@lists.openwall.com> Cc: <kristen@linux.intel.com> Cc: <linux_dti@icloud.com> Cc: <will.deacon@arm.com> Cc: Andy Lutomirski <luto@kernel.org> Cc: Borislav Petkov <bp@alien8.de> Cc: Dave Hansen <dave.hansen@linux.intel.com> Cc: H. Peter Anvin <hpa@zytor.com> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Rik van Riel <riel@surriel.com> Cc: Thomas Gleixner <tglx@linutronix.de> Link: https://lkml.kernel.org/r/20190426001143.4983-23-namit@vmware.com Signed-off-by: Ingo Molnar <mingo@kernel.org>
1 parent e836673 commit 5932c9f

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

arch/x86/include/asm/tlbflush.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,8 @@ static inline bool nmi_uaccess_okay(void)
274274
return true;
275275
}
276276

277+
#define nmi_uaccess_okay nmi_uaccess_okay
278+
277279
/* Initialize cr4 shadow for this CPU. */
278280
static inline void cr4_init_shadow(void)
279281
{

include/asm-generic/tlb.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,15 @@
2020
#include <asm/pgalloc.h>
2121
#include <asm/tlbflush.h>
2222

23+
/*
24+
* Blindly accessing user memory from NMI context can be dangerous
25+
* if we're in the middle of switching the current user task or switching
26+
* the loaded mm.
27+
*/
28+
#ifndef nmi_uaccess_okay
29+
# define nmi_uaccess_okay() true
30+
#endif
31+
2332
#ifdef CONFIG_MMU
2433

2534
#ifdef CONFIG_HAVE_RCU_TABLE_FREE

0 commit comments

Comments
 (0)