From f1632e4deb16a4bef15fe96986425dc8fdd14b4e Mon Sep 17 00:00:00 2001 From: Nadav Amit Date: Thu, 25 Apr 2019 17:11:42 -0700 Subject: [PATCH] UPSTREAM: 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. Change-Id: Ie710d06700a2c5b392bff0dbc82798f9c0d985cc Signed-off-by: Nadav Amit Signed-off-by: Rick Edgecombe Signed-off-by: Peter Zijlstra (Intel) Cc: Cc: Cc: Cc: Cc: Cc: Cc: Cc: Andy Lutomirski Cc: Borislav Petkov Cc: Dave Hansen Cc: H. Peter Anvin Cc: Linus Torvalds Cc: Rik van Riel Cc: Thomas Gleixner Link: https://lkml.kernel.org/r/20190426001143.4983-23-namit@vmware.com Signed-off-by: Ingo Molnar --- include/asm-generic/tlb.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/include/asm-generic/tlb.h b/include/asm-generic/tlb.h index b06240b67199..fd5f54b9c863 100644 --- a/include/asm-generic/tlb.h +++ b/include/asm-generic/tlb.h @@ -26,6 +26,15 @@ # define nmi_uaccess_okay() true #endif +/* + * 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 /*