[Devel] [PATCH rh7] tty: Fix task hang if one of peers is sitting in read

Vladimir Davydov vdavydov at virtuozzo.com
Fri Jan 29 01:55:11 PST 2016


On Thu, Jan 28, 2016 at 06:30:58PM +0300, Cyrill Gorcunov wrote:

> @@ -679,16 +679,13 @@ void tty_ldisc_hangup(struct tty_struct
>  	wake_up_interruptible_poll(&tty->write_wait, POLLOUT);
>  	wake_up_interruptible_poll(&tty->read_wait, POLLIN);
>  
> -	tty_unlock(tty);
> -
>  	/*
>  	 * Shutdown the current line discipline, and reset it to
>  	 * N_TTY if need be.
>  	 *
>  	 * Avoid racing set_ldisc or tty_ldisc_release
>  	 */
> -	tty_ldisc_lock_pair(tty, tty->link);
> -	tty_lock(tty);
> +	tty_ldisc_lock(tty, MAX_SCHEDULE_TIMEOUT);

Before this patch tty_lock nested into tty_ldisc_lock, not it's
vice-versa in this function, but e.g. tty_set_ldisc still follows the
former locking order. Can't it result in a deadlock or, at least,
lockdep complains?


More information about the Devel mailing list