* [PATCH] can: ucan: Fix infinite loop from zero-length messages
@ 2026-02-23 16:30 Greg Kroah-Hartman
2026-03-02 10:06 ` Marc Kleine-Budde
0 siblings, 1 reply; 2+ messages in thread
From: Greg Kroah-Hartman @ 2026-02-23 16:30 UTC (permalink / raw)
To: linux-can
Cc: linux-kernel, Greg Kroah-Hartman, Marc Kleine-Budde,
Vincent Mailhol, stable
If a broken ucan device gets a message with the message length field set
to 0, then the driver will loop for forever in
ucan_read_bulk_callback(), hanging the system. If the length is 0, just
skip the message and go on to the next one.
This has been fixed in the kvaser_usb driver in the past in commit
0c73772cd2b8 ("can: kvaser_usb: leaf: Fix potential infinite loop in
command parsers"), so there must be some broken devices out there like
this somewhere.
Cc: Marc Kleine-Budde <mkl@pengutronix.de>
Cc: Vincent Mailhol <mailhol@kernel.org>
Cc: stable <stable@kernel.org>
Assisted-by: gkh_clanker_2000
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/net/can/usb/ucan.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/net/can/usb/ucan.c b/drivers/net/can/usb/ucan.c
index c79508b1c43e..0ea0ac75e42f 100644
--- a/drivers/net/can/usb/ucan.c
+++ b/drivers/net/can/usb/ucan.c
@@ -748,7 +748,7 @@ static void ucan_read_bulk_callback(struct urb *urb)
len = le16_to_cpu(m->len);
/* check sanity (length of content) */
- if (urb->actual_length - pos < len) {
+ if ((len == 0) || (urb->actual_length - pos < len)) {
netdev_warn(up->netdev,
"invalid message (short; no data; l:%d)\n",
urb->actual_length);
--
2.53.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] can: ucan: Fix infinite loop from zero-length messages
2026-02-23 16:30 [PATCH] can: ucan: Fix infinite loop from zero-length messages Greg Kroah-Hartman
@ 2026-03-02 10:06 ` Marc Kleine-Budde
0 siblings, 0 replies; 2+ messages in thread
From: Marc Kleine-Budde @ 2026-03-02 10:06 UTC (permalink / raw)
To: Greg Kroah-Hartman; +Cc: linux-can, linux-kernel, Vincent Mailhol, stable
[-- Attachment #1: Type: text/plain, Size: 1105 bytes --]
On 23.02.2026 17:30:20, Greg Kroah-Hartman wrote:
> If a broken ucan device gets a message with the message length field set
> to 0, then the driver will loop for forever in
> ucan_read_bulk_callback(), hanging the system. If the length is 0, just
> skip the message and go on to the next one.
>
> This has been fixed in the kvaser_usb driver in the past in commit
> 0c73772cd2b8 ("can: kvaser_usb: leaf: Fix potential infinite loop in
> command parsers"), so there must be some broken devices out there like
> this somewhere.
>
> Cc: Marc Kleine-Budde <mkl@pengutronix.de>
> Cc: Vincent Mailhol <mailhol@kernel.org>
> Cc: stable <stable@kernel.org>
> Assisted-by: gkh_clanker_2000
> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Applied to linux-can, with preferred stable format.
regards,
Marc
--
Pengutronix e.K. | Marc Kleine-Budde |
Embedded Linux | https://www.pengutronix.de |
Vertretung Nürnberg | Phone: +49-5121-206917-129 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-9 |
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-03-02 10:07 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-02-23 16:30 [PATCH] can: ucan: Fix infinite loop from zero-length messages Greg Kroah-Hartman
2026-03-02 10:06 ` Marc Kleine-Budde
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox