[PATCH] usb-storage: option_ms: bound probe-time bulk transfers
From: Lee Yongjun
Date: Tue Oct 13 2026 - 10:24:49 EST
The Option device initialization path issues bulk transfers
without a timeout. If a device does not complete a transfer,
the USB hub worker can remain blocked while holding the device
mutex, causing usb_device_read() to hang.
Use the timeout-aware bulk transfer helper for the transfers
in option_inquiry() and option_rezero(). This bounds the wait
for each probe-time transfer to 30 seconds.
Tested with the syzbot C reproducer under QEMU/KVM. The
patched kernel repeatedly completed USB device initialization
attempts after approximately 30 seconds without triggering
the previously observed hung-task warning.
This patch depends on Hongyu Xie's pending v3 series:
https://lore.kernel.org/r/20261001123135.38831-1-xy521521@xxxxxxxxx/
Fixes: 32ebbe7b6ad4 ("USB: usb-storage: add filter to "option_ms" to leave unrecognized devices alone")
Reported-by: syzbot+7317196294d50d6e55c3@xxxxxxxxxxxxxxxxxxxxxxxxx
Closes: https://syzkaller.appspot.com/bug?extid=7317196294d50d6e55c3
Assisted-by: LLM
Signed-off-by: Lee Yongjun <jun85566@xxxxxxxxx>
---
drivers/usb/storage/option_ms.c | 38 +++++++++++++++++----------------
1 file changed, 20 insertions(+), 18 deletions(-)
diff --git a/drivers/usb/storage/option_ms.c b/drivers/usb/storage/option_ms.c
index 7c0b05a36554..1f3d984d6932 100644
--- a/drivers/usb/storage/option_ms.c
+++ b/drivers/usb/storage/option_ms.c
@@ -10,6 +10,7 @@
#include <linux/usb.h>
#include <linux/slab.h>
#include <linux/module.h>
+#include <linux/jiffies.h>
#include "usb.h"
#include "transport.h"
@@ -18,6 +19,7 @@
#define ZCD_FORCE_MODEM 0x01
#define ZCD_ALLOW_MS 0x02
+#define OPTION_MS_PROBE_TIMEOUT (30 * HZ)
static unsigned int option_zero_cd = ZCD_FORCE_MODEM;
module_param(option_zero_cd, uint, S_IRUGO | S_IWUSR);
@@ -44,9 +46,9 @@ static int option_rezero(struct us_data *us)
return USB_STOR_TRANSPORT_ERROR;
memcpy(buffer, rezero_msg, sizeof(rezero_msg));
- result = usb_stor_bulk_transfer_buf(us,
- us->send_bulk_pipe,
- buffer, sizeof(rezero_msg), NULL);
+ result = usb_stor_bulk_transfer_buf_timeout(us, us->send_bulk_pipe,
+ buffer, sizeof(rezero_msg), NULL,
+ OPTION_MS_PROBE_TIMEOUT);
if (result != USB_STOR_XFER_GOOD) {
result = USB_STOR_XFER_ERROR;
goto out;
@@ -56,14 +58,14 @@ static int option_rezero(struct us_data *us)
* Some of the devices need to be asked for a response, but we don't
* care what that response is.
*/
- usb_stor_bulk_transfer_buf(us,
- us->recv_bulk_pipe,
- buffer, RESPONSE_LEN, NULL);
+ usb_stor_bulk_transfer_buf_timeout(us, us->recv_bulk_pipe,
+ buffer, RESPONSE_LEN, NULL,
+ OPTION_MS_PROBE_TIMEOUT);
/* Read the CSW */
- usb_stor_bulk_transfer_buf(us,
- us->recv_bulk_pipe,
- buffer, 13, NULL);
+ usb_stor_bulk_transfer_buf_timeout(us, us->recv_bulk_pipe,
+ buffer, 13, NULL,
+ OPTION_MS_PROBE_TIMEOUT);
result = USB_STOR_XFER_GOOD;
@@ -90,17 +92,17 @@ static int option_inquiry(struct us_data *us)
return USB_STOR_TRANSPORT_ERROR;
memcpy(buffer, inquiry_msg, sizeof(inquiry_msg));
- result = usb_stor_bulk_transfer_buf(us,
- us->send_bulk_pipe,
- buffer, sizeof(inquiry_msg), NULL);
+ result = usb_stor_bulk_transfer_buf_timeout(us, us->send_bulk_pipe,
+ buffer, sizeof(inquiry_msg), NULL,
+ OPTION_MS_PROBE_TIMEOUT);
if (result != USB_STOR_XFER_GOOD) {
result = USB_STOR_XFER_ERROR;
goto out;
}
- result = usb_stor_bulk_transfer_buf(us,
- us->recv_bulk_pipe,
- buffer, 0x24, NULL);
+ result = usb_stor_bulk_transfer_buf_timeout(us, us->recv_bulk_pipe,
+ buffer, 0x24, NULL,
+ OPTION_MS_PROBE_TIMEOUT);
if (result != USB_STOR_XFER_GOOD) {
result = USB_STOR_XFER_ERROR;
goto out;
@@ -112,9 +114,9 @@ static int option_inquiry(struct us_data *us)
result = memcmp(buffer+8, "ZCOPTION", 8);
/* Read the CSW */
- usb_stor_bulk_transfer_buf(us,
- us->recv_bulk_pipe,
- buffer, 13, NULL);
+ usb_stor_bulk_transfer_buf_timeout(us, us->recv_bulk_pipe,
+ buffer, 13, NULL,
+ OPTION_MS_PROBE_TIMEOUT);
out:
kfree(buffer);
--
2.43.0