linux/drivers/usb/core
Alan Stern 8963c487a8 USB: fix deadlock in bConfigurationValue attribute method
This patch (as154) fixes a self-deadlock that occurs when userspace
writes to the bConfigurationValue sysfs attribute for a hub with
children.  The task tries to lock the bandwidth_mutex at a time when
it already owns the lock:

	The attribute's method calls usb_set_configuration(),
	which calls usb_disable_device() with the bandwidth_mutex
	held.

	usb_disable_device() unregisters the existing interfaces,
	which causes the hub driver to be unbound.

	The hub_disconnect() routine calls hub_quiesce(), which
	calls usb_disconnect() for each of the hub's children.

	usb_disconnect() attempts to acquire the bandwidth_mutex
	around a call to usb_disable_device().

The solution is to make usb_disable_device() acquire the mutex for
itself instead of requiring the caller to hold it.  Then the mutex can
cover only the bandwidth deallocation operation and not the region
where the interfaces are unregistered.

This has the potential to change system behavior slightly when a
config change races with another config or altsetting change.  Some of
the bandwidth released from the old config might get claimed by the
other config or altsetting, make it impossible to restore the old
config in case of a failure.  But since we don't try to recover from
config-change failures anyway, this doesn't matter.

[This should be marked for stable kernels that contain the commit
fccf4e8620 "USB: Free bandwidth when
usb_disable_device is called."
That commit was marked for stable kernels as old as 2.6.32.]

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Sarah Sharp <sarah.a.sharp@linux.intel.com>
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-04-17 15:54:57 -07:00
..
Kconfig kconfig: rename CONFIG_EMBEDDED to CONFIG_EXPERT 2011-01-20 17:02:05 -08:00
Makefile usb: makefile cleanup 2010-10-22 10:22:07 -07:00
buffer.c USB: Core: Fix minor coding style issues 2011-01-22 19:35:39 -08:00
config.c usbcore: get BOS descriptor set 2011-09-26 15:51:08 -07:00
devices.c USB: use usb_endpoint_maxp() instead of le16_to_cpu() 2011-08-23 09:47:40 -07:00
devio.c module_param: make bool parameters really bool (drivers & misc) 2012-01-13 09:32:20 +10:30
driver.c USB: don't ignore suspend errors for root hubs 2012-04-09 15:36:21 -07:00
endpoint.c USB: use usb_endpoint_maxp() instead of le16_to_cpu() 2011-08-23 09:47:40 -07:00
file.c switch device_get_devnode() and ->devnode() to umode_t * 2012-01-03 22:54:55 -05:00
generic.c USB: accept RNDIS configs if there's no alternative 2010-08-10 14:35:43 -07:00
hcd-pci.c usb: fix defined but not used warnings in hcd-pci.c 2012-02-28 10:53:08 -08:00
hcd.c USB: fix race between root-hub suspend and remote wakeup 2012-04-09 15:43:21 -07:00
hub.c USB: fix deadlock in bConfigurationValue attribute method 2012-04-17 15:54:57 -07:00
inode.c simple_open: automatically convert to simple_open() 2012-04-05 15:25:50 -07:00
message.c USB: fix deadlock in bConfigurationValue attribute method 2012-04-17 15:54:57 -07:00
notify.c usb: Add export.h for EXPORT_SYMBOL/THIS_MODULE where needed 2011-10-31 19:31:25 -04:00
otg_whitelist.h
quirks.c USB: add quirk for another camera 2012-01-03 16:48:56 -08:00
sysfs.c usb: Add support for indicating whether a port is removable 2012-02-09 08:40:11 -08:00
urb.c USB documentation: explain lifetime rules for unlinking URBs 2012-04-06 13:54:00 -07:00
usb.c USB: cleanup the handling of the PM complete call 2012-01-24 14:23:49 -08:00
usb.h USB: cleanup the handling of the PM complete call 2012-01-24 14:23:49 -08:00