Skip to content

Commit 363eaa3

Browse files
shuahkhgregkh
authored andcommitted
usbip: synchronize event handler with 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. Use sysfs_lock to synchronize event handler with sysfs paths in usbip drivers. Cc: [email protected] Reported-and-tested-by: [email protected] Signed-off-by: Shuah Khan <[email protected]> Link: https://lore.kernel.org/r/c5c8723d3f29dfe3d759cfaafa7dd16b0dfe2918.1616807117.git.skhan@linuxfoundation.org Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent bd8b820 commit 363eaa3

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

drivers/usb/usbip/usbip_event.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ static void event_handler(struct work_struct *work)
7070
while ((ud = get_event()) != NULL) {
7171
usbip_dbg_eh("pending event %lx\n", ud->event);
7272

73+
mutex_lock(&ud->sysfs_lock);
7374
/*
7475
* NOTE: shutdown must come first.
7576
* Shutdown the device.
@@ -90,6 +91,7 @@ static void event_handler(struct work_struct *work)
9091
ud->eh_ops.unusable(ud);
9192
unset_event(ud, USBIP_EH_UNUSABLE);
9293
}
94+
mutex_unlock(&ud->sysfs_lock);
9395

9496
wake_up(&ud->eh_waitq);
9597
}

0 commit comments

Comments
 (0)