android_kernel_sony_sdm845/Documentation/usb
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Alan Stern 3c65c7660b USB: core: Fix bug caused by duplicate interface PM usage counter
commit c2b71462d294cf517a0bc6e4fd6424d7cee5596f upstream.

The syzkaller fuzzer reported a bug in the USB hub driver which turned
out to be caused by a negative runtime-PM usage counter.  This allowed
a hub to be runtime suspended at a time when the driver did not expect
it.  The symptom is a WARNING issued because the hub's status URB is
submitted while it is already active:

	URB 0000000031fb463e submitted while active
	WARNING: CPU: 0 PID: 2917 at drivers/usb/core/urb.c:363

The negative runtime-PM usage count was caused by an unfortunate
design decision made when runtime PM was first implemented for USB.
At that time, USB class drivers were allowed to unbind from their
interfaces without balancing the usage counter (i.e., leaving it with
a positive count).  The core code would take care of setting the
counter back to 0 before allowing another driver to bind to the
interface.

Later on when runtime PM was implemented for the entire kernel, the
opposite decision was made: Drivers were required to balance their
runtime-PM get and put calls.  In order to maintain backward
compatibility, however, the USB subsystem adapted to the new
implementation by keeping an independent usage counter for each
interface and using it to automatically adjust the normal usage
counter back to 0 whenever a driver was unbound.

This approach involves duplicating information, but what is worse, it
doesn't work properly in cases where a USB class driver delays
decrementing the usage counter until after the driver's disconnect()
routine has returned and the counter has been adjusted back to 0.
Doing so would cause the usage counter to become negative.  There's
even a warning about this in the USB power management documentation!

As it happens, this is exactly what the hub driver does.  The
kick_hub_wq() routine increments the runtime-PM usage counter, and the
corresponding decrement is carried out by hub_event() in the context
of the hub_wq work-queue thread.  This work routine may sometimes run
after the driver has been unbound from its interface, and when it does
it causes the usage counter to go negative.

It is not possible for hub_disconnect() to wait for a pending
hub_event() call to finish, because hub_disconnect() is called with
the device lock held and hub_event() acquires that lock.  The only
feasible fix is to reverse the original design decision: remove the
duplicate interface-specific usage counter and require USB drivers to
balance their runtime PM gets and puts.  As far as I know, all
existing drivers currently do this.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Reported-and-tested-by: syzbot+7634edaea4d0b341c625@syzkaller.appspotmail.com
CC: <stable@vger.kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-05-08 07:19:08 +02:00
..
acm.txt
anchors.txt
authorization.txt usb: interface authorization: Documentation part 2015-09-22 12:08:40 -07:00
bulk-streams.txt
callbacks.txt
chipidea.txt doc: usb: chipidea: update the doc for OTG FSM 2016-05-04 13:40:31 +08:00
CREDITS
dma.txt
dwc3.txt doc: fix a few typos 2012-04-05 17:02:52 -07:00
ehci.txt
error-codes.txt USB: report submission of active URBs 2012-11-11 18:10:46 -08:00
functionfs.txt FunctionFS: enable multiple functions 2012-05-14 09:25:44 -07:00
gadget-testing.txt Documentation: usb: update usb-tools repository address 2015-12-16 10:07:30 -06:00
gadget_configfs.txt gadget_configfs.txt: fix spelling of 'function' 2014-10-29 14:30:15 +01:00
gadget_hid.txt usb: gadget: hid: add configfs support 2014-11-06 16:18:19 -06:00
gadget_multi.txt Documentation: tiny typo fix in usb/gadget_multi.txt 2016-06-23 08:09:10 -06:00
gadget_printer.txt
gadget_serial.txt Documentation: usb: gadget_serial: update generic serial setup instruction 2015-01-12 12:13:24 -06:00
hotplug.txt usb: hub: rename khubd to hub_wq in documentation and comments 2014-09-23 22:33:19 -07:00
iuu_phoenix.txt
linux-cdc-acm.inf
linux.inf
mass-storage.txt doc: spelling error changes 2014-05-05 15:32:05 +02:00
misc_usbsevseg.txt
mtouchusb.txt Documentation: Fix Broken URL "freshmeat" 2012-02-21 11:43:45 +01:00
ohci.txt
persist.txt usb: add decriptor of persist fail for some morph usb devices 2012-08-10 12:06:39 -07:00
power-management.txt USB: core: Fix bug caused by duplicate interface PM usage counter 2019-05-08 07:19:08 +02:00
proc_usb_info.txt proc_usb_info.txt: Correct documentation about endianness of config descriptors 2013-08-12 12:24:27 -07:00
rio.txt
URB.txt USB: URB documentation: claim complete() will be run with IRQs enabled 2013-08-12 11:43:48 -07:00
usb-help.txt
usb-serial.txt Documentation usb serial: fixed how to provide vendor and product id 2015-05-07 09:44:04 -06:00
usbdevfs-drop-permissions.c usb: devio: Add ioctl to disallow detaching kernel USB drivers. 2016-03-05 12:05:01 -08:00
usbip_protocol.txt usbip: move usbip_protocol.txt to Documentation 2016-03-03 19:44:06 -08:00
usbmon.txt doc: usbmon: fix spelling s/unpriviledged/unprivileged/ 2015-01-09 12:25:54 -08:00
wusb-cbaf doc: fix a few typos 2012-04-05 17:02:52 -07:00
WUSB-Design-overview.txt usb: hub: rename khubd to hub_wq in documentation and comments 2014-09-23 22:33:19 -07:00