Linux USB
 help / color / mirror / Atom feed
* [PATCH] USB: iowarrior: ignore short reports
@ 2026-11-28  8:43 Maoyi Xie
  2026-11-28  8:46 ` sashiko-bot
  0 siblings, 1 reply; 2+ messages in thread
From: Maoyi Xie @ 2026-11-28  8:43 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: linux-usb, Christoph Jung

iowarrior_callback() copies report_size bytes of the interrupt-in
buffer into the read queue. It never looks at urb->actual_length. After
a short report the bytes past actual_length are stale or uninitialized.
iowarrior_read() copies them to user space.

The vendor's datasheets describe only reports of a fixed length. Ignore
a report shorter than report_size.

Found with a CodeQL-based static analysis tool that we are developing.
Reproduced in a userspace harness and with an emulated device on
dummy_hcd. Not tested on hardware.

Fixes: 946b960d13c1 ("USB: add driver for iowarrior devices.")
Cc: stable@vger.kernel.org
Signed-off-by: Maoyi Xie <maoyixie.tju@gmail.com>
---
I used an LLM to help write the harness, the device emulation and this
patch.

 drivers/usb/misc/iowarrior.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/usb/misc/iowarrior.c b/drivers/usb/misc/iowarrior.c
index de2b236ef903..8d2d01df8d5f 100644
--- a/drivers/usb/misc/iowarrior.c
+++ b/drivers/usb/misc/iowarrior.c
@@ -170,6 +170,9 @@ static void iowarrior_callback(struct urb *urb)
 		goto exit;
 	}
 
+	if (urb->actual_length < dev->report_size)
+		goto exit;
+
 	intr_idx = atomic_read(&dev->intr_idx);
 	/* aux_idx become previous intr_idx */
 	aux_idx = (intr_idx == 0) ? (MAX_INTERRUPT_BUFFER - 1) : (intr_idx - 1);
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] USB: iowarrior: ignore short reports
  2026-11-28  8:43 [PATCH] USB: iowarrior: ignore short reports Maoyi Xie
@ 2026-11-28  8:46 ` sashiko-bot
  0 siblings, 0 replies; 2+ messages in thread
From: sashiko-bot @ 2026-11-28  8:46 UTC (permalink / raw)
  To: Maoyi Xie; +Cc: linux-usb

> iowarrior_callback() copies report_size bytes of the interrupt-in
> buffer into the read queue. It never looks at urb->actual_length. After
> a short report the bytes past actual_length are stale or uninitialized.
> iowarrior_read() copies them to user space.
> 
> The vendor's datasheets describe only reports of a fixed length. Ignore
> a report shorter than report_size.
> 
> Found with a CodeQL-based static analysis tool that we are developing.
> Reproduced in a userspace harness and with an emulated device on
> dummy_hcd. Not tested on hardware.
> 
> Fixes: 946b960d13c1 ("USB: add driver for iowarrior devices.")
> Cc: stable@vger.kernel.org
> Signed-off-by: Maoyi Xie <maoyixie.tju@gmail.com>

Sashiko has reviewed this patch and found no issues.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261128084355.721820-1-maoyixie.tju@gmail.com?part=1

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-11-28  8:46 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-28  8:43 [PATCH] USB: iowarrior: ignore short reports Maoyi Xie
2026-11-28  8:46 ` sashiko-bot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox