All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] x86/uaccess: instrument copy_from_user_nmi()
@ 2022-10-25 22:17 Alexander Potapenko
  2022-10-26  9:30 ` Peter Zijlstra
  0 siblings, 1 reply; 8+ messages in thread
From: Alexander Potapenko @ 2022-10-25 22:17 UTC (permalink / raw)
  To: glider; +Cc: linux-kernel, linux-mm, Andrew Morton, Dave Hansen, Kees Cook, x86

Make sure usercopy hooks from linux/instrumented.h are invoked for
copy_from_user_nmi().
This fixes KMSAN false positives reported when dumping opcodes for a
stack trace.

Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Cc: Kees Cook <keescook@chromium.org>
Cc: x86@kernel.org
Signed-off-by: Alexander Potapenko <glider@google.com>
---
 arch/x86/lib/usercopy.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/arch/x86/lib/usercopy.c b/arch/x86/lib/usercopy.c
index f1bb186171562..24b48af274173 100644
--- a/arch/x86/lib/usercopy.c
+++ b/arch/x86/lib/usercopy.c
@@ -6,6 +6,7 @@
 
 #include <linux/uaccess.h>
 #include <linux/export.h>
+#include <linux/instrumented.h>
 
 #include <asm/tlbflush.h>
 
@@ -44,7 +45,9 @@ copy_from_user_nmi(void *to, const void __user *from, unsigned long n)
 	 * called from other contexts.
 	 */
 	pagefault_disable();
+	instrument_copy_from_user_before(to, from, n);
 	ret = raw_copy_from_user(to, from, n);
+	instrument_copy_from_user_after(to, from, n, ret);
 	pagefault_enable();
 
 	return ret;
-- 
2.38.0.135.g90850a2211-goog


^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2022-10-27 23:25 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-25 22:17 [PATCH] x86/uaccess: instrument copy_from_user_nmi() Alexander Potapenko
2022-10-26  9:30 ` Peter Zijlstra
2022-10-26 18:38   ` Alexander Potapenko
2022-10-27  8:05     ` Peter Zijlstra
2022-10-27 18:26       ` Alexander Potapenko
2022-10-27 18:58         ` Kees Cook
2022-10-27 19:26           ` Peter Zijlstra
2022-10-27 23:24           ` Alexander Potapenko

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.