]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
usbip: add sysfs_lock to synchronize sysfs code paths
authorShuah Khan <skhan@linuxfoundation.org>
Tue, 30 Mar 2021 01:36:48 +0000 (19:36 -0600)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 14 Apr 2021 06:47:14 +0000 (08:47 +0200)
commit32fa3479cd3a034d8d1c431398807f41c2d42bf5
tree4933eda8ed6871906301c1bab07e13420ae3c8e5
parent6547627a1262ee63859c092c4317a5a6f9b84c04
usbip: add sysfs_lock to synchronize sysfs code paths

commit 4e9c93af7279b059faf5bb1897ee90512b258a12 upstream.

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>
drivers/usb/usbip/usbip_common.h
drivers/usb/usbip/vhci_hcd.c
drivers/usb/usbip/vhci_sysfs.c