summaryrefslogtreecommitdiffstats
path: root/drivers/usb/usbip/vhci_hcd.c
diff options
context:
space:
mode:
authorShuah Khan <skhan@linuxfoundation.org>2021-03-29 19:36:48 -0600
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2021-04-05 09:05:42 +0200
commit4e9c93af7279b059faf5bb1897ee90512b258a12 (patch)
tree646050e3ffb7e9bec9c7077c382be1ce56fa027f /drivers/usb/usbip/vhci_hcd.c
parent3004fcba01b4adb3d2ff48c7eead8763fb837556 (diff)
downloadlinux-4e9c93af7279b059faf5bb1897ee90512b258a12.tar.bz2
usbip: add sysfs_lock to synchronize sysfs code paths
Fuzzing uncovered race condition between sysfs code paths in usbip drivers. Device connect/disconnect code paths initiated through sysfs interface are prone to races if disconnect happens during connect and vice versa. This problem is common to all drivers while it can be reproduced easily in vhci_hcd. Add a sysfs_lock to usbip_device struct to protect the paths. Use this in vhci_hcd to protect sysfs paths. For a complete fix, usip_host and usip-vudc drivers and the event handler will have to use this lock to protect the paths. These changes will be done in subsequent patches. Cc: stable@vger.kernel.org Reported-and-tested-by: syzbot+a93fba6d384346a761e3@syzkaller.appspotmail.com Signed-off-by: Shuah Khan <skhan@linuxfoundation.org> Link: https://lore.kernel.org/r/b6568f7beae702bbc236a545d3c020106ca75eac.1616807117.git.skhan@linuxfoundation.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/usb/usbip/vhci_hcd.c')
-rw-r--r--drivers/usb/usbip/vhci_hcd.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/drivers/usb/usbip/vhci_hcd.c b/drivers/usb/usbip/vhci_hcd.c
index a20a8380ca0c..4ba6bcdaa8e9 100644
--- a/drivers/usb/usbip/vhci_hcd.c
+++ b/drivers/usb/usbip/vhci_hcd.c
@@ -1101,6 +1101,7 @@ static void vhci_device_init(struct vhci_device *vdev)
vdev->ud.side = USBIP_VHCI;
vdev->ud.status = VDEV_ST_NULL;
spin_lock_init(&vdev->ud.lock);
+ mutex_init(&vdev->ud.sysfs_lock);
INIT_LIST_HEAD(&vdev->priv_rx);
INIT_LIST_HEAD(&vdev->priv_tx);