All of lore.kernel.org
 help / color / mirror / Atom feed
From: Maoyi Xie <maoyixie.tju@gmail.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: linux-usb@vger.kernel.org, Christoph Jung <jung@codemercs.com>
Subject: [PATCH] USB: iowarrior: ignore short reports
Date: Sat, 28 Nov 2026 16:43:55 +0800	[thread overview]
Message-ID: <20261128084355.721820-1-maoyixie.tju@gmail.com> (raw)

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


             reply	other threads:[~2026-11-28  8:44 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-28  8:43 Maoyi Xie [this message]
2026-11-28  8:46 ` [PATCH] USB: iowarrior: ignore short reports sashiko-bot
2026-11-29 13:54 ` Greg Kroah-Hartman
2026-11-30 11:15   ` Maoyi Xie

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261128084355.721820-1-maoyixie.tju@gmail.com \
    --to=maoyixie.tju@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=jung@codemercs.com \
    --cc=linux-usb@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.