From: "eritque-arcus@ikuyo.dev" <eritque-arcus@ikuyo.dev>
To: Frank Jungclaus <frank.jungclaus@esd.eu>,
socketcan@esd.eu, Marc Kleine-Budde <mkl@pengutronix.de>,
Vincent Mailhol <mailhol@kernel.org>
Cc: linux-can@vger.kernel.org, linux-kernel@vger.kernel.org,
stable@vger.kernel.org, blbllhy@gmail.com
Subject: Re: [PATCH 2/2] can: kvaser_usb_hydra: reject too-short commands in the receive path
Date: Wed, 16 Sep 2026 14:18:44 -0400 [thread overview]
Message-ID: <050b2eb3-3435-4180-935d-c03f3972e11c@ikuyo.dev> (raw)
In-Reply-To: <20260815-can-esd-hydra-fixes-v1-2-de644cbeaec2@ikuyo.dev>
Hi Marc, Vincent,
Please drop patch 2/2 (kvaser_usb_hydra) from this series. Cen Zhang has
since posted a standalone fix for the same hydra receive path that is
more complete than mine.
<https://lore.kernel.org/linux-can/20260819145658.29872-1-blbllhy@gmail.com/>
Patch 1/2 (esd_usb) is independent so please consider it on its own.
One note on the automated review of patch 1/2: the issues it raised are
all in esd_usb's probe and tx-done paths. I've kept this fix narrow
rather than widen it into those, and will look at them separately.
Thanks,
Yiran
On 8/14/26 2:05 PM, Yiran Qiu wrote:
> kvaser_usb_hydra_read_bulk_callback() walks commands out of the RX URB
> buffer, using kvaser_usb_hydra_cmd_size() to determine each command's
> length. For an extended command (CMD_EXTENDED) that size is taken
> directly from the device-supplied 16-bit length field with no lower
> bound. A CMD_EXTENDED command whose length is zero makes cmd_size 0, so
> "pos += cmd_len" never advances and this URB-completion softirq spins
> forever.
>
> Reject a command whose reported size is smaller than the command header
> before it is dispatched, mirroring the minimum-length check added in
> commit 0293dd153f9d ("can: kvaser_usb_leaf: kvaser_usb_leaf_wait_cmd():
> validate received command extents"); that fix did not touch hydra's
> asynchronous read_bulk_callback().
>
> Reproduced with USB_RAW_GADGET + dummy_hcd on a KASAN build: after the
> normal probe/START_CHIP handshake, a 6-byte CMD_EXTENDED frame with the
> length field set to 0 makes the callback loop print
>
> kvaser_usb 1-1:1.0: Unhandled extended command (255)
>
> without bound (306000 times in ~75 s), until
>
> rcu: INFO: rcu_sched detected stalls on CPUs/tasks:
>
> and the machine had to be killed externally.
>
> Fixes: aec5fb2268b5 ("can: kvaser_usb: Add support for Kvaser USB hydra family")
> Cc: stable@vger.kernel.org
> Signed-off-by: Yiran Qiu <eritque-arcus@ikuyo.dev>
> ---
> drivers/net/can/usb/kvaser_usb/kvaser_usb_hydra.c | 9 +++++++++
> 1 file changed, 9 insertions(+)
>
> diff --git a/drivers/net/can/usb/kvaser_usb/kvaser_usb_hydra.c b/drivers/net/can/usb/kvaser_usb/kvaser_usb_hydra.c
> index efbb7bed34c9d..d44f9875fbe2f 100644
> --- a/drivers/net/can/usb/kvaser_usb/kvaser_usb_hydra.c
> +++ b/drivers/net/can/usb/kvaser_usb/kvaser_usb_hydra.c
> @@ -2156,6 +2156,15 @@ static void kvaser_usb_hydra_read_bulk_callback(struct kvaser_usb *dev,
>
> cmd_len = kvaser_usb_hydra_cmd_size(cmd);
>
> + /* An extended command carries a device-supplied length; a
> + * command shorter than the command header would never advance
> + * @pos and would spin this URB-completion softirq forever.
> + */
> + if (cmd_len < sizeof(struct kvaser_cmd_header)) {
> + dev_err(&dev->intf->dev, "Format error\n");
> + break;
> + }
> +
> if (pos + cmd_len > len) {
> /* We got first part of a command */
> int leftover_bytes;
>
prev parent reply other threads:[~2026-09-16 18:19 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-14 18:05 [PATCH 0/2] can: fix two missed siblings of the kvaser_usb_leaf receive-walk fix Yiran Qiu
2026-08-14 18:05 ` [PATCH 1/2] can: esd_usb: validate received message length before use Yiran Qiu
2026-08-14 18:05 ` [PATCH 2/2] can: kvaser_usb_hydra: reject too-short commands in the receive path Yiran Qiu
2026-09-16 18:18 ` eritque-arcus [this message]
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=050b2eb3-3435-4180-935d-c03f3972e11c@ikuyo.dev \
--to=eritque-arcus@ikuyo.dev \
--cc=blbllhy@gmail.com \
--cc=frank.jungclaus@esd.eu \
--cc=linux-can@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mailhol@kernel.org \
--cc=mkl@pengutronix.de \
--cc=socketcan@esd.eu \
--cc=stable@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®