lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date:   Thu, 16 Jun 2022 10:49:38 -0700
From:   "Paul E. McKenney" <paulmck@...nel.org>
To:     Marco Elver <elver@...gle.com>
Cc:     kernel test robot <lkp@...el.com>,
        Frederic Weisbecker <frederic@...nel.org>,
        kbuild-all@...ts.01.org,
        GNU/Weeb Mailing List <gwml@...r.gnuweeb.org>,
        linux-kernel@...r.kernel.org, dvyukov@...gle.com
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

On Thu, Jun 16, 2022 at 07:32:14PM +0200, Marco Elver wrote:
> On Thu, 16 Jun 2022 at 18:44, Paul E. McKenney <paulmck@...nel.org> 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.

Here is hoping!  I will see if I can reproduce locally.  ;-)

> 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.

Good to know, thank you!  Additional local-reproduce opportunities.

> Reviewed-by: Marco Elver <elver@...gle.com>

Applied, thank you!

                                                         Thanx, Paul

> > ------------------------------------------------------------------------
> >
> > commit 81e24ca26ee9933bcacf67a61e3f6ae41a025442
> > Author: Paul E. McKenney <paulmck@...nel.org>
> > 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 <paulmck@...nel.org>
> >     Cc: Frederic Weisbecker <frederic@...nel.org>
> >     Cc: Marco Elver <elver@...gle.com>
> >
> > 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
> >

Powered by blists - more mailing lists