* [PATCH v2] USB: iowarrior: use kzalloc() for the interrupt-in buffer
@ 2026-11-30 11:32 Maoyi Xie
2026-11-30 11:35 ` sashiko-bot
0 siblings, 1 reply; 2+ messages in thread
From: Maoyi Xie @ 2026-11-30 11:32 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. The
buffer comes from kmalloc(). After a short report the bytes past
actual_length can be uninitialized. iowarrior_read() copies them to
user space.
Allocate the buffer with kzalloc(). A short report is passed on as
before. It can still carry bytes of an earlier report.
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.")
Suggested-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
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.
v2: Keep short reports and allocate the buffer with kzalloc() (Greg).
v1: https://lore.kernel.org/all/20261128084355.721820-1-maoyixie.tju@gmail.com/
drivers/usb/misc/iowarrior.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/usb/misc/iowarrior.c b/drivers/usb/misc/iowarrior.c
index de2b236ef903..53e0e68682b6 100644
--- a/drivers/usb/misc/iowarrior.c
+++ b/drivers/usb/misc/iowarrior.c
@@ -829,7 +829,7 @@ static int iowarrior_probe(struct usb_interface *interface,
dev->int_in_urb = usb_alloc_urb(0, GFP_KERNEL);
if (!dev->int_in_urb)
goto error;
- dev->int_in_buffer = kmalloc(dev->report_size, GFP_KERNEL);
+ dev->int_in_buffer = kzalloc(dev->report_size, GFP_KERNEL);
if (!dev->int_in_buffer)
goto error;
usb_fill_int_urb(dev->int_in_urb, dev->udev,
--
2.34.1
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH v2] USB: iowarrior: use kzalloc() for the interrupt-in buffer
2026-11-30 11:32 [PATCH v2] USB: iowarrior: use kzalloc() for the interrupt-in buffer Maoyi Xie
@ 2026-11-30 11:35 ` sashiko-bot
0 siblings, 0 replies; 2+ messages in thread
From: sashiko-bot @ 2026-11-30 11:35 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. The
> buffer comes from kmalloc(). After a short report the bytes past
> actual_length can be uninitialized. iowarrior_read() copies them to
> user space.
>
> Allocate the buffer with kzalloc(). A short report is passed on as
> before. It can still carry bytes of an earlier report.
>
> 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.")
> Suggested-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> 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/20261130113237.2371847-1-maoyixie.tju@gmail.com?part=1
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-11-30 11:35 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-30 11:32 [PATCH v2] USB: iowarrior: use kzalloc() for the interrupt-in buffer Maoyi Xie
2026-11-30 11:35 ` sashiko-bot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox