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:	Tue, 4 Nov 2008 09:11:28 -0800
From:	Greg KH <greg@...ah.com>
To:	Alan Cox <alan@...rguk.ukuu.org.uk>
Cc:	linux-usb@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] tty: Fix close races in USB serial

On Tue, Nov 04, 2008 at 03:29:24PM +0000, Alan Cox wrote:
> From: Alan Cox <alan@...hat.com>
> 
> USB serial has always had races where the tty port usage count can hit zero
> during a receive event. The internal locking is a mutex so we can't use
> that in the IRQ handlers.
> 
> With krefs we can tackle this differently but we still need to be careful.
> 
> Signed-off-by: Alan Cox <alan@...hat.com>
> ---
> 
>  drivers/usb/serial/usb-serial.c |   15 ++++++++++-----
>  1 files changed, 10 insertions(+), 5 deletions(-)
> 
> 
> diff --git a/drivers/usb/serial/usb-serial.c b/drivers/usb/serial/usb-serial.c
> index 794b5ff..aafa684 100644
> --- a/drivers/usb/serial/usb-serial.c
> +++ b/drivers/usb/serial/usb-serial.c
> @@ -269,15 +269,19 @@ static void serial_close(struct tty_struct *tty, struct file *filp)
>  		return;
>  	}
>  
> -	--port->port.count;
> -	if (port->port.count == 0)
> +	if (port->port.count == 1)
>  		/* only call the device specific close if this
> -		 * port is being closed by the last owner */
> +		 * port is being closed by the last owner. Ensure we do
> +		 * this before we drop the port count. The call is protected
> +		 * by the port mutex
> +		 */
>  		port->serial->type->close(tty, port, filp);
>  
> -	if (port->port.count == (port->console? 1 : 0)) {
> +	if (port->port.count == (port->console ? 2 : 1)) {

Why are you testing for 2 here?

confused,

greg k-h
--
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