linux_dsm_epyc7002/drivers/net/wireless
Alan Stern 6e41e2257f p54usb: Fix race between disconnect and firmware loading
The syzbot fuzzer found a bug in the p54 USB wireless driver.  The
issue involves a race between disconnect and the firmware-loader
callback routine, and it has several aspects.

One big problem is that when the firmware can't be loaded, the
callback routine tries to unbind the driver from the USB _device_ (by
calling device_release_driver) instead of from the USB _interface_ to
which it is actually bound (by calling usb_driver_release_interface).

The race involves access to the private data structure.  The driver's
disconnect handler waits for a completion that is signalled by the
firmware-loader callback routine.  As soon as the completion is
signalled, you have to assume that the private data structure may have
been deallocated by the disconnect handler -- even if the firmware was
loaded without errors.  However, the callback routine does access the
private data several times after that point.

Another problem is that, in order to ensure that the USB device
structure hasn't been freed when the callback routine runs, the driver
takes a reference to it.  This isn't good enough any more, because now
that the callback routine calls usb_driver_release_interface, it has
to ensure that the interface structure hasn't been freed.

Finally, the driver takes an unnecessary reference to the USB device
structure in the probe function and drops the reference in the
disconnect handler.  This extra reference doesn't accomplish anything,
because the USB core already guarantees that a device structure won't
be deallocated while a driver is still bound to any of its interfaces.

To fix these problems, this patch makes the following changes:

	Call usb_driver_release_interface() rather than
	device_release_driver().

	Don't signal the completion until after the important
	information has been copied out of the private data structure,
	and don't refer to the private data at all thereafter.

	Lock udev (the interface's parent) before unbinding the driver
	instead of locking udev->parent.

	During the firmware loading process, take a reference to the
	USB interface instead of the USB device.

	Don't take an unnecessary reference to the device during probe
	(and then don't drop it during disconnect).

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Reported-and-tested-by: syzbot+200d4bb11b23d929335f@syzkaller.appspotmail.com
CC: <stable@vger.kernel.org>
Acked-by: Christian Lamparter <chunkeey@gmail.com>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
2019-06-25 07:40:27 +03:00
..
admtek treewide: Add SPDX license identifier - Makefile/Kconfig 2019-05-21 10:50:46 +02:00
ath Merge ath-next from git://git.kernel.org/pub/scm/linux/kernel/git/kvalo/ath.git 2019-05-27 15:15:29 +03:00
atmel treewide: Add SPDX license identifier - Makefile/Kconfig 2019-05-21 10:50:46 +02:00
broadcom b43: Avoid possible double calls to b43_one_core_detach() 2019-05-28 15:43:34 +03:00
cisco treewide: Add SPDX license identifier - Makefile/Kconfig 2019-05-21 10:50:46 +02:00
intel treewide: Add SPDX license identifier - Makefile/Kconfig 2019-05-21 10:50:46 +02:00
intersil p54usb: Fix race between disconnect and firmware loading 2019-06-25 07:40:27 +03:00
marvell libertas: fix spelling mistake "Donwloading" -> "Downloading" 2019-05-28 15:42:43 +03:00
mediatek treewide: Add SPDX license identifier - Makefile/Kconfig 2019-05-21 10:50:46 +02:00
quantenna treewide: Add SPDX license identifier - Makefile/Kconfig 2019-05-21 10:50:46 +02:00
ralink treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 13 2019-05-21 11:28:45 +02:00
realtek rtlwifi: btcoex: remove unused function exhalbtc_stack_operation_notify 2019-05-28 15:38:02 +03:00
rsi treewide: Add SPDX license identifier - Makefile/Kconfig 2019-05-21 10:50:46 +02:00
st treewide: Add SPDX license identifier - Makefile/Kconfig 2019-05-21 10:50:46 +02:00
ti treewide: Add SPDX license identifier - Makefile/Kconfig 2019-05-21 10:50:46 +02:00
zydas treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 13 2019-05-21 11:28:45 +02:00
Kconfig treewide: Add SPDX license identifier - Makefile/Kconfig 2019-05-21 10:50:46 +02:00
mac80211_hwsim.c Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next 2019-05-07 22:03:58 -07:00
mac80211_hwsim.h mac80211_hwsim: allow configurable cipher types 2018-11-09 11:36:15 +01:00
Makefile mac80211-next: rtnetlink wifi simulation device 2018-12-05 15:31:31 +01:00
ray_cs.c ray_cs: use remove_proc_subtree to simplify procfs code 2019-04-25 19:38:52 +03:00
ray_cs.h
rayctl.h
rndis_wlan.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 13 2019-05-21 11:28:45 +02:00
virt_wifi.c virt_wifi: Remove REGULATORY_WIPHY_SELF_MANAGED 2019-02-11 17:10:48 +01:00
wl3501_cs.c treewide: Add SPDX license identifier for more missed files 2019-05-21 10:50:45 +02:00
wl3501.h