lists.openwall.net | lists / announce owl-users owl-dev john-users john-dev passwdqc-users yescrypt popa3d-users / oss-security kernel-hardening musl sabotage tlsify passwords / crypt-dev xvendor / Bugtraq Full-Disclosure linux-kernel linux-netdev linux-ext4 linux-hardening linux-cve-announce PHC | |
Open Source and information security mailing list archives
| ||
|
Message-Id: <20220916135953.1320601-2-keescook@chromium.org> Date: Fri, 16 Sep 2022 06:59:53 -0700 From: Kees Cook <keescook@...omium.org> To: Matthew Wilcox <willy@...radead.org> Cc: Kees Cook <keescook@...omium.org>, Uladzislau Rezki <urezki@...il.com>, Peter Zijlstra <peterz@...radead.org>, Ingo Molnar <mingo@...hat.com>, Borislav Petkov <bp@...en8.de>, x86@...nel.org, linux-perf-users@...r.kernel.org, bpf@...r.kernel.org, Yu Zhao <yuzhao@...gle.com>, dev@...-flo.net, Andrew Morton <akpm@...ux-foundation.org>, linux-kernel@...r.kernel.org, linux-mm@...ck.org, linux-hardening@...r.kernel.org, linux-arch@...r.kernel.org Subject: [PATCH 1/3] x86/uaccess: Move nmi_uaccess_okay() into uaccess.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@...radead.org> Cc: Ingo Molnar <mingo@...hat.com> Cc: Borislav Petkov <bp@...en8.de> Cc: x86@...nel.org Cc: linux-perf-users@...r.kernel.org Cc: bpf@...r.kernel.org Cc: Matthew Wilcox <willy@...radead.org> Cc: Yu Zhao <yuzhao@...gle.com> Cc: dev@...-flo.net Signed-off-by: Kees Cook <keescook@...omium.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(-) diff --git a/arch/x86/events/core.c b/arch/x86/events/core.c index f969410d0c90..3e2bb6324ca3 100644 --- a/arch/x86/events/core.c +++ b/arch/x86/events/core.c @@ -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> diff --git a/arch/x86/include/asm/tlbflush.h b/arch/x86/include/asm/tlbflush.h index cda3118f3b27..233818bb72c6 100644 --- a/arch/x86/include/asm/tlbflush.h +++ b/arch/x86/include/asm/tlbflush.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) { diff --git a/arch/x86/include/asm/uaccess.h b/arch/x86/include/asm/uaccess.h index 913e593a3b45..e9390eea861b 100644 --- a/arch/x86/include/asm/uaccess.h +++ b/arch/x86/include/asm/uaccess.h @@ -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 diff --git a/arch/x86/lib/usercopy.c b/arch/x86/lib/usercopy.c index ad0139d25401..959489f2f814 100644 --- a/arch/x86/lib/usercopy.c +++ b/arch/x86/lib/usercopy.c @@ -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 diff --git a/include/asm-generic/tlb.h b/include/asm-generic/tlb.h index 492dce43236e..14efd74f3e70 100644 --- a/include/asm-generic/tlb.h +++ b/include/asm-generic/tlb.h @@ -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 /* diff --git a/include/linux/uaccess.h b/include/linux/uaccess.h index 47e5d374c7eb..065e121d2a86 100644 --- a/include/linux/uaccess.h +++ b/include/linux/uaccess.h @@ -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 diff --git a/kernel/trace/bpf_trace.c b/kernel/trace/bpf_trace.c index 68e5cdd24cef..0fd185c3d174 100644 --- a/kernel/trace/bpf_trace.c +++ b/kernel/trace/bpf_trace.c @@ -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" -- 2.34.1
Powered by blists - more mailing lists