mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Brendan Jackman <jackmanb@google.com>
To: Marco Elver <elver@google.com>, Brendan Jackman <jackmanb@google.com>
Cc: Andrey Ryabinin <ryabinin.a.a@gmail.com>,
	Alexander Potapenko <glider@google.com>,
	 Andrey Konovalov <andreyknvl@gmail.com>,
	Dmitry Vyukov <dvyukov@google.com>,
	 Vincenzo Frascino <vincenzo.frascino@arm.com>,
	Ard Biesheuvel <ardb@kernel.org>,  <kasan-dev@googlegroups.com>,
	<linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v2 2/3] kcsan: mark !__SANITIZE_THREAD__ stub __always_inline
Date: Tue, 16 Dec 2025 09:41:13 +0000	[thread overview]
Message-ID: <DEZJJ7PS876Q.2T6OVVJH0ZGZD@google.com> (raw)
In-Reply-To: <CANpmjNP=_g4Ecfyk7h-Z1bSWho3MXNU3CO_a77zs+phhUZu76Q@mail.gmail.com>

On Mon Dec 15, 2025 at 12:11 PM UTC, Marco Elver wrote:
> On Mon, 15 Dec 2025 at 11:12, Brendan Jackman <jackmanb@google.com> wrote:
>>
>> The x86 instrumented bitops in
>> include/asm-generic/bitops/instrumented-non-atomic.h are
>> KCSAN-instrumented via explicit calls to instrument_* functions from
>> include/linux/instrumented.h.
>>
>> This bitops are used from noinstr code in __sev_es_nmi_complete(). This
>> code avoids noinstr violations by disabling __SANITIZE_THREAD__ etc for
>> the compilation unit.
>>
>> However, when GCOV is enabled, there can still be violations caused by
>> the stub versions of these functions, since coverage instrumentation is
>> injected that causes them to be out-of-lined.
>>
>> Fix this by just applying __always_inline.
>>
>> Signed-off-by: Brendan Jackman <jackmanb@google.com>
>> ---
>>  include/linux/kcsan-checks.h | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/include/linux/kcsan-checks.h b/include/linux/kcsan-checks.h
>> index 92f3843d9ebb8177432bb4eccc151ea66d3dcbb7..cabb2ae46bdc0963bd89533777cab586ab4d5a1b 100644
>> --- a/include/linux/kcsan-checks.h
>> +++ b/include/linux/kcsan-checks.h
>> @@ -226,7 +226,7 @@ static inline void kcsan_end_scoped_access(struct kcsan_scoped_access *sa) { }
>>  #define __kcsan_disable_current kcsan_disable_current
>>  #define __kcsan_enable_current kcsan_enable_current_nowarn
>>  #else /* __SANITIZE_THREAD__ */
>> -static inline void kcsan_check_access(const volatile void *ptr, size_t size,
>> +static __always_inline void kcsan_check_access(const volatile void *ptr, size_t size,
>>                                       int type) { }
>>  static inline void __kcsan_enable_current(void)  { }
>>  static inline void __kcsan_disable_current(void) { }
>
> It wouldn't be wrong to apply __always_inline to these 2 stub
> functions as well, but I think it's fair if you just limit this to the
> ones used from <linux/instrumented.h>. Either way, please
> double-check.

I was thinking here that it's a bug to call these from noinstr code,
regardless of your ambient instrumentation settings.

But yeah, on second thoughts... says who? I don't think that _has_ to be
a bug, we could totally mark them __always_inline.

  reply	other threads:[~2025-12-16  9:41 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-12-15 10:12 [PATCH v2 0/3] Noinstr fixes for K[CA]SAN with GCOV Brendan Jackman
2025-12-15 10:12 ` [PATCH v2 1/3] kasan: mark !__SANITIZE_ADDRESS__ stubs __always_inline Brendan Jackman
2025-12-15 10:12 ` [PATCH v2 2/3] kcsan: mark !__SANITIZE_THREAD__ stub __always_inline Brendan Jackman
2025-12-15 12:11   ` Marco Elver
2025-12-16  9:41     ` Brendan Jackman [this message]
2025-12-15 10:12 ` [PATCH v2 3/3] x86/sev: Disable GCOV on noinstr object Brendan Jackman
2025-12-15 12:15 ` [PATCH v2 0/3] Noinstr fixes for K[CA]SAN with GCOV Marco Elver

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=DEZJJ7PS876Q.2T6OVVJH0ZGZD@google.com \
    --to=jackmanb@google.com \
    --cc=andreyknvl@gmail.com \
    --cc=ardb@kernel.org \
    --cc=dvyukov@google.com \
    --cc=elver@google.com \
    --cc=glider@google.com \
    --cc=kasan-dev@googlegroups.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=ryabinin.a.a@gmail.com \
    --cc=vincenzo.frascino@arm.com \
    /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

all inboxes | Powered by JetHome®