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:   Wed, 20 Nov 2019 15:55:08 +0000
From:   Sudip Mukherjee <sudipm.mukherjee@...il.com>
To:     Greg Kroah-Hartman <gregkh@...uxfoundation.org>
Cc:     Jiri Slaby <jslaby@...e.com>, Rob Herring <robh@...nel.org>,
        linux-kernel@...r.kernel.org, linux-serial@...r.kernel.org
Subject: Re: [PATCH 2/2] tty: add retry to tty_init_dev() to workaround a
 race condition

On Wed, Nov 20, 2019 at 04:44:50PM +0100, Greg Kroah-Hartman wrote:
> On Wed, Nov 20, 2019 at 03:17:09PM +0000, Sudip Mukherjee wrote:
> > There seems to be a race condition in tty drivers and I could see on
> > many boot cycles a NULL pointer dereference as tty_init_dev() tries to
> > do 'tty->port->itty = tty' even though tty->port is NULL.
<snip>
> > +++ b/drivers/tty/pty.c
> > @@ -842,7 +842,7 @@ static int ptmx_open(struct inode *inode, struct file *filp)
> >  
> >  
> >  	mutex_lock(&tty_mutex);
> > -	tty = tty_init_dev(ptm_driver, index);
> > +	tty = tty_init_dev(ptm_driver, index, 0);
> 
> Horrible naming scheme for this new "flag".
> 
> Look at that call here, can you instantly tell what this call is doing
> with "0"?  I sure can not :(

well, I also made the mistake of 1->0 in my initial patch. :(

> 
> If you really want to do this, you make a different function,
> tty_init_dev_retry() and then have that pass in a retry flag in the tty
> core, so that any users always know what they are doing here.

will do.

> 
> But, this really feels like a race in the code somewhere:
> 
> > --- a/drivers/tty/tty_io.c
> > +++ b/drivers/tty/tty_io.c
> > @@ -1295,6 +1295,7 @@ static int tty_reopen(struct tty_struct *tty)
> >   *	tty_init_dev		-	initialise a tty device
> >   *	@driver: tty driver we are opening a device on
> >   *	@idx: device index
> > + *	@retry: retry count if driver has not set tty->port yet
> 
> Why would tty->port not be set up already?  The caller has control over
> this, what is not happening correctly to cause this?

Will add more debugs to check what is happening now and then send you v2.


--
Regards
Sudip

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ