linux-toolchains.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH -tip] kasan: Emit different calls for instrumentable memintrinsics
@ 2023-02-08 18:42 Marco Elver
  2023-02-09 22:43 ` Andrey Konovalov
  2023-02-10 19:25 ` Jakub Jelinek
  0 siblings, 2 replies; 12+ messages in thread
From: Marco Elver @ 2023-02-08 18:42 UTC (permalink / raw)
  To: elver, Peter Zijlstra
  Cc: Masahiro Yamada, Nathan Chancellor, Nick Desaulniers,
	Nicolas Schier, Andrey Ryabinin, Alexander Potapenko,
	Andrey Konovalov, Dmitry Vyukov, Vincenzo Frascino, linux-kbuild,
	kasan-dev, linux-kernel, Ingo Molnar, Tony Lindgren, Ulf Hansson,
	linux-toolchains

Clang 15 will provide an option to prefix calls to memcpy/memset/memmove
with __asan_ in instrumented functions: https://reviews.llvm.org/D122724

GCC does not yet have similar support.

Use it to regain KASAN instrumentation of memcpy/memset/memmove on
architectures that require noinstr to be really free from instrumented
mem*() functions (all GENERIC_ENTRY architectures).

Fixes: 69d4c0d32186 ("entry, kasan, x86: Disallow overriding mem*() functions")
Signed-off-by: Marco Elver <elver@google.com>
---

The Fixes tag is just there to show the dependency, and that people
shouldn't apply this patch without 69d4c0d32186.

---
 scripts/Makefile.kasan | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/scripts/Makefile.kasan b/scripts/Makefile.kasan
index b9e94c5e7097..78336b04c077 100644
--- a/scripts/Makefile.kasan
+++ b/scripts/Makefile.kasan
@@ -38,6 +38,13 @@ endif
 
 CFLAGS_KASAN += $(call cc-param,asan-stack=$(stack_enable))
 
+ifdef CONFIG_GENERIC_ENTRY
+# Instrument memcpy/memset/memmove calls by using instrumented __asan_mem*()
+# instead. With compilers that don't support this option, compiler-inserted
+# memintrinsics won't be checked by KASAN.
+CFLAGS_KASAN += $(call cc-param,asan-kernel-mem-intrinsic-prefix)
+endif
+
 endif # CONFIG_KASAN_GENERIC
 
 ifdef CONFIG_KASAN_SW_TAGS
-- 
2.39.1.519.gcb327c4b5f-goog


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

end of thread, other threads:[~2023-02-13 13:38 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-08 18:42 [PATCH -tip] kasan: Emit different calls for instrumentable memintrinsics Marco Elver
2023-02-09 22:43 ` Andrey Konovalov
2023-02-09 23:34   ` Marco Elver
2023-02-10 16:13     ` Andrey Konovalov
2023-02-10 18:40       ` Marco Elver
2023-02-10 21:36         ` Andrey Konovalov
2023-02-13  7:00           ` Marco Elver
2023-02-10 19:25 ` Jakub Jelinek
2023-02-10 20:07   ` Marco Elver
2023-02-13 11:01     ` Jakub Jelinek
2023-02-13 12:35       ` Peter Zijlstra
2023-02-13 13:37         ` Marco Elver

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).