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: <cbedde00-a0f4-6714-f7f4-a180dca15ce0@suse.cz>
Date:   Wed, 29 Aug 2018 16:38:47 +0200
From:   Jiri Slaby <jslaby@...e.cz>
To:     Dmitry Safonov <dima@...sta.com>, linux-kernel@...r.kernel.org
Cc:     Daniel Axtens <dja@...ens.net>,
        Dmitry Safonov <0x7f454c46@...il.com>,
        Sergey Senozhatsky <sergey.senozhatsky.work@...il.com>,
        Dmitry Vyukov <dvyukov@...gle.com>,
        Tan Xiaojun <tanxiaojun@...wei.com>,
        Peter Hurley <peter@...leysoftware.com>,
        Pasi Kärkkäinen <pasik@....fi>,
        Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
        Michael Neuling <mikey@...ling.org>,
        Mikulas Patocka <mpatocka@...hat.com>, stable@...r.kernel.org
Subject: Re: [PATCH 1/4] tty: Drop tty->count on tty_reopen() failure

On 08/29/2018, 04:23 AM, Dmitry Safonov wrote:
> In case of tty_ldisc_reinit() failure, tty->count should be decremented
> back, otherwise we will never release_tty().
> Never seen it in the real life, but it seems not really hard to hit.

I did see it. And this fixes it.

> Cc: Greg Kroah-Hartman <gregkh@...uxfoundation.org>
> Cc: Jiri Slaby <jslaby@...e.com>
> Cc: stable@...r.kernel.org
> Signed-off-by: Dmitry Safonov <dima@...sta.com>
> ---
>  drivers/tty/tty_io.c | 11 ++++++++---
>  1 file changed, 8 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c
> index 32bc3e3fe4d3..5e5da9acaf0a 100644
> --- a/drivers/tty/tty_io.c
> +++ b/drivers/tty/tty_io.c
> @@ -1255,6 +1255,7 @@ static void tty_driver_remove_tty(struct tty_driver *driver, struct tty_struct *
>  static int tty_reopen(struct tty_struct *tty)
>  {
>  	struct tty_driver *driver = tty->driver;
> +	int retval;
>  
>  	if (driver->type == TTY_DRIVER_TYPE_PTY &&
>  	    driver->subtype == PTY_TYPE_MASTER)
> @@ -1268,10 +1269,14 @@ static int tty_reopen(struct tty_struct *tty)
>  
>  	tty->count++;
>  
> -	if (!tty->ldisc)
> -		return tty_ldisc_reinit(tty, tty->termios.c_line);
> +	if (tty->ldisc)
> +		return 0;
>  
> -	return 0;
> +	retval = tty_ldisc_reinit(tty, tty->termios.c_line);
> +	if (retval)
> +		tty->count--;

I would just do:
  if (!retval)
    tty->count++;
here. Nobody from ldiscs should rely on tty->count.

> +	return retval;

thanks,
-- 
js
suse labs

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ