kernel-ark/drivers/usb/core
Alan Stern 4a2a8a2cce usbfs: private mutex for open, release, and remove
The usbfs code doesn't provide sufficient mutual exclusion among open,
release, and remove.  Release vs. remove is okay because they both
acquire the device lock, but open is not exclusive with either one.  All
three routines modify the udev->filelist linked list, so they must not
run concurrently.

Apparently someone gave this a minimum amount of thought in the past by
explicitly acquiring the BKL at the start of the usbdev_open routine.
Oddly enough, there's a comment pointing out that locking is unnecessary
because chrdev_open already has acquired the BKL.

But this ignores the point that the files in /proc/bus/usb/* are not
char device files; they are regular files and so they don't get any
special locking.  Furthermore it's necessary to acquire the same lock in
the release and remove routines, which the code does not do.

Yet another problem arises because the same file_operations structure is
accessible through both the /proc/bus/usb/* and /dev/usb/usbdev* file
nodes.  Even when one of them has been removed, it's still possible for
userspace to open the other.  So simple locking around the individual
remove routines is insufficient; we need to lock the entire
usb_notify_remove_device notifier chain.

Rather than rely on the BKL, this patch (as723) introduces a new private
mutex for the purpose.  Holding the BKL while invoking a notifier chain
doesn't seem like a good idea.


Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2006-09-27 11:58:49 -07:00
..
buffer.c Remove obsolete #include <linux/config.h> 2006-06-30 19:25:36 +02:00
config.c Remove obsolete #include <linux/config.h> 2006-06-30 19:25:36 +02:00
devices.c
devio.c usbfs: private mutex for open, release, and remove 2006-09-27 11:58:49 -07:00
driver.c Remove obsolete #include <linux/config.h> 2006-06-30 19:25:36 +02:00
endpoint.c [PATCH] USB: make endpoints real struct devices 2006-06-21 15:04:19 -07:00
file.c Revert "[PATCH] USB: convert usb class devices to real devices" 2006-08-02 16:49:37 -07:00
hcd-pci.c PM: USB HCDs use PM_EVENT_PRETHAW 2006-09-25 21:08:37 -07:00
hcd.c Remove obsolete #include <linux/config.h> 2006-06-30 19:25:36 +02:00
hcd.h [PATCH] USB: remove usbcore-specific wakeup flags 2006-03-20 14:49:56 -08:00
hub.c [PATCH] usbcore: fixes for hub_port_resume 2006-07-12 16:03:22 -07:00
hub.h
inode.c [PATCH] inode-diet: Eliminate i_blksize from the inode structure 2006-09-27 08:26:18 -07:00
Kconfig [PATCH] USB: remove devfs information from Kconfig 2006-07-12 16:03:23 -07:00
Makefile [PATCH] USB: move the endpoint specific sysfs code to it's own file 2006-06-21 15:04:18 -07:00
message.c Remove obsolete #include <linux/config.h> 2006-06-30 19:25:36 +02:00
notify.c usbfs: private mutex for open, release, and remove 2006-09-27 11:58:49 -07:00
otg_whitelist.h
sysfs.c usbcore: add configuration_string to attribute group 2006-09-27 11:58:49 -07:00
urb.c Remove obsolete #include <linux/config.h> 2006-06-30 19:25:36 +02:00
usb.c USB: Make usb_buffer_free() NULL-safe 2006-09-27 11:58:49 -07:00
usb.h usbfs: private mutex for open, release, and remove 2006-09-27 11:58:49 -07:00