LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Alan Cox <alan@lxorguk.ukuu.org.uk>
To: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Cc: torvalds@osdl.org
Subject: BAD PATCH: USB: remove use of the bus rwsem, as it doesn't really protect anything.
Date: Fri, 27 Apr 2007 22:49:32 +0100	[thread overview]
Message-ID: <20070427224932.34a03e2e@the-village.bc.nu> (raw)
In-Reply-To: <200704272059.l3RKxNPS023912@hera.kernel.org>


Unless there is something I'm missing most of these patches seem totally
unsafe.

> --- a/drivers/usb/core/devices.c
> +++ b/drivers/usb/core/devices.c
> @@ -246,7 +246,6 @@ static char *usb_dump_interface_descriptor(char *start, char *end,
>  
>  	if (start > end)
>  		return start;
> -	down_read(&usb_bus_type.subsys.rwsem);
>  	if (iface) {
>  		driver_name = (iface->dev.driver
>  				? iface->dev.driver->name

iface->dev.driver can now become NULL during the evaluation above

> @@ -444,8 +441,6 @@ static int releaseintf(struct dev_state *ps, unsigned int ifnum)
>  	if (ifnum >= 8*sizeof(ps->ifclaimed))
>  		return err;
>  	dev = ps->dev;
> -	/* lock against other changes to driver bindings */
> -	down_write(&usb_bus_type.subsys.rwsem);
>  	intf = usb_ifnum_to_if(dev, ifnum);
>  	if (!intf)
>  		err = -ENOENT;
> @@ -453,7 +448,6 @@ static int releaseintf(struct dev_state *ps, unsigned int ifnum)
>  		usb_driver_release_interface(&usbfs_driver, intf);

Which takes iface->dev.driver to NULL

>  		err = 0;
>  	}
> -	up_write(&usb_bus_type.subsys.rwsem);
>  	return err;
>  }
>  
> @@ -813,7 +807,6 @@ static int proc_getdriver(struct dev_state *ps, void __user *arg)
>  
>  	if (copy_from_user(&gd, arg, sizeof(gd)))
>  		return -EFAULT;
> -	down_read(&usb_bus_type.subsys.rwsem);
>  	intf = usb_ifnum_to_if(ps->dev, gd.interface);
>  	if (!intf || !intf->dev.driver)
>  		ret = -ENODATA;

Ditto ...




       reply	other threads:[~2007-04-27 21:46 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <200704272059.l3RKxNPS023912@hera.kernel.org>
2007-04-27 21:49 ` Alan Cox [this message]
2007-05-02 16:26   ` Greg KH

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20070427224932.34a03e2e@the-village.bc.nu \
    --to=alan@lxorguk.ukuu.org.uk \
    --cc=linux-kernel@vger.kernel.org \
    --cc=torvalds@osdl.org \
    --subject='Re: BAD PATCH: USB: remove use of the bus rwsem, as it doesn'\''t really protect anything.' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).