* [PATCH] usb-storage: option_ms: bound probe-time bulk transfers
@ 2026-10-13 13:20 Lee Yongjun
2026-10-13 13:27 ` sashiko-bot
2026-10-13 16:18 ` Greg KH
0 siblings, 2 replies; 3+ messages in thread
From: Lee Yongjun @ 2026-10-13 13:20 UTC (permalink / raw)
To: stern, gregkh
Cc: digidietze, xiehongyu1, linux-usb, usb-storage, linux-kernel,
syzkaller-bugs, syzbot+7317196294d50d6e55c3, Lee Yongjun
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@gmail.com/
Fixes: 32ebbe7b6ad4 ("USB: usb-storage: add filter to "option_ms" to leave unrecognized devices alone")
Reported-by: syzbot+7317196294d50d6e55c3@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=7317196294d50d6e55c3
Assisted-by: LLM
Signed-off-by: Lee Yongjun <jun85566@gmail.com>
---
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
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH] usb-storage: option_ms: bound probe-time bulk transfers
2026-10-13 13:20 [PATCH] usb-storage: option_ms: bound probe-time bulk transfers Lee Yongjun
@ 2026-10-13 13:27 ` sashiko-bot
2026-10-13 16:18 ` Greg KH
1 sibling, 0 replies; 3+ messages in thread
From: sashiko-bot @ 2026-10-13 13:27 UTC (permalink / raw)
To: Lee Yongjun; +Cc: linux-usb
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] usb-storage: build failure due to missing usb_stor_bulk_transfer_buf_timeout() dependency
--
commit 3551a3904408bdea1ed0fe7ef3aadc1aebde4e98
Author: Lee Yongjun <jun85566@gmail.com>
usb-storage: option_ms: bound probe-time bulk transfers
This commit replaces bulk transfers in the option_ms initialization path with
timeout-aware equivalents to prevent the USB hub worker from hanging
indefinitely if a device stops responding. A 30-second timeout is introduced
for transfers in option_inquiry() and option_rezero().
Link: https://lore.kernel.org/r/20261001123135.38831-1-xy521521@gmail.com/
Link: https://syzkaller.appspot.com/bug?extid=7317196294d50d6e55c3
> diff --git a/drivers/usb/storage/option_ms.c b/drivers/usb/storage/option_ms.c
> index 7c0b05a365543..1f3d984d69326 100644
> --- a/drivers/usb/storage/option_ms.c
> +++ b/drivers/usb/storage/option_ms.c
[ ... ]
> @@ -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);
[Severity: High]
Does this cause a build failure? The new helper function
usb_stor_bulk_transfer_buf_timeout() does not appear to be defined or
declared anywhere in the current tree.
The commit message notes a dependency on a pending v3 series, but without
that series applied, compiling drivers/usb/storage/option_ms.c results in
an implicit function declaration and subsequent linker failure when the
usb-storage driver is enabled.
Should this patch be held back from the tree until its dependencies are
merged?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261013132033.4352-1-jun85566@gmail.com?part=1
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] usb-storage: option_ms: bound probe-time bulk transfers
2026-10-13 13:20 [PATCH] usb-storage: option_ms: bound probe-time bulk transfers Lee Yongjun
2026-10-13 13:27 ` sashiko-bot
@ 2026-10-13 16:18 ` Greg KH
1 sibling, 0 replies; 3+ messages in thread
From: Greg KH @ 2026-10-13 16:18 UTC (permalink / raw)
To: Lee Yongjun
Cc: stern, digidietze, xiehongyu1, linux-usb, usb-storage,
linux-kernel, syzkaller-bugs, syzbot+7317196294d50d6e55c3
On Tue, Oct 13, 2026 at 10:20:33PM +0900, Lee Yongjun wrote:
> 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.
So a broken device?
> 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.
That feels very long, are you sure that works well?
> 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@gmail.com/
This should go below the --- line and is why sashiko is confused.
> Fixes: 32ebbe7b6ad4 ("USB: usb-storage: add filter to "option_ms" to leave unrecognized devices alone")
> Reported-by: syzbot+7317196294d50d6e55c3@syzkaller.appspotmail.com
> Closes: https://syzkaller.appspot.com/bug?extid=7317196294d50d6e55c3
> Assisted-by: LLM
>
> Signed-off-by: Lee Yongjun <jun85566@gmail.com>
No blank line above here is needed.
thanks,
greg k-h
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-10-13 16:18 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-13 13:20 [PATCH] usb-storage: option_ms: bound probe-time bulk transfers Lee Yongjun
2026-10-13 13:27 ` sashiko-bot
2026-10-13 16:18 ` Greg KH
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.