From: Jimmy Assarsson <extja@kvaser.com>
To: pip-izony <eeodqql09@gmail.com>,
Marc Kleine-Budde <mkl@pengutronix.de>,
Vincent Mailhol <mailhol@kernel.org>
Cc: Kyungtae Kim <Kyungtae.Kim@dartmouth.edu>,
linux-can@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] can: kvaser_usb: leaf: Fix potential infinite loop in command parsers
Date: Sun, 26 Oct 2025 14:26:59 +0100 [thread overview]
Message-ID: <1d960d0d-06ab-4f38-817f-b9a5e949d3c7@kvaser.com> (raw)
In-Reply-To: <20251023162709.348240-1-eeodqql09@gmail.com>
Hi Seungjin,
Thanks for fixing this!
I'll do some testing in the beginning of next week.
Which Kvaser device did you use when you discovered the problem?
Best regards,
jimmy
On 10/23/25 18:27, pip-izony wrote:
> From: Seungjin Bae <eeodqql09@gmail.com>
>
> The `kvaser_usb_leaf_wait_cmd()` and `kvaser_usb_leaf_read_bulk_callback`
> functions contain logic to zero-length commands. These commands are used
> to align data to the USB endpoint's wMaxPacketSize boundary.
>
> The driver attempts to skip these placeholders by aligning the buffer
> position `pos` to the next packet boundary using `round_up()` function.
>
> However, if zero-length command is found exactly on a packet boundary
> (i.e., `pos` is a multiple of wMaxPacketSize, including 0), `round_up`
> function will return the unchanged value of `pos`. This prevents `pos`
> to be increased, causing an infinite loop in the parsing logic.
>
> This patch fixes this in the function by using `pos + 1` instead.
> This ensures that even if `pos` is on a boundary, the calculation is
> based on `pos + 1`, forcing `round_up()` to always return the next
> aligned boundary.
>
> Fixes: 7259124eac7d ("can: kvaser_usb: Split driver into kvaser_usb_core.c and kvaser_usb_leaf.c")
> Signed-off-by: Seungjin Bae <eeodqql09@gmail.com>
> ---
> v1 -> v2: Apply the same infinite loop fix to kvaser_usb_leaf_wait_cmd()
>
> drivers/net/can/usb/kvaser_usb/kvaser_usb_leaf.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/net/can/usb/kvaser_usb/kvaser_usb_leaf.c b/drivers/net/can/usb/kvaser_usb/kvaser_usb_leaf.c
> index c29828a94ad0..1167d38344f1 100644
> --- a/drivers/net/can/usb/kvaser_usb/kvaser_usb_leaf.c
> +++ b/drivers/net/can/usb/kvaser_usb/kvaser_usb_leaf.c
> @@ -685,7 +685,7 @@ static int kvaser_usb_leaf_wait_cmd(const struct kvaser_usb *dev, u8 id,
> * for further details.
> */
> if (tmp->len == 0) {
> - pos = round_up(pos,
> + pos = round_up(pos + 1,
> le16_to_cpu
> (dev->bulk_in->wMaxPacketSize));
> continue;
> @@ -1732,7 +1732,7 @@ static void kvaser_usb_leaf_read_bulk_callback(struct kvaser_usb *dev,
> * number of events in case of a heavy rx load on the bus.
> */
> if (cmd->len == 0) {
> - pos = round_up(pos, le16_to_cpu
> + pos = round_up(pos + 1, le16_to_cpu
> (dev->bulk_in->wMaxPacketSize));
> continue;
> }
next prev parent reply other threads:[~2025-10-26 13:27 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CAAsoPpV7Kzap1Sn8QFtBbvwW-DJMTTcU_bBOUDYYC286Uaddtg@mail.gmail.com>
2025-10-23 16:27 ` [PATCH v2] can: kvaser_usb: leaf: Fix potential infinite loop in command parsers pip-izony
2025-10-26 13:26 ` Jimmy Assarsson [this message]
2025-10-29 10:53 ` Jimmy Assarsson
[not found] ` <CAAsoPpWaj4iq7HN7DiGpEGTpCv34jNneC-5oLdtyou9qniU2Yw@mail.gmail.com>
2025-11-03 8:51 ` Jimmy Assarsson
2025-10-23 6:16 [PATCH] can: kvaser_usb: leaf: Fix infinite loop on zero-length cmd Marc Kleine-Budde
2025-10-23 16:30 ` [PATCH v2] can: kvaser_usb: leaf: Fix potential infinite loop in command parsers pip-izony
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=1d960d0d-06ab-4f38-817f-b9a5e949d3c7@kvaser.com \
--to=extja@kvaser.com \
--cc=Kyungtae.Kim@dartmouth.edu \
--cc=eeodqql09@gmail.com \
--cc=linux-can@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mailhol@kernel.org \
--cc=mkl@pengutronix.de \
/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