Linux CAN drivers development
 help / color / mirror / Atom feed
From: netdev-bot+sashiko@kernel.org
To: socketcan@hartkopp.net
Cc: linux-can@vger.kernel.org, mkl@pengutronix.de,
	sashiko-bot@kernel.org, zihanx@nebusec.ai,
	o.rempel@pengutronix.de, yewentian395@gmail.com, kuba@kernel.org
Subject: Re: [PATCH can-next v4 07/23] can: isotp: add the frame transmission time to the protocol timeouts
Date: Thu, 03 Dec 2026 06:15:28 +0000	[thread overview]
Message-ID: <179627852862.3142.8395066602250179143@kernel.org> (raw)
In-Reply-To: <20261201-getsockopt-memcg-isotp-v4-7-97261be8e38e@hartkopp.net>

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] setsockopt(CAN_ISOTP_OPTS) in isotp_setsockopt_locked()
  (net/can/isotp.c) now rejects any frame_txtime between 1000000001 and…

--

can: isotp: add the frame transmission time to the protocol timeouts

This patch adds so->frame_txtime (N_As/N_Ar) to the rx, flow control and
local echo timeouts that start when a CAN frame is transmitted. It also
makes setsockopt(CAN_ISOTP_OPTS) reject frame_txtime values above 1 s with
-EINVAL, and documents the new limit in isotp.h and iso15765-2.rst.

Closes: https://lore.kernel.org/linux-can/eb5e9618-3dbf-42cb-a635-752ff9fbcb99@hartkopp.net/

> diff --git a/net/can/isotp.c b/net/can/isotp.c
> index 7b88b3ace919e..18b1e815db4de 100644
> --- a/net/can/isotp.c
> +++ b/net/can/isotp.c

[ ... ]

> @@ -1747,6 +1752,11 @@ static int isotp_setsockopt_locked(struct socket *sock, int optname,
>  		if (hweight32(opt->flags & ISOTP_ALL_BC_FLAGS) > 1)
>  			return -EINVAL;
>  
> +		/* frame_txtime must not exceed the N_As/N_Ar timeout */
> +		if (opt->frame_txtime != CAN_ISOTP_FRAME_TXTIME_ZERO &&
> +		    opt->frame_txtime > ISOTP_MAX_FRAME_TXTIME_NS)
> +			return -EINVAL;
> +
>  		memcpy(&so->opt, opt, sizeof(*opt));

[Severity: Low]
Can this break existing users of CAN_ISOTP_OPTS?

Before this patch, every frame_txtime value except 0 and
CAN_ISOTP_FRAME_TXTIME_ZERO was accepted and stored in so->frame_txtime.
Now, values from 1000000001 to 0xFFFFFFFE ns return -EINVAL.

The check runs before memcpy(&so->opt, ...), so the whole struct is
rejected. None of the other options get applied either:

  - flags such as CAN_ISOTP_EXTEND_ADDR, and the padding and broadcast
    modes
  - ext_address
  - txpad_content and rxpad_content
  - rx_ext_address

An application that used to pass a frame_txtime above 1 s can no longer
configure the socket at all.

Does the timeout fix itself need this limit? ktime_set() works for any u32
nsecs:

include/linux/ktime.h:ktime_set() {
    ...
	return secs * NSEC_PER_SEC + (s64)nsecs;
}

So the new hrtimer_start(..., ktime_set(..., so->frame_txtime), ...) calls
look correct for the full u32 range.

The limit also does not cap the real gap between consecutive frames.
CAN_ISOTP_TX_STMIN with CAN_ISOTP_FORCE_TXSTMIN can still add more time on
top of it.

The commit message does describe the restriction, and it names
CAN_ISOTP_TX_STMIN as the replacement. Would it make sense to move the
narrowing of what userspace can set into its own patch? Clamping the value
instead of rejecting it would be another option. Either way, a backport of
the timeout fix would not carry the ABI change with it. The check is still
there at the end of the series.

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261201-getsockopt-memcg-isotp-v4-0-97261be8e38e%40hartkopp.net

  reply	other threads:[~2026-12-03  6:15 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-01 16:51 [PATCH can-next v4 00/23] can: memcg accounting, CAN_ISOTP fixes and cleanups Oliver Hartkopp
2026-12-01 16:51 ` [PATCH can-next v4 01/23] can: raw: read socket options under conf_lock in raw_getsockopt() Oliver Hartkopp
2026-12-01 16:51 ` [PATCH can-next v4 02/23] can: isotp: read socket options under conf_lock in isotp_getsockopt() Oliver Hartkopp
2026-12-01 16:51 ` [PATCH can-next v4 03/23] can: enable memcg accounting for user triggered allocations Oliver Hartkopp
2026-12-03  6:15   ` netdev-bot+sashiko
2026-12-01 16:51 ` [PATCH can-next v4 04/23] can: isotp: do not send FC.OVFLW in listen mode Oliver Hartkopp
2026-12-01 16:51 ` [PATCH can-next v4 05/23] can: isotp: check the CAN_ISOTP_OPTS values before applying them Oliver Hartkopp
2026-12-01 16:51 ` [PATCH can-next v4 06/23] can: isotp: add the frame transmission time to the CF broadcast gap Oliver Hartkopp
2026-12-03  6:15   ` netdev-bot+sashiko
2026-12-01 16:51 ` [PATCH can-next v4 07/23] can: isotp: add the frame transmission time to the protocol timeouts Oliver Hartkopp
2026-12-03  6:15   ` netdev-bot+sashiko [this message]
2026-12-01 16:51 ` [PATCH can-next v4 08/23] can: isotp: use the N_As timeout for the local echo Oliver Hartkopp
2026-12-03  6:15   ` netdev-bot+sashiko
2026-12-01 16:51 ` [PATCH can-next v4 09/23] can: isotp: check the CAN FD tx_flags in CAN_ISOTP_LL_OPTS Oliver Hartkopp
2026-12-03  6:15   ` netdev-bot+sashiko
2026-12-01 16:51 ` [PATCH can-next v4 10/23] can: isotp: reject reserved STmin values in CAN_ISOTP_RECV_FC Oliver Hartkopp
2026-12-01 16:51 ` [PATCH can-next v4 11/23] can: isotp: ignore CAN_ISOTP_CHK_PAD_DATA without CAN_ISOTP_RX_PADDING Oliver Hartkopp
2026-12-01 16:51 ` [PATCH can-next v4 12/23] can: isotp: drop frames without N_PCI Oliver Hartkopp
2026-12-01 16:51 ` [PATCH can-next v4 13/23] can: isotp: drop FF frames with invalid length extension Oliver Hartkopp
2026-12-01 16:51 ` [PATCH can-next v4 14/23] can: isotp: check the minimum FF_DL Oliver Hartkopp
2026-12-01 16:51 ` [PATCH can-next v4 15/23] can: isotp: check the data length of the last CF Oliver Hartkopp
2026-12-01 16:51 ` [PATCH can-next v4 16/23] can: isotp: drop inline keyword, let the compiler decide Oliver Hartkopp
2026-12-01 16:51 ` [PATCH can-next v4 17/23] can: isotp: rename rx_lock as it has become state machine lock Oliver Hartkopp
2026-12-03  6:15   ` netdev-bot+sashiko
2026-12-01 16:51 ` [PATCH can-next v4 18/23] can: isotp: introduce isotp_invalid_canid() to verify proper CAN-IDs Oliver Hartkopp
2026-12-01 16:51 ` [PATCH can-next v4 19/23] can: isotp: rename variable for the required content length Oliver Hartkopp
2026-12-01 16:51 ` [PATCH can-next v4 20/23] can: isotp: rename checkpad functions returning bool values Oliver Hartkopp
2026-12-01 16:51 ` [PATCH can-next v4 21/23] can: isotp: change return type of functions to void Oliver Hartkopp
2026-12-01 16:51 ` [PATCH can-next v4 22/23] can: isotp: rename pointer in isotp_rcv() prototype Oliver Hartkopp
2026-12-01 16:51 ` [PATCH can-next v4 23/23] can: isotp: introduce CAN_ISOTP_MIN_TX_DL 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=179627852862.3142.8395066602250179143@kernel.org \
    --to=netdev-bot+sashiko@kernel.org \
    --cc=kuba@kernel.org \
    --cc=linux-can@vger.kernel.org \
    --cc=mkl@pengutronix.de \
    --cc=o.rempel@pengutronix.de \
    --cc=sashiko-bot@kernel.org \
    --cc=socketcan@hartkopp.net \
    --cc=yewentian395@gmail.com \
    --cc=zihanx@nebusec.ai \
    /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