]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commit
usbip: usbip_host: fix bad unlock balance during stub_probe()
authorShuah Khan (Samsung OSG) <shuah@kernel.org>
Tue, 15 May 2018 23:57:23 +0000 (17:57 -0600)
committerStefan Bader <stefan.bader@canonical.com>
Tue, 14 Aug 2018 10:27:09 +0000 (12:27 +0200)
commit92909219c6c5231cc51508793b2b86d390e7aae7
tree6ceb4c63a161fca974bdc325c18c5a058cc78f96
parente19e3e06644477245e6957f74099a7d3fc2a9415
usbip: usbip_host: fix bad unlock balance during stub_probe()

BugLink: http://bugs.launchpad.net/bugs/1782846
commit c171654caa875919be3c533d3518da8be5be966e 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: 22076557b07c ("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>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
drivers/usb/usbip/stub_main.c