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: <200912231716.41004.rjw@sisk.pl>
Date:	Wed, 23 Dec 2009 17:16:40 +0100
From:	"Rafael J. Wysocki" <rjw@...k.pl>
To:	Alan Stern <stern@...land.harvard.edu>
Cc:	Greg KH <greg@...ah.com>, linux-usb@...r.kernel.org,
	LKML <linux-kernel@...r.kernel.org>,
	Linus Torvalds <torvalds@...ux-foundation.org>,
	Stefani Seibold <stefani@...bold.net>,
	Andrew Morton <akpm@...ux-foundation.org>
Subject: Re: [Regression, 2.6.33-rc1->current git] NULL pointer in usb_serial_probe() introduced by the recent kfifo changes

On Wednesday 23 December 2009, Alan Stern wrote:
> On Wed, 23 Dec 2009, Rafael J. Wysocki wrote:
> 
> > Hi,
> > 
> > Something like the patch below is necessary to fix a new NULL pointer deref
> > in usb_serial_probe() that appeared after the recent kfifo changes (in short,
> > the kfifo changes modified the semantics of kfifo_alloc() that
> > usb_serial_probe() reiled on).
> > 
> > Thanks,
> > Rafael
> > 
> > ---
> >  drivers/usb/serial/usb-serial.c |   10 +++++++++-
> >  1 file changed, 9 insertions(+), 1 deletion(-)
> > 
> > Index: linux-2.6/drivers/usb/serial/usb-serial.c
> > ===================================================================
> > --- linux-2.6.orig/drivers/usb/serial/usb-serial.c
> > +++ linux-2.6/drivers/usb/serial/usb-serial.c
> > @@ -595,8 +595,10 @@ static void port_release(struct device *
> >  	usb_free_urb(port->write_urb);
> >  	usb_free_urb(port->interrupt_in_urb);
> >  	usb_free_urb(port->interrupt_out_urb);
> > -	if (!IS_ERR(port->write_fifo) && port->write_fifo)
> > +	if (port->write_fifo) {
> >  		kfifo_free(port->write_fifo);
> > +		kfree(port->write_fifo);
> > +	}
> >  	kfree(port->bulk_in_buffer);
> >  	kfree(port->bulk_out_buffer);
> >  	kfree(port->interrupt_in_buffer);
> > @@ -939,6 +941,12 @@ int usb_serial_probe(struct usb_interfac
> >  			dev_err(&interface->dev, "No free urbs available\n");
> >  			goto probe_error;
> >  		}
> > +		port->write_fifo = kzalloc(sizeof(struct kfifo), GFP_KERNEL);
> > +		if (!port->write_fifo) {
> > +			dev_err(&interface->dev,
> > +				"Couldn't allocate write_fifo\n");
> > +			goto probe_error;
> > +		}
> >  		if (kfifo_alloc(port->write_fifo, PAGE_SIZE, GFP_KERNEL))
> >  			goto probe_error;
> >  		buffer_size = le16_to_cpu(endpoint->wMaxPacketSize);
> 
> Although this would mean further changes elsewhere, doesn't it make
> more sense to embed the struct kfifo directly in the usb_serial_port
> structure instead of allocating it dynamically?

I guess it would, but I wanted to avoid making any further changes.

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