@@ -36,7 +36,6 @@
#include <asm/smp.h>
#include <asm/alternative.h>
#include <asm/mmu_context.h>
-#include <asm/tlbflush.h>
#include <asm/timer.h>
#include <asm/desc.h>
#include <asm/ldt.h>
@@ -157,9 +157,6 @@ struct tlb_state_shared {
};
DECLARE_PER_CPU_SHARED_ALIGNED(struct tlb_state_shared, cpu_tlbstate_shared);
-bool nmi_uaccess_okay(void);
-#define nmi_uaccess_okay nmi_uaccess_okay
-
/* Initialize cr4 shadow for this CPU. */
static inline void cr4_init_shadow(void)
{
@@ -20,6 +20,9 @@ static inline bool pagefault_disabled(void);
# define WARN_ON_IN_IRQ()
#endif
+bool nmi_uaccess_okay(void);
+#define nmi_uaccess_okay nmi_uaccess_okay
+
/**
* access_ok - Checks if a user space pointer is valid
* @addr: User space pointer to start of block to check
@@ -7,8 +7,6 @@
#include <linux/uaccess.h>
#include <linux/export.h>
-#include <asm/tlbflush.h>
-
/**
* copy_from_user_nmi - NMI safe copy from user
* @to: Pointer to the destination buffer
@@ -17,15 +17,6 @@
#include <asm/tlbflush.h>
#include <asm/cacheflush.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
/*
@@ -10,6 +10,15 @@
#include <asm/uaccess.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
+
/*
* Architectures should provide two primitives (raw_copy_{to,from}_user())
* and get rid of their private instances of copy_{to,from}_user() and
@@ -26,8 +26,6 @@
#include <uapi/linux/bpf.h>
#include <uapi/linux/btf.h>
-#include <asm/tlb.h>
-
#include "trace_probe.h"
#include "trace.h"
In preparation for inlining copy_from_user_in_nmi(), move the nmi_uaccess_okay() declaration into uaccess.h, which makes a bit more sense anyway. Additionally update all callers to remove the no longer needed tlbflush.h include, which was only for the declaration of nmi_uaccess_okay(). Cc: Peter Zijlstra <peterz@infradead.org> Cc: Ingo Molnar <mingo@redhat.com> Cc: Borislav Petkov <bp@alien8.de> Cc: x86@kernel.org Cc: linux-perf-users@vger.kernel.org Cc: bpf@vger.kernel.org Cc: Matthew Wilcox <willy@infradead.org> Cc: Yu Zhao <yuzhao@google.com> Cc: dev@der-flo.net Signed-off-by: Kees Cook <keescook@chromium.org> --- arch/x86/events/core.c | 1 - arch/x86/include/asm/tlbflush.h | 3 --- arch/x86/include/asm/uaccess.h | 3 +++ arch/x86/lib/usercopy.c | 2 -- include/asm-generic/tlb.h | 9 --------- include/linux/uaccess.h | 9 +++++++++ kernel/trace/bpf_trace.c | 2 -- 7 files changed, 12 insertions(+), 17 deletions(-)