public inbox for [email protected]
 help / color / mirror / Atom feed
From: Marco Elver <[email protected]>
To: [email protected]
Cc: kernel test robot <[email protected]>,
	Frederic Weisbecker <[email protected]>,
	[email protected],
	 "GNU/Weeb Mailing List" <[email protected]>,
	[email protected], [email protected]
Subject: Re: [ammarfaizi2-block:paulmck/linux-rcu/pmladek.2022.06.15a 133/140] vmlinux.o: warning: objtool: __ct_user_exit+0x41: call to __kasan_check_read() leaves .noinstr.text section
Date: Thu, 16 Jun 2022 19:32:14 +0200	[thread overview]
Message-ID: <CANpmjNPhfGnO8qebvPd2pEqO37qTAa8pUAOTy2MXqT4R+iZ8QA@mail.gmail.com> (raw)
In-Reply-To: <20220616164416.GA2130702@paulmck-ThinkPad-P17-Gen-1>

On Thu, 16 Jun 2022 at 18:44, Paul E. McKenney <[email protected]> wrote:
[...]
> > > > > > >> vmlinux.o: warning: objtool: __ct_user_exit+0x41: call to __kasan_check_read() leaves .noinstr.text section
> > > > > > >> vmlinux.o: warning: objtool: __ct_user_enter+0x7f: call to __kasan_check_read() leaves .noinstr.text section
[...]
> > > It's due to the atomic_read()s within the noinstr function. Within
> > > noinstr you can use arch_atomic_read() to avoid the instrumentation.
> >
> > Thank you, will fix!
>
> And please see below for an alleged fix.

Looks good, if this made the above warnings go away.

Btw, it's not just KASAN, but arch_atomic_read() also disables KCSAN
checking. A similar warning would have been generated in a KCSAN
config.

Reviewed-by: Marco Elver <[email protected]>

>                                                         Thanx, Paul
>
> ------------------------------------------------------------------------
>
> commit 81e24ca26ee9933bcacf67a61e3f6ae41a025442
> Author: Paul E. McKenney <[email protected]>
> Date:   Thu Jun 16 09:30:37 2022 -0700
>
>     context_tracking: Use arch_atomic_read() in __ct_state for KASAN
>
>     Context tracking's __ct_state() function can be invoked from noinstr state
>     where RCU is not watching.  This means that its use of atomic_read()
>     causes KASAN to invoke the non-noinstr __kasan_check_read() function
>     from the noinstr function __ct_state().  This is problematic because
>     someone tracing the __kasan_check_read() function could get a nasty
>     surprise because of RCU not watching.
>
>     This commit therefore replaces the __ct_state() function's use of
>     atomic_read() with arch_atomic_read(), which KASAN does not attempt to
>     add instrumention to.
>
>     Signed-off-by: Paul E. McKenney <[email protected]>
>     Cc: Frederic Weisbecker <[email protected]>
>     Cc: Marco Elver <[email protected]>
>
> diff --git a/include/linux/context_tracking_state.h b/include/linux/context_tracking_state.h
> index 0aecc07fb4f50..81c51e5f03143 100644
> --- a/include/linux/context_tracking_state.h
> +++ b/include/linux/context_tracking_state.h
> @@ -49,7 +49,7 @@ DECLARE_PER_CPU(struct context_tracking, context_tracking);
>
>  static __always_inline int __ct_state(void)
>  {
> -       return atomic_read(this_cpu_ptr(&context_tracking.state)) & CT_STATE_MASK;
> +       return arch_atomic_read(this_cpu_ptr(&context_tracking.state)) & CT_STATE_MASK;
>  }
>  #endif
>

  reply	other threads:[~2022-06-16 17:32 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-15 20:26 [ammarfaizi2-block:paulmck/linux-rcu/pmladek.2022.06.15a 133/140] vmlinux.o: warning: objtool: __ct_user_exit+0x41: call to __kasan_check_read() leaves .noinstr.text section kernel test robot
2022-06-15 20:40 ` Paul E. McKenney
2022-06-15 21:17   ` Paul E. McKenney
2022-06-16  8:19     ` Marco Elver
2022-06-16 13:40       ` Paul E. McKenney
2022-06-16 16:44         ` Paul E. McKenney
2022-06-16 17:32           ` Marco Elver [this message]
2022-06-16 17:49             ` Paul E. McKenney

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=CANpmjNPhfGnO8qebvPd2pEqO37qTAa8pUAOTy2MXqT4R+iZ8QA@mail.gmail.com \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    /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