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:	Fri, 08 Jun 2012 17:08:34 +0200
From:	Peter Zijlstra <peterz@...radead.org>
To:	"J. Bruce Fields" <bfields@...ldses.org>
Cc:	Linus Torvalds <torvalds@...ux-foundation.org>,
	Dave Jones <davej@...hat.com>,
	Al Viro <viro@...iv.linux.org.uk>,
	Linux Kernel <linux-kernel@...r.kernel.org>,
	Miklos Szeredi <mszeredi@...e.cz>, Jan Kara <jack@...e.cz>
Subject: Re: processes hung after sys_renameat, and 'missing' processes

On Fri, 2012-06-08 at 10:46 -0400, J. Bruce Fields wrote:
> > > > Sadly, if you get that annotation wrong you can annotate an actual
> > > > deadlock away.
> 
> What's a (contrived as you want) example where that happens?

spinlock_t lock_array[10];

void init_array(void)
{
	int i;

	for (i = 0; i < ARRAY_SIZE(lock_array); i++)
		spin_lock_init(array + i);
}

void double_lock(int a, int b)
{
	spin_lock(lock_array + a);
	spin_lock_nested(lock_array + b, SINGLE_DEPTH_NESTING);
}

The above places all locks in the array in the same class, it then does
a double lock without order, but tells lockdep the nesting is ok.

A correct version of the double_lock() function would look like:

void double_lock(int a, int b)
{
	if (b < a)
		swap(a, b);

	spin_lock(lock_array + a);
	spin_lock_nested(lock_array + b, SINGLE_DEPTH_NESTING);
}

This orders the locks in array order.

> > > > This the reason you have to be very careful when
> > > > annotating stuff.
> 
> Or alternatively--what do I need to check before I call
> mutex_lock_nested? 

That the lock order you tell lockdep is ok, is indeed correct.


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