From: Dmitry Vyukov <dvyukov@google.com>
To: Alexander Potapenko <glider@google.com>
Cc: quic_jiangenj@quicinc.com, linux-kernel@vger.kernel.org,
kasan-dev@googlegroups.com, Aleksandr Nogikh <nogikh@google.com>,
Andrey Konovalov <andreyknvl@gmail.com>,
Borislav Petkov <bp@alien8.de>,
Dave Hansen <dave.hansen@linux.intel.com>,
Ingo Molnar <mingo@redhat.com>,
Josh Poimboeuf <jpoimboe@kernel.org>,
Marco Elver <elver@google.com>,
Peter Zijlstra <peterz@infradead.org>,
Thomas Gleixner <tglx@linutronix.de>
Subject: Re: [PATCH v2 05/11] mm/kasan: define __asan_before_dynamic_init, __asan_after_dynamic_init
Date: Wed, 9 Jul 2025 16:53:13 +0200 [thread overview]
Message-ID: <CACT4Y+ahHYybYkvT8z8rzr55mmSp-_EDCVZsh+f_TX9mnCJoiA@mail.gmail.com> (raw)
In-Reply-To: <20250626134158.3385080-6-glider@google.com>
On Thu, 26 Jun 2025 at 15:42, Alexander Potapenko <glider@google.com> wrote:
>
> Calls to __asan_before_dynamic_init() and __asan_after_dynamic_init()
> are inserted by Clang when building with coverage guards.
> These functions can be used to detect initialization order fiasco bugs
> in the userspace, but it is fine for them to be no-ops in the kernel.
>
> Signed-off-by: Alexander Potapenko <glider@google.com>
Reviewed-by: Dmitry Vyukov <dvyukov@google.com>
>
> ---
> Change-Id: I7f8eb690a3d96f7d122205e8f1cba8039f6a68eb
>
> v2:
> - Address comments by Dmitry Vyukov:
> - rename CONFIG_KCOV_ENABLE_GUARDS to CONFIG_KCOV_UNIQUE
> - Move this patch before the one introducing CONFIG_KCOV_UNIQUE,
> per Marco Elver's request.
> ---
> mm/kasan/generic.c | 18 ++++++++++++++++++
> mm/kasan/kasan.h | 2 ++
> 2 files changed, 20 insertions(+)
>
> diff --git a/mm/kasan/generic.c b/mm/kasan/generic.c
> index d54e89f8c3e76..b0b7781524348 100644
> --- a/mm/kasan/generic.c
> +++ b/mm/kasan/generic.c
> @@ -238,6 +238,24 @@ void __asan_unregister_globals(void *ptr, ssize_t size)
> }
> EXPORT_SYMBOL(__asan_unregister_globals);
>
> +#if defined(CONFIG_KCOV_UNIQUE)
> +/*
> + * __asan_before_dynamic_init() and __asan_after_dynamic_init() are inserted
> + * when the user requests building with coverage guards. In the userspace, these
> + * two functions can be used to detect initialization order fiasco bugs, but in
> + * the kernel they can be no-ops.
> + */
> +void __asan_before_dynamic_init(const char *module_name)
> +{
> +}
> +EXPORT_SYMBOL(__asan_before_dynamic_init);
> +
> +void __asan_after_dynamic_init(void)
> +{
> +}
> +EXPORT_SYMBOL(__asan_after_dynamic_init);
> +#endif
> +
> #define DEFINE_ASAN_LOAD_STORE(size) \
> void __asan_load##size(void *addr) \
> { \
> diff --git a/mm/kasan/kasan.h b/mm/kasan/kasan.h
> index 129178be5e649..c817c46b4fcd2 100644
> --- a/mm/kasan/kasan.h
> +++ b/mm/kasan/kasan.h
> @@ -582,6 +582,8 @@ void kasan_restore_multi_shot(bool enabled);
>
> void __asan_register_globals(void *globals, ssize_t size);
> void __asan_unregister_globals(void *globals, ssize_t size);
> +void __asan_before_dynamic_init(const char *module_name);
> +void __asan_after_dynamic_init(void);
> void __asan_handle_no_return(void);
> void __asan_alloca_poison(void *, ssize_t size);
> void __asan_allocas_unpoison(void *stack_top, ssize_t stack_bottom);
> --
> 2.50.0.727.gbf7dc18ff4-goog
>
next prev parent reply other threads:[~2025-07-09 14:53 UTC|newest]
Thread overview: 43+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-26 13:41 [PATCH v2 00/11] Coverage deduplication for KCOV Alexander Potapenko
2025-06-26 13:41 ` [PATCH v2 01/11] x86: kcov: disable instrumentation of arch/x86/kernel/tsc.c Alexander Potapenko
2025-06-27 7:59 ` Peter Zijlstra
2025-06-27 10:51 ` Alexander Potapenko
2025-06-30 7:43 ` Peter Zijlstra
2025-06-30 13:39 ` Alexander Potapenko
2025-06-26 13:41 ` [PATCH v2 02/11] kcov: apply clang-format to kcov code Alexander Potapenko
2025-06-27 8:02 ` Peter Zijlstra
2025-06-27 12:50 ` Alexander Potapenko
2025-06-29 19:25 ` Miguel Ojeda
2025-06-30 6:40 ` Alexander Potapenko
2025-06-30 8:09 ` Peter Zijlstra
2025-06-30 18:14 ` Miguel Ojeda
2025-06-30 7:56 ` Peter Zijlstra
2025-07-03 7:51 ` David Laight
2025-06-26 13:41 ` [PATCH v2 03/11] kcov: elaborate on using the shared buffer Alexander Potapenko
2025-07-09 13:12 ` Dmitry Vyukov
2025-06-26 13:41 ` [PATCH v2 04/11] kcov: factor out struct kcov_state Alexander Potapenko
2025-07-09 14:51 ` Dmitry Vyukov
2025-07-24 14:08 ` Alexander Potapenko
2025-06-26 13:41 ` [PATCH v2 05/11] mm/kasan: define __asan_before_dynamic_init, __asan_after_dynamic_init Alexander Potapenko
2025-07-09 14:53 ` Dmitry Vyukov [this message]
2025-06-26 13:41 ` [PATCH v2 06/11] kcov: x86: introduce CONFIG_KCOV_UNIQUE Alexander Potapenko
2025-06-27 8:11 ` Peter Zijlstra
2025-06-27 14:24 ` Alexander Potapenko
2025-06-27 14:32 ` Alexander Potapenko
2025-06-30 7:49 ` Peter Zijlstra
2025-07-09 15:01 ` Dmitry Vyukov
2025-07-25 10:07 ` Alexander Potapenko
2025-07-25 10:21 ` Dmitry Vyukov
2025-06-26 13:41 ` [PATCH v2 07/11] kcov: add trace and trace_size to struct kcov_state Alexander Potapenko
2025-06-27 12:34 ` kernel test robot
2025-07-09 15:05 ` Dmitry Vyukov
2025-07-25 10:45 ` Alexander Potapenko
2025-06-26 13:41 ` [PATCH v2 08/11] kcov: add ioctl(KCOV_UNIQUE_ENABLE) Alexander Potapenko
2025-06-27 8:27 ` Peter Zijlstra
2025-06-27 13:58 ` Alexander Potapenko
2025-06-30 7:54 ` Peter Zijlstra
2025-06-26 13:41 ` [PATCH v2 09/11] kcov: add ioctl(KCOV_RESET_TRACE) Alexander Potapenko
2025-06-26 13:41 ` [PATCH v2 10/11] kcov: selftests: add kcov_test Alexander Potapenko
2025-07-09 15:15 ` Dmitry Vyukov
2025-07-25 14:37 ` Alexander Potapenko
2025-06-26 13:41 ` [PATCH v2 11/11] kcov: use enum kcov_mode in kcov_mode_enabled() Alexander Potapenko
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:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CACT4Y+ahHYybYkvT8z8rzr55mmSp-_EDCVZsh+f_TX9mnCJoiA@mail.gmail.com \
--to=dvyukov@google.com \
--cc=andreyknvl@gmail.com \
--cc=bp@alien8.de \
--cc=dave.hansen@linux.intel.com \
--cc=elver@google.com \
--cc=glider@google.com \
--cc=jpoimboe@kernel.org \
--cc=kasan-dev@googlegroups.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=nogikh@google.com \
--cc=peterz@infradead.org \
--cc=quic_jiangenj@quicinc.com \
--cc=tglx@linutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* 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).