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] [thread-next>] [day] [month] [year] [list]
Message-ID: <20210729133618.GS4397@paulmck-ThinkPad-P17-Gen-1>
Date:   Thu, 29 Jul 2021 06:36:18 -0700
From:   "Paul E. McKenney" <paulmck@...nel.org>
To:     Boqun Feng <boqun.feng@...il.com>
Cc:     rcu@...r.kernel.org, linux-kernel@...r.kernel.org,
        kernel-team@...com, mingo@...nel.org, jiangshanlai@...il.com,
        akpm@...ux-foundation.org, mathieu.desnoyers@...icios.com,
        josh@...htriplett.org, tglx@...utronix.de, peterz@...radead.org,
        rostedt@...dmis.org, dhowells@...hat.com, edumazet@...gle.com,
        fweisbec@...il.com, oleg@...hat.com, joel@...lfernandes.org
Subject: Re: [PATCH rcu 10/18] srcutiny: Mark read-side data races

On Thu, Jul 29, 2021 at 04:23:08PM +0800, Boqun Feng wrote:
> On Wed, Jul 21, 2021 at 01:21:18PM -0700, Paul E. McKenney wrote:
> > This commit marks some interrupt-induced read-side data races in
> > __srcu_read_lock(), __srcu_read_unlock(), and srcu_torture_stats_print().
> > 
> > Signed-off-by: Paul E. McKenney <paulmck@...nel.org>
> > ---
> >  include/linux/srcutiny.h | 8 ++++----
> >  kernel/rcu/srcutiny.c    | 2 +-
> >  2 files changed, 5 insertions(+), 5 deletions(-)
> > 
> > diff --git a/include/linux/srcutiny.h b/include/linux/srcutiny.h
> > index 0e0cf4d6a72a0..6cfaa0a9a9b96 100644
> > --- a/include/linux/srcutiny.h
> > +++ b/include/linux/srcutiny.h
> > @@ -61,7 +61,7 @@ static inline int __srcu_read_lock(struct srcu_struct *ssp)
> >  	int idx;
> >  
> >  	idx = ((READ_ONCE(ssp->srcu_idx) + 1) & 0x2) >> 1;
> > -	WRITE_ONCE(ssp->srcu_lock_nesting[idx], ssp->srcu_lock_nesting[idx] + 1);
> > +	WRITE_ONCE(ssp->srcu_lock_nesting[idx], READ_ONCE(ssp->srcu_lock_nesting[idx]) + 1);
> >  	return idx;
> >  }
> >  
> > @@ -81,11 +81,11 @@ static inline void srcu_torture_stats_print(struct srcu_struct *ssp,
> >  {
> >  	int idx;
> >  
> > -	idx = ((READ_ONCE(ssp->srcu_idx) + 1) & 0x2) >> 1;
> > +	idx = ((data_race(READ_ONCE(ssp->srcu_idx)) + 1) & 0x2) >> 1;
> 
> This looks very weird, any explanation why we want to put data_race() on
> a READ_ONCE()?

We don't want KCSAN to check this read, but we also don't want the
compiler to mess it up.

							Thanx, Paul

> Regards,
> Boqun
> 
> >  	pr_alert("%s%s Tiny SRCU per-CPU(idx=%d): (%hd,%hd)\n",
> >  		 tt, tf, idx,
> > -		 READ_ONCE(ssp->srcu_lock_nesting[!idx]),
> > -		 READ_ONCE(ssp->srcu_lock_nesting[idx]));
> > +		 data_race(READ_ONCE(ssp->srcu_lock_nesting[!idx])),
> > +		 data_race(READ_ONCE(ssp->srcu_lock_nesting[idx])));
> >  }
> >  
> >  #endif
> > diff --git a/kernel/rcu/srcutiny.c b/kernel/rcu/srcutiny.c
> > index 26344dc6483b0..a0ba2ed49bc61 100644
> > --- a/kernel/rcu/srcutiny.c
> > +++ b/kernel/rcu/srcutiny.c
> > @@ -96,7 +96,7 @@ EXPORT_SYMBOL_GPL(cleanup_srcu_struct);
> >   */
> >  void __srcu_read_unlock(struct srcu_struct *ssp, int idx)
> >  {
> > -	int newval = ssp->srcu_lock_nesting[idx] - 1;
> > +	int newval = READ_ONCE(ssp->srcu_lock_nesting[idx]) - 1;
> >  
> >  	WRITE_ONCE(ssp->srcu_lock_nesting[idx], newval);
> >  	if (!newval && READ_ONCE(ssp->srcu_gp_waiting))
> > -- 
> > 2.31.1.189.g2e36527f23
> > 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ