linux/drivers/usb/usbip
Shuah Khan (Samsung OSG) e842726ecc usbip: usbip_host: fix bad unlock balance during stub_probe()
commit c171654caa upstream.

stub_probe() calls put_busid_priv() in an error path when device isn't
found in the busid_table. Fix it by making put_busid_priv() safe to be
called with null struct bus_id_priv pointer.

This problem happens when "usbip bind" is run without loading usbip_host
driver and then running modprobe. The first failed bind attempt unbinds
the device from the original driver and when usbip_host is modprobed,
stub_probe() runs and doesn't find the device in its busid table and calls
put_busid_priv(0 with null bus_id_priv pointer.

usbip-host 3-10.2: 3-10.2 is not in match_busid table...  skip!

[  367.359679] =====================================
[  367.359681] WARNING: bad unlock balance detected!
[  367.359683] 4.17.0-rc4+ #5 Not tainted
[  367.359685] -------------------------------------
[  367.359688] modprobe/2768 is trying to release lock (
[  367.359689]
==================================================================
[  367.359696] BUG: KASAN: null-ptr-deref in print_unlock_imbalance_bug+0x99/0x110
[  367.359699] Read of size 8 at addr 0000000000000058 by task modprobe/2768

[  367.359705] CPU: 4 PID: 2768 Comm: modprobe Not tainted 4.17.0-rc4+ #5

Fixes: 22076557b0 ("usbip: usbip_host: fix NULL-ptr deref and use-after-free errors") in usb-linus
Signed-off-by: Shuah Khan (Samsung OSG) <shuah@kernel.org>
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
History 2018-05-22 18:53:55 +02:00
..
Kconfig usb: Kconfig: using select for USB_COMMON dependency 2016-09-27 12:20:17 +02:00
Makefile License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
README usbip: move usbip kernel code out of staging 2014-08-25 10:40:06 -07:00
stub.h usbip: usbip_host: fix NULL-ptr deref and use-after-free errors 2018-05-22 18:53:55 +02:00
stub_dev.c usbip: usbip_host: fix NULL-ptr deref and use-after-free errors 2018-05-22 18:53:55 +02:00
stub_main.c usbip: usbip_host: fix bad unlock balance during stub_probe() 2018-05-22 18:53:55 +02:00
stub_rx.c usbip: stub: stop printing kernel pointer addresses in messages 2018-01-02 20:31:14 +01:00
stub_tx.c usbip: stub: stop printing kernel pointer addresses in messages 2018-01-02 20:31:14 +01:00
usbip_common.c usbip: remove kernel addresses from usb device and urb debug msgs 2018-01-17 09:45:26 +01:00
usbip_common.h usbip: vhci_hcd: Fix usb device and sockfd leaks 2018-05-01 12:58:09 -07:00
usbip_event.c usbip: usbip_event: fix to not print kernel pointer address 2018-05-01 12:58:08 -07:00
vhci.h usbip: vhci-hcd: Clean up the code by adding a new macro 2017-06-13 10:51:10 +02:00
vhci_hcd.c usbip: vhci_hcd: check rhport before using in vhci_hub_control() 2018-05-01 12:58:09 -07:00
vhci_rx.c usbip: vhci: stop printing kernel pointer addresses in messages 2018-01-02 20:31:14 +01:00
vhci_sysfs.c usbip: prevent vhci_hcd driver from leaking a socket pointer address 2017-12-20 10:10:19 +01:00
vhci_tx.c usbip: vhci: stop printing kernel pointer addresses in messages 2018-01-02 20:31:14 +01:00
vudc.h usb: usbip: vudc: Rename find_endpoint() to vudc_find_endpoint() 2016-04-28 12:28:08 -07:00
vudc_dev.c usbip: vudc: Refactor init_vudc_hw() to be more obvious 2016-12-05 15:08:45 +01:00
vudc_main.c usbip: vudc: Add VUDC main file 2016-04-26 15:19:50 -07:00
vudc_rx.c usbip: fix vudc_rx: harden CMD_SUBMIT path to handle malicious input 2018-01-17 09:45:26 +01:00
vudc_sysfs.c usbip: vudc: fix null pointer dereference on udc->lock 2018-03-19 08:42:46 +01:00
vudc_transfer.c usbip: vudc: fix: Clear already_seen flag also for ep0 2016-12-05 15:08:45 +01:00
vudc_tx.c usbip: vudc_tx: fix v_send_ret_submit() vulnerability to null xfer buffer 2018-01-17 09:45:26 +01:00

TODO:
	- more discussion about the protocol
	- testing
	- review of the userspace interface
	- document the protocol

Please send patches for this code to Greg Kroah-Hartman <greg@kroah.com>