summaryrefslogtreecommitdiffstats
path: root/tools/usb
diff options
context:
space:
mode:
authorShuah Khan <shuahkh@osg.samsung.com>2018-01-17 12:07:30 -0700
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2018-02-03 17:05:42 +0100
commit4c6fcc3425e19d1f63fd5a7f4f4408ce8f688a48 (patch)
treec53a809ec4ae345f10a52f7857f75e0cb45d99d7 /tools/usb
parentec719c52af164f2eaff0e5bff3b6074ded70c9bf (diff)
downloadlinux-stable-4c6fcc3425e19d1f63fd5a7f4f4408ce8f688a48.tar.gz
linux-stable-4c6fcc3425e19d1f63fd5a7f4f4408ce8f688a48.tar.bz2
linux-stable-4c6fcc3425e19d1f63fd5a7f4f4408ce8f688a48.zip
usbip: prevent bind loops on devices attached to vhci_hcd
commit ef54cf0c600fb8f5737fb001a9e357edda1a1de8 upstream. usbip host binds to devices attached to vhci_hcd on the same server when user does attach over localhost or specifies the server as the remote. usbip attach -r localhost -b busid or usbip attach -r servername (or server IP) Unbind followed by bind works, however device is left in a bad state with accesses via the attached busid result in errors and system hangs during shutdown. Fix it to check and bail out if the device is already attached to vhci_hcd. Signed-off-by: Shuah Khan <shuahkh@osg.samsung.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'tools/usb')
-rw-r--r--tools/usb/usbip/src/usbip_bind.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/tools/usb/usbip/src/usbip_bind.c b/tools/usb/usbip/src/usbip_bind.c
index fa46141ae68b..e121cfb1746a 100644
--- a/tools/usb/usbip/src/usbip_bind.c
+++ b/tools/usb/usbip/src/usbip_bind.c
@@ -144,6 +144,7 @@ static int bind_device(char *busid)
int rc;
struct udev *udev;
struct udev_device *dev;
+ const char *devpath;
/* Check whether the device with this bus ID exists. */
udev = udev_new();
@@ -152,8 +153,16 @@ static int bind_device(char *busid)
err("device with the specified bus ID does not exist");
return -1;
}
+ devpath = udev_device_get_devpath(dev);
udev_unref(udev);
+ /* If the device is already attached to vhci_hcd - bail out */
+ if (strstr(devpath, USBIP_VHCI_DRV_NAME)) {
+ err("bind loop detected: device: %s is attached to %s\n",
+ devpath, USBIP_VHCI_DRV_NAME);
+ return -1;
+ }
+
rc = unbind_other(busid);
if (rc == UNBIND_ST_FAILED) {
err("could not unbind driver from device on busid %s", busid);