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]
Date:	Thu, 2 Feb 2012 08:20:17 -0800
From:	"Paul E. McKenney" <paulmck@...ux.vnet.ibm.com>
To:	Josh Triplett <josh@...htriplett.org>
Cc:	linux-kernel@...r.kernel.org, mingo@...e.hu, laijs@...fujitsu.com,
	dipankar@...ibm.com, akpm@...ux-foundation.org,
	mathieu.desnoyers@...ymtl.ca, niv@...ibm.com, tglx@...utronix.de,
	peterz@...radead.org, rostedt@...dmis.org, Valdis.Kletnieks@...edu,
	dhowells@...hat.com, eric.dumazet@...il.com, darren@...art.com,
	fweisbec@...il.com, patches@...aro.org
Subject: Re: [PATCH RFC tip/core/rcu 03/41] rcu: Add lockdep-RCU checks for
 simple self-deadlock

On Wed, Feb 01, 2012 at 04:55:54PM -0800, Josh Triplett wrote:
> On Wed, Feb 01, 2012 at 11:41:21AM -0800, Paul E. McKenney wrote:
> > From: "Paul E. McKenney" <paulmck@...ux.vnet.ibm.com>
> > 
> > It is illegal to have a grace period within a same-flavor RCU read-side
> > critical section, so this commit adds lockdep-RCU checks to splat when
> > such abuse is encountered.  This commit does not detect more elaborate
> > RCU deadlock situations.  These situations might be a job for lockdep
> > enhancements.
> 
> Since doing so also violates the prohibition on blocking within an RCU
> read-side critical section, wouldn't it suffice to call might_sleep() or
> equivalent, which also detects other problems?  (Obviously this doesn't
> apply to SRCU, but it applies to the other variants of RCU.)

Yes, but...

The advantage of the lockdep-RCU splat is that it gives you a better
hint as to where the RCU read-side critical section was entered, which
is very helpful when tracking these down, especially when they are
intermittent.

On of the downsides of the Linux kernel community being more RCU-savvy
is that the errors they now tend to commit are more complex.  ;-)

And yes, I should also well check for the other variants of RCU read-side
critical section (other than RCU).  Done.

I also glued the strings together to promote grepability as you suggest
later.  (But I leave it to you to get checkpatch.pl upgraded -- it currently
warns about long lines, but not about strings split across lines.)

> > --- a/kernel/rcutiny.c
> > +++ b/kernel/rcutiny.c
> > @@ -319,6 +319,9 @@ static void rcu_process_callbacks(struct softirq_action *unused)
> >   */
> >  void synchronize_sched(void)
> >  {
> > +	rcu_lockdep_assert(!lock_is_held(&rcu_sched_lock_map),
> > +			   "Illegal grace period in RCU read-side "
> > +			   "critical section");
> 
> This message doesn't seem entirely obvious to me.  A grace period didn't
> occur; a synchronize call did, which tried to request a grace period
> that can never happen.

I suppose I might as well make it consistent with the other messages.  ;-)

> > --- a/kernel/rcutree.c
> > +++ b/kernel/rcutree.c
> > @@ -1816,6 +1816,9 @@ EXPORT_SYMBOL_GPL(call_rcu_bh);
> >   */
> >  void synchronize_sched(void)
> >  {
> > +	rcu_lockdep_assert(!lock_is_held(&rcu_sched_lock_map),
> > +			   "Illegal synchronize_sched() in RCU-sched "
> > +			   "read-side critical section");
> >  	if (rcu_blocking_is_gp())
> >  		return;
> >  	wait_rcu_gp(call_rcu_sched);
> > @@ -1833,6 +1836,9 @@ EXPORT_SYMBOL_GPL(synchronize_sched);
> >   */
> >  void synchronize_rcu_bh(void)
> >  {
> > +	rcu_lockdep_assert(!lock_is_held(&rcu_bh_lock_map),
> > +			   "Illegal synchronize_sched() in RCU-bh "
> > +			   "read-side critical section");
> 
> Copy-paste problem here: this should say synchronize_sched_bh.  (Or
> perhaps it should say __func__. :) )

Fixed, but will pass on __func__ for the moment.  Cool though it might
be to exercise varargs.  ;-)

> > --- a/kernel/srcu.c
> > +++ b/kernel/srcu.c
> > @@ -172,6 +172,10 @@ static void __synchronize_srcu(struct srcu_struct *sp, void (*sync_func)(void))
> >  {
> >  	int idx;
> >  
> > +	rcu_lockdep_assert(!lock_is_held(&sp->dep_map),
> > +			   "Illegal SRCU grace period in same-type "
> > +			   "SRCU read-side critical section");
> 
> Same issue with the message: a grace period didn't occur, and it never
> will; a call to synchronize_srcu requesting a grace period occurred.

Good catch, fixed!

							Thanx, Paul

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ