archive mirror
 help / color / mirror / Atom feed
From: Marco Elver <>
To:, Peter Zijlstra <>
Cc: Masahiro Yamada <>,
	Nathan Chancellor <>,
	Nick Desaulniers <>,
	Nicolas Schier <>,
	Andrey Ryabinin <>,
	Alexander Potapenko <>,
	Andrey Konovalov <>,
	Dmitry Vyukov <>,
	Vincenzo Frascino <>,,,, Ingo Molnar <>,
	Tony Lindgren <>,
	Ulf Hansson <>,
	Jakub Jelinek <>,
Subject: [PATCH -tip v2] kasan: Emit different calls for instrumentable memintrinsics
Date: Mon, 13 Feb 2023 21:10:40 +0100	[thread overview]
Message-ID: <> (raw)

Clang 15 will provide an option to prefix calls to memcpy/memset/memmove
with __asan_ in instrumented functions:

GCC will add support in future:

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 <>
* Use asan-kernel-mem-intrinsic-prefix=1, so that once GCC supports the
  param, it also works there (it needs the =1).

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))
+# 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)

                 reply	other threads:[~2023-02-13 20:10 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).