From: netdev-bot+sashiko@kernel.org
To: s.grosjean@peak-system.fr
Cc: mkl@pengutronix.de, mailhol@kernel.org, error27@gmail.com,
wg@grandegger.com, linux-can@vger.kernel.org,
linux-kernel@vger.kernel.org, kuba@kernel.org
Subject: Re: [PATCH v5 07/10] can: peak_usb: fix RX cursor desync for self-received RTR frames with SRR
Date: Thu, 22 Oct 2026 03:36:38 +0000 [thread overview]
Message-ID: <179264019805.3131.3239897056475962964@kernel.org> (raw)
In-Reply-To: <20261020-canfd_check_channel_idx-v5-7-a62b35b867f0@peak-system.fr>
Thank you for your contribution! Sashiko AI review found more severe
issue(s) in other patches of this series. This mail is only an FYI, in case
you want to address the nit picks below when you respin.
Low priority / nit picks for your consideration:
- [Low] In pcan_usb_decode_data()
(drivers/net/can/usb/peak_usb/pcan_usb.c), the patch moves the SRR…
--
can: peak_usb: fix RX cursor desync for self-received RTR frames with SRR
This patch moves the SRR writer-id byte skip in pcan_usb_decode_data()
out of the non-RTR branch. The byte is now consumed for RTR frames too,
which matches the layout produced by pcan_usb_encode_msg(). Before this,
self-received RTR frames with SRR set left the RX cursor one byte short.
> diff --git a/drivers/net/can/usb/peak_usb/pcan_usb.c b/drivers/net/can/usb/peak_usb/pcan_usb.c
> index 93da0fd4f10e7..4c8cfed31634a 100644
> --- a/drivers/net/can/usb/peak_usb/pcan_usb.c
> +++ b/drivers/net/can/usb/peak_usb/pcan_usb.c
> @@ -697,16 +697,19 @@ static int pcan_usb_decode_data(struct pcan_usb_msg_context *mc, u8 status_len)
> memcpy(cf->data, mc->ptr, cf->len);
> mc->ptr += rec_len;
>
> - /* Ignore next byte (client private id) if SRR bit is set */
> - if (can_id_flags & PCAN_USB_TX_SRR) {
> - if ((mc->ptr + 1) > mc->end)
> - goto decode_failed;
> - mc->ptr++;
> - }
> -
> /* update statistics */
> mc->netdev->stats.rx_bytes += cf->len;
> }
> +
> + /* Ignore next byte (client private id) if SRR bit is set.
> + * Note: this test must be done even when the frame is an RTR frame.
> + */
> + if (can_id_flags & PCAN_USB_TX_SRR) {
> + if ((mc->ptr + 1) > mc->end)
> + goto decode_failed;
[Severity: Low]
Can rx_bytes now be over-counted for a frame that gets dropped?
The SRR bounds check now runs after the rx_bytes update in the non-RTR
branch. Take a non-RTR record with PCAN_USB_TX_SRR set in can_id_flags
where the URB ends right after the payload, so the writer-id byte is
missing:
pcan_usb_decode_data()
if ((mc->ptr + rec_len) > mc->end) /* passes */
...
mc->netdev->stats.rx_bytes += cf->len;
...
if ((mc->ptr + 1) > mc->end) /* fails */
goto decode_failed;
The skb is freed, -EINVAL is returned and rx_packets is not incremented,
but rx_bytes has already gone up by cf->len.
Before this patch the SRR check came before the rx_bytes update, so a
rejected record was not counted. Nothing undoes the increment later,
because peak_usb_read_bulk_callback() only calls pcan_dump_mem() when
dev_decode_buf() returns an error.
Would it work to move the rx_bytes update below the SRR check, for
example next to the rx_packets++?
> + mc->ptr++;
> + }
> +
> mc->netdev->stats.rx_packets++;
>
> /* convert timestamp into kernel time */
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261020-canfd_check_channel_idx-v5-0-a62b35b867f0%40peak-system.fr
next prev parent reply other threads:[~2026-10-22 3:36 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-20 13:30 [PATCH v5 00/10] can: peak_usb: fixes, cleanup and input validation hardening Stéphane Grosjean via B4 Relay
2026-10-20 13:30 ` [PATCH v5 01/10] can: peak_usb: fix missing CAN_ERR_FLAG when reporting error counters Stéphane Grosjean via B4 Relay
2026-10-20 13:30 ` [PATCH v5 02/10] can: peak_usb: add missing includes Stéphane Grosjean via B4 Relay
2026-10-20 13:30 ` [PATCH v5 03/10] can: peak_usb: sort ctrlmode_supported flags Stéphane Grosjean via B4 Relay
2026-10-20 13:30 ` [PATCH v5 04/10] can: peak_usb: harden PCAN-USB message validation Stéphane Grosjean via B4 Relay
2026-10-20 13:30 ` [PATCH v5 05/10] can: peak_usb: replace open-coded bitmask operations with bitops Stéphane Grosjean via B4 Relay
2026-10-20 13:30 ` [PATCH v5 06/10] can: peak_usb: harden channel handling in PCAN-USB FD Stéphane Grosjean via B4 Relay
2026-10-20 13:30 ` [PATCH v5 07/10] can: peak_usb: fix RX cursor desync for self-received RTR frames with SRR Stéphane Grosjean via B4 Relay
2026-10-22 3:36 ` netdev-bot+sashiko [this message]
2026-10-20 13:30 ` [PATCH v5 08/10] can: peak_usb: reject records for unset channels in PCAN-USB Pro Stéphane Grosjean via B4 Relay
2026-10-22 3:36 ` netdev-bot+sashiko
2026-10-20 13:30 ` [PATCH v5 09/10] can: peak_usb: register the netdevs only once all channels are set up Stéphane Grosjean via B4 Relay
2026-10-22 3:36 ` netdev-bot+sashiko
2026-10-20 13:30 ` [PATCH v5 10/10] can: peak_usb: only dump received bytes on decode error Stéphane Grosjean via B4 Relay
2026-10-22 3:36 ` netdev-bot+sashiko
2026-10-20 13:53 ` [PATCH v5 00/10] can: peak_usb: fixes, cleanup and input validation hardening Dan Carpenter
2026-10-20 14:19 ` Stéphane Grosjean
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=179264019805.3131.3239897056475962964@kernel.org \
--to=netdev-bot+sashiko@kernel.org \
--cc=error27@gmail.com \
--cc=kuba@kernel.org \
--cc=linux-can@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mailhol@kernel.org \
--cc=mkl@pengutronix.de \
--cc=s.grosjean@peak-system.fr \
--cc=wg@grandegger.com \
/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®