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:	Mon, 10 Aug 2015 16:24:17 +0200
From:	Peter Zijlstra <peterz@...radead.org>
To:	Boqun Feng <boqun.feng@...il.com>
Cc:	Ingo Molnar <mingo@...hat.com>, linux-kernel@...r.kernel.org
Subject: Re: [Question] lockdep: Is nested lock handled correctly?

On Mon, Aug 10, 2015 at 09:49:24PM +0800, Boqun Feng wrote:
> Hi Peter,
> 
> On Mon, Aug 10, 2015 at 01:42:28PM +0200, Peter Zijlstra wrote:
> > On Mon, Aug 10, 2015 at 05:52:47PM +0800, Boqun Feng wrote:
> > > Hi Peter and Ingo,
> > > 
> > > I'm now learning the code of lockdep and find that nested lock may not
> > > be handled correctly because we fail to take held_lock merging into
> > > consideration. I come up with an example and hope that could explain my
> > > concern.
> > > 
> > > Please consider this lock/unlock sequence, I also put a patch ading this
> > > sequence as a test into locking-selftest:
> > > 
> > > (lock_X1 and lock_X2 belong to the same lock class X, lock_Y1 belongs to
> > > another lock class Y)
> > > 
> > > spin_lock(&lock_X1);
> > > spin_lock(&lock_Y1);
> > > spin_lock_nested_lock(&lock_X2, &lock_X1);
> 
> Sorry for the typo here.. should be spin_lock_nest_lock().
> 
> > > spin_unlock(&lock_Y1);
> > > spin_unlock(&lock_X2);
> > > spin_unlock(&lock_X1);
> > > 
> > > 
> > > This is totally legal in current lockdep rules, right? 
> > 
> > Yuck, I'd say no. That's quite horrible.
> > 
> 
> I admit that I didn't find this is horrible at first, but now I agree
> with you, this is not a rational locking order. Thank you.
> 
> > Why would you ever want to do that?
> 
> Though I don't want to have a locking order like that either, we can't
> stop others from using that order(maybe a good design review will) and
> lockdep yells something -unrelated- in such an order.
> 
> I think we can either let lockdep complain if some one uses this
> locking order or clean up current code a little bit to tolarent this.
> 
> If you really think we should do something about it, I can write the
> patch and add test cases.


Maybe something like the below in __lock_acquire():

	/* Daft bugger, can't guard a nesting order with the same lock class */
	if (DEBUG_LOCKS_WARN_ON(lock == nest_lock))
		return 0;

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