From: netdev-bot+sashiko@kernel.org
To: socketcan@hartkopp.net
Cc: linux-can@vger.kernel.org, mkl@pengutronix.de, kuba@kernel.org
Subject: Re: [PATCH can-next v2 11/22] can: isotp: drop frames without N_PCI
Date: Mon, 30 Nov 2026 20:25:08 +0000 [thread overview]
Message-ID: <179607030811.3142.10779302114478643996@kernel.org> (raw)
In-Reply-To: <20261128-getsockopt-memcg-isotp-v2-11-034ba95e17a4@hartkopp.net>
Thank you for your contribution! Sashiko AI review found 1 potential
issue(s) to consider.
Critical: 0 · High: 0 · Medium: 1 · Low: 0
If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).
- [Medium] The patch only partly removes the symptom its commit message
describes.
--
can: isotp: drop frames without N_PCI
This patch adds a length check to isotp_rcv() so that CAN frames with
CAN_DL < ae + N_PCI_SZ are dropped. Previously the AE and N_PCI bytes
were read beyond CAN_DL. A zero-filled CAN_DL 0 frame was then handled
as an SF with SF_DL 0, which ended an ongoing reception.
> diff --git a/net/can/isotp.c b/net/can/isotp.c
> index b237b1fb9d99c..798c1b4c6f6ae 100644
> --- a/net/can/isotp.c
> +++ b/net/can/isotp.c
> @@ -775,6 +775,10 @@ static void isotp_rcv(struct sk_buff *skb, void *data)
>
> cf = (struct canfd_frame *)skb->data;
>
> + /* frames without N_PCI (and AE) are no N_PDUs */
> + if (cf->len < ae + N_PCI_SZ)
> + return;
> +
[Severity: Medium]
This new check closes the read beyond CAN_DL. Can an invalid SF still
end an ongoing reception, though? A frame one byte longer, with
CAN_DL = ae + 1 and N_PCI byte 0x00, passes this check. It then goes
into isotp_rcv_sf() with SF_DL 0.
isotp_rcv_sf() resets the rx state before it checks the length:
net/can/isotp.c:isotp_rcv_sf() {
...
hrtimer_cancel(&so->rxtimer);
WRITE_ONCE(so->rx.state, ISOTP_IDLE);
if (!len || len > cf->len - pcilen)
return 1;
...
}
So the zero-filled frame from the commit message, with its length byte
raised by one, still ends a reception in ISOTP_WAIT_DATA. The same
happens for any SF with SF_DL > CAN_DL - pcilen. It also happens for a
CAN FD SF with CAN_DL > 8, the SF_DL escape value 0, and a real SF_DL
that is 0 or too large.
isotp_rcv_ff() uses the same order:
net/can/isotp.c:isotp_rcv_ff() {
...
hrtimer_cancel(&so->rxtimer);
WRITE_ONCE(so->rx.state, ISOTP_IDLE);
/* get the used sender LL_DL from the (first) CAN frame data length */
so->rx.ll_dl = padlen(cf->len);
/* the first frame has to use the entire frame up to LL_DL length */
if (cf->len != so->rx.ll_dl)
return 1;
...
}
padlen() maps 0..8 to 8, so an FF with CAN_DL 2..7 is rejected only
after rx.state has been reset and rx.ll_dl overwritten. None of these
paths set sk_err. The partial PDU is dropped silently, and the
following CFs are ignored because rx.state is no longer
ISOTP_WAIT_DATA.
The SF handling in isotp_rcv() is also inconsistent. An FD SF with
CAN_DL > 8 and SF_DL != 0 is ignored without touching the rx state,
but the invalid SFs above end the reception:
if (cf->len <= CAN_MAX_DLEN) {
isotp_rcv_sf(sk, cf, SF_PCI_SZ4 + ae, skb, sf_dl);
} else {
if (can_is_canfd_skb(skb)) {
...
if (sf_dl == 0)
isotp_rcv_sf(sk, cf, SF_PCI_SZ8 + ae, skb,
cf->data[SF_PCI_SZ4 + ae]);
isotp_rcv_cf() checks the frame first and only then changes state:
/* stop the rx timeout only for valid CFs (checked above) */
hrtimer_cancel(&so->rxtimer);
The problem is still there at the end of the series.
isotp_rcv_sf() and isotp_rcv_ff() still reset the state first. The
later patches "can: isotp: drop FF frames with invalid length
extension" and "can: isotp: check the minimum FF_DL" add more return
paths after that reset. Their commit messages say these frames "shall
be ignored according to ISO 15765-2:2016". As written, those invalid
FFs abort an ongoing reception instead of being ignored.
Would it make sense to validate SF_DL, the FF CAN_DL and FF_DL before
cancelling rxtimer and setting rx.state to ISOTP_IDLE? The new N_PCI
length check would still be needed in addition to that.
> /* if enabled: check reception of my configured extended address */
> if (ae && cf->data[0] != so->opt.rx_ext_address)
> return;
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261128-getsockopt-memcg-isotp-v2-0-034ba95e17a4%40hartkopp.net
next prev parent reply other threads:[~2026-11-30 20:25 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-28 17:48 [PATCH can-next v2 00/22] can: memcg accounting, CAN_ISOTP fixes and cleanups Oliver Hartkopp
2026-11-28 17:48 ` [PATCH can-next v2 01/22] can: raw: read socket options under conf_lock in raw_getsockopt() Oliver Hartkopp
2026-11-28 17:48 ` [PATCH can-next v2 02/22] can: isotp: read socket options under conf_lock in isotp_getsockopt() Oliver Hartkopp
2026-11-28 17:48 ` [PATCH can-next v2 03/22] can: enable memcg accounting for user triggered allocations Oliver Hartkopp
2026-11-30 20:25 ` netdev-bot+sashiko
2026-11-28 17:48 ` [PATCH can-next v2 04/22] can: isotp: do not send FC.OVFLW in listen mode Oliver Hartkopp
2026-11-30 20:25 ` netdev-bot+sashiko
2026-11-28 17:48 ` [PATCH can-next v2 05/22] can: isotp: check the CAN_ISOTP_OPTS values before applying them Oliver Hartkopp
2026-11-28 17:48 ` [PATCH can-next v2 06/22] can: isotp: add the frame transmission time to the CF broadcast gap Oliver Hartkopp
2026-11-30 20:25 ` netdev-bot+sashiko
2026-11-28 17:48 ` [PATCH can-next v2 07/22] can: isotp: add the frame transmission time to the protocol timeouts Oliver Hartkopp
2026-11-30 20:25 ` netdev-bot+sashiko
2026-11-28 17:49 ` [PATCH can-next v2 08/22] can: isotp: check the CAN FD tx_flags in CAN_ISOTP_LL_OPTS Oliver Hartkopp
2026-11-30 20:25 ` netdev-bot+sashiko
2026-11-28 17:49 ` [PATCH can-next v2 09/22] can: isotp: reject reserved STmin values in CAN_ISOTP_RECV_FC Oliver Hartkopp
2026-11-30 20:25 ` netdev-bot+sashiko
2026-11-28 17:49 ` [PATCH can-next v2 10/22] can: isotp: ignore CAN_ISOTP_CHK_PAD_DATA without CAN_ISOTP_RX_PADDING Oliver Hartkopp
2026-11-28 17:49 ` [PATCH can-next v2 11/22] can: isotp: drop frames without N_PCI Oliver Hartkopp
2026-11-30 20:25 ` netdev-bot+sashiko [this message]
2026-11-28 17:49 ` [PATCH can-next v2 12/22] can: isotp: drop FF frames with invalid length extension Oliver Hartkopp
2026-11-28 17:49 ` [PATCH can-next v2 13/22] can: isotp: check the minimum FF_DL Oliver Hartkopp
2026-11-28 17:49 ` [PATCH can-next v2 14/22] can: isotp: check the data length of the last CF Oliver Hartkopp
2026-11-28 17:49 ` [PATCH can-next v2 15/22] can: isotp: drop inline keyword, let the compiler decide Oliver Hartkopp
2026-11-28 17:49 ` [PATCH can-next v2 16/22] can: isotp: rename rx_lock as it has become state machine lock Oliver Hartkopp
2026-11-30 20:25 ` netdev-bot+sashiko
2026-11-28 17:49 ` [PATCH can-next v2 17/22] can: isotp: introduce isotp_invalid_canid() to verify proper CAN-IDs Oliver Hartkopp
2026-11-28 17:49 ` [PATCH can-next v2 18/22] can: isotp: rename variable for the required content length Oliver Hartkopp
2026-11-28 17:49 ` [PATCH can-next v2 19/22] can: isotp: rename checkpad functions returning bool values Oliver Hartkopp
2026-11-28 17:49 ` [PATCH can-next v2 20/22] can: isotp: change return type of functions to void Oliver Hartkopp
2026-11-28 17:49 ` [PATCH can-next v2 21/22] can: isotp: rename pointer in isotp_rcv() prototype Oliver Hartkopp
2026-11-28 17:49 ` [PATCH can-next v2 22/22] can: isotp: introduce CAN_ISOTP_MIN_TX_DL Oliver Hartkopp
2026-11-30 8:57 ` [PATCH can-next v2 00/22] can: memcg accounting, CAN_ISOTP fixes and cleanups Oliver Hartkopp
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=179607030811.3142.10779302114478643996@kernel.org \
--to=netdev-bot+sashiko@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-can@vger.kernel.org \
--cc=mkl@pengutronix.de \
--cc=socketcan@hartkopp.net \
/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