Linux CAN drivers development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Marc Kleine-Budde" <mkl@pengutronix.de>
Cc: linux-can@vger.kernel.org,
	"Oliver Hartkopp" <socketcan@hartkopp.net>,
	"Vincent Mailhol" <mailhol@kernel.org>,
	"Oleksij Rempel" <o.rempel@pengutronix.de>
Subject: Re: [PATCH net 06/11] can: isotp: always start the rx timeout in ISOTP_WAIT_DATA state
Date: Wed, 18 Nov 2026 22:10:16 +0000	[thread overview]
Message-ID: <sashiko-outbox-222094@kernel.org> (raw)
In-Reply-To: <20261117220818.1142581-7-mkl@pengutronix.de>

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] can: isotp: rxtimer not restarted on invalid CF length in
  isotp_rcv_cf()
--

commit 94f5ff3c55fd4fb8ddb6ad8f21dc67ceb4b06102
Author: Oliver Hartkopp <socketcan@hartkopp.net>

can: isotp: always start the rx timeout in ISOTP_WAIT_DATA state

This commit starts so->rxtimer in isotp_rcv_ff() and isotp_rcv_cf()
before checking CAN_ISOTP_LISTEN_MODE or calling isotp_send_fc() so that
reception does not stay in ISOTP_WAIT_DATA without an active timeout.

Link: https://patch.msgid.link/20261117-can-bcmlock-memcg-v6-6-6826a6227d36@hartkopp.net

> diff --git a/net/can/isotp.c b/net/can/isotp.c
> index 8229b6a69ecd0..0293d590186c4 100644
> --- a/net/can/isotp.c
> +++ b/net/can/isotp.c

[ ... ]

> @@ -726,13 +730,13 @@ static int isotp_rcv_cf(struct sock *sk, struct canfd_frame *cf, int ae,
>  		return 0;
>  	}
>  
> +	/* start rx timeout, isotp_send_fc() restarts it */
> +	hrtimer_start(&so->rxtimer, ktime_set(ISOTP_FC_TIMEOUT, 0),
> +		      HRTIMER_MODE_REL_SOFT);
> +
>  	/* perform blocksize handling, if enabled */
> -	if (!so->rxfc.bs || ++so->rx.bs < so->rxfc.bs) {
> -		/* start rx timeout watchdog */
> -		hrtimer_start(&so->rxtimer, ktime_set(ISOTP_FC_TIMEOUT, 0),
> -			      HRTIMER_MODE_REL_SOFT);
> +	if (!so->rxfc.bs || ++so->rx.bs < so->rxfc.bs)
>  		return 0;
> -	}
>  
>  	/* no creation of flow control frames */
>  	if (so->opt.flags & CAN_ISOTP_LISTEN_MODE)

[Severity: Medium]
Can isotp_rcv_cf() still leave so->rx.state in ISOTP_WAIT_DATA without a
running so->rxtimer when cf->len is invalid?

Earlier in isotp_rcv_cf(), so->rxtimer is cancelled before checking
cf->len against so->rx.ll_dl:

net/can/isotp.c:isotp_rcv_cf() {
    ...
	hrtimer_cancel(&so->rxtimer);

	if (READ_ONCE(so->rx.state) != ISOTP_WAIT_DATA)
		return 1;

	/* CFs are never longer than the FF */
	if (cf->len > so->rx.ll_dl)
		return 1;

	/* CFs have usually the LL_DL length */
	if (cf->len < so->rx.ll_dl) {
		/* this is only allowed for the last CF */
		if (so->rx.len - so->rx.idx > so->rx.ll_dl - ae - N_PCI_SZ)
			return 1;
	}
    ...
}

Unlike the sequence-number mismatch path below it, which resets
so->rx.state to ISOTP_IDLE, a consecutive frame that fails either cf->len
check returns before reaching the new hrtimer_start() while leaving
so->rx.state in ISOTP_WAIT_DATA.  If no further frames arrive (for
example, if the CAN device is removed), the transfer never times out and
isotp_bind() continues to fail with -EAGAIN until the socket is closed.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261117220818.1142581-1-mkl@pengutronix.de?part=6

  reply	other threads:[~2026-11-18 22:10 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-17 22:03 [PATCH net 0/11] pull-request: can 2026-11-17 Marc Kleine-Budde
2026-11-17 22:03 ` [PATCH net 01/11] can: bcm: copy the CAN frames outside of lock_sock() Marc Kleine-Budde
2026-11-17 22:12   ` netdev-bot+sinfo
2026-11-18  7:47     ` Oliver Hartkopp
2026-11-17 22:03 ` [PATCH net 02/11] can: bcm: do not remove the procfs entry in bcm_notify() Marc Kleine-Budde
2026-11-17 22:03 ` [PATCH net 03/11] can: raw: use a private mutex instead of lock_sock() Marc Kleine-Budde
2026-11-17 22:03 ` [PATCH net 04/11] can: isotp: " Marc Kleine-Budde
2026-11-17 22:03 ` [PATCH net 05/11] can: bcm: " Marc Kleine-Budde
2026-11-17 22:03 ` [PATCH net 06/11] can: isotp: always start the rx timeout in ISOTP_WAIT_DATA state Marc Kleine-Budde
2026-11-18 22:10   ` sashiko-bot [this message]
2026-11-17 22:03 ` [PATCH net 07/11] can: isotp: reject socket options while a transfer is active Marc Kleine-Budde
2026-11-18 22:10   ` sashiko-bot
2026-11-17 22:03 ` [PATCH net 08/11] can: netlink: fix static FD-NON-ISO mode validation Marc Kleine-Budde
2026-11-17 22:03 ` [PATCH net 09/11] can: netlink: fix IFLA_CAN_BITRATE_MAX attribute sizing Marc Kleine-Budde
2026-11-17 22:03 ` [PATCH net 10/11] can: netlink: fix CAN XL PWM " Marc Kleine-Budde
2026-11-17 22:03 ` [PATCH net 11/11] can: gs_usb: gs_can_start_xmit(): don't leak uninitialized memory over USB Marc Kleine-Budde

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=sashiko-outbox-222094@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=linux-can@vger.kernel.org \
    --cc=mailhol@kernel.org \
    --cc=mkl@pengutronix.de \
    --cc=o.rempel@pengutronix.de \
    --cc=sashiko-reviews@lists.linux.dev \
    --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