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: <1354556465.2531.169.camel@thor>
Date:	Mon, 03 Dec 2012 12:41:05 -0500
From:	Peter Hurley <peter@...leysoftware.com>
To:	Sebastian Andrzej Siewior <bigeasy@...utronix.de>
Cc:	Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
	Alan Cox <alan@...rguk.ukuu.org.uk>,
	linux-kernel@...r.kernel.org, linux-usb@...r.kernel.org,
	Alan Cox <alan@...ux.intel.com>
Subject: Re: [PATCH RESEND] tty: don't dead lock while flushing workqueue

On Tue, 2012-11-27 at 19:01 +0100, Sebastian Andrzej Siewior wrote:
> Since commit 89c8d91e31f2 ("tty: localise the lock") I see a dead lock
> in one of my dummy_hcd + g_nokia test cases. The first run one was usually
> okay, the second often resulted in a splat by lockdep and the third was
> usually a dead lock.
....
> 
> Before the path mentioned tty_ldisc_release() look like this:
> 
> |	tty_ldisc_halt(tty);
> |	tty_ldisc_flush_works(tty);
> |	tty_lock();
> 
> As it can be seen, it first flushes the workqueue and then grabs the
> tty_lock. Now we grab the lock first:
> 
> |	tty_lock_pair(tty, o_tty);
> |	tty_ldisc_halt(tty);
> |	tty_ldisc_flush_works(tty);
> 
> so lockdep's complaint seems valid.
> 
> The other user of tty_ldisc_flush_works() is tty_set_ldisc() and I tried
> to mimnic its logic:

The lock logic for tty_set_ldisc() is wrong. Despite existing code in
tty_set_ldisc() and tty_ldisc_hangup(), the ldisc_mutex does **not**
(and should not) play a role in acquiring or releasing ldisc references.
The only thing that needs to happen here is below (don't actually use
below because I just hand-edited it):

> See http://lkml.org/lkml/2012/11/21/347
> 
>  drivers/tty/tty_ldisc.c |   13 +++++++++----
>  1 file changed, 9 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/tty/tty_ldisc.c b/drivers/tty/tty_ldisc.c
> index 0f2a2c5..fb76818 100644
> --- a/drivers/tty/tty_ldisc.c
> +++ b/drivers/tty/tty_ldisc.c
> @@ -930,16 +930,21 @@ void tty_ldisc_release(struct tty_struct *tty, struct tty_struct *o_tty)
>  	 */
>  
> - 	tty_lock_pair(tty, o_tty);
>  	tty_ldisc_halt(tty);
> 	tty_ldisc_flush_works(tty);

 
> +	tty_lock_pair(tty, o_tty);
>  	/* This will need doing differently if we need to lock */
>  	tty_ldisc_kill(tty);
> -
>  	if (o_tty)
>  		tty_ldisc_kill(o_tty);
>  


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