Linux CAN drivers development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Oliver Hartkopp" <socketcan@hartkopp.net>, linux-can@vger.kernel.org
Cc: "Marc Kleine-Budde" <mkl@pengutronix.de>,
	"Vincent Mailhol" <mailhol@kernel.org>,
	"Oleksij Rempel" <o.rempel@pengutronix.de>
Subject: Re: [PATCH can-next v6 11/24] can: isotp: reject reserved STmin values in CAN_ISOTP_RECV_FC
Date: Sat, 05 Dec 2026 13:36:23 +0000	[thread overview]
Message-ID: <sashiko-outbox-251585@kernel.org> (raw)
In-Reply-To: <20261205-getsockopt-memcg-isotp-v6-11-9d42c52a90df@hartkopp.net>

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [High] can: isotp: isotp_setsockopt_locked() breaks documented STmin
  UAPI contract
--

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

can: isotp: reject reserved STmin values in CAN_ISOTP_RECV_FC

This commit rejects ISO 15765-2 reserved STmin values (0x80 - 0xF0 and
0xFA - 0xFF) with -EINVAL in the CAN_ISOTP_RECV_FC socket option, and
updates the uAPI header comment and documentation accordingly.

[ ... ]

> diff --git a/include/uapi/linux/can/isotp.h b/include/uapi/linux/can/isotp.h
> index 7f9fb59bad71c..8b1cf7cc68ca0 100644
> --- a/include/uapi/linux/can/isotp.h
> +++ b/include/uapi/linux/can/isotp.h
> @@ -154,10 +154,9 @@ struct can_isotp_ll_options {
>   *
>   * We can strongly assume, that the Linux Kernel implementation of
>   * CAN_ISOTP is capable to run with BS=0, STmin=0 and WFTmax=0.
> - * But as we like to be able to behave as a commonly available ECU,
> - * these default settings can be changed via sockopts.
> - * For that reason the STmin value is intentionally _not_ checked for
> - * consistency and copied directly into the flow control (FC) frame.
> + * These default settings can be changed with the CAN_ISOTP_RECV_FC
> + * sockopt to behave like other ECUs. The reserved STmin values are
> + * rejected with -EINVAL.
>   */
>  
>  /* link layer default values => make use of Classical CAN frames */
> diff --git a/net/can/isotp.c b/net/can/isotp.c
> index cea50bd78632d..01079ce4fa458 100644
> --- a/net/can/isotp.c
> +++ b/net/can/isotp.c
> @@ -1808,9 +1808,17 @@ static int isotp_setsockopt_locked(struct socket *sock, int optname,
>  		break;
>  	}
>  
> -	case CAN_ISOTP_RECV_FC:
> -		memcpy(&so->rxfc, val, sizeof(so->rxfc));
> +	case CAN_ISOTP_RECV_FC: {
> +		const struct can_isotp_fc_options *fc = val;
> +
> +		/* reject the reserved STmin values 0x80 - 0xF0, 0xFA - 0xFF */
> +		if (fc->stmin > 0x7F &&
> +		    (fc->stmin < 0xF1 || fc->stmin > 0xF9))
> +			return -EINVAL;
> +
> +		memcpy(&so->rxfc, fc, sizeof(*fc));
>  		break;
> +	}
>  
>  	case CAN_ISOTP_TX_STMIN:
>  		so->force_tx_stmin = *(const u32 *)val;

[Severity: High]
Does rejecting reserved STmin values in CAN_ISOTP_RECV_FC introduce a
uAPI regression for existing userspace?

Since commit e057dd3fc20f ("can: add ISO 15765-2:2016 transport protocol"),
isotp.h has documented that stmin is intentionally unchecked and copied
into flow control frames.  Existing conformance tests and tools like
isotprecv that configure reserved STmin values will now fail with -EINVAL.

In the kernel, so->rxfc.stmin is only copied verbatim into the outgoing
frame payload in isotp_send_fc() and read back via getsockopt.  Accepting
reserved values introduces no kernel timer, driver, or state-machine issue.

CAN_RAW is also not a drop-in replacement for testing peer handling of
reserved STmin values (such as clamping to 0x7F in isotp_rcv_fc()), since
it lacks the ISO-TP RX state machine for flow control replies, blocksize
counting, and consecutive frame reassembly.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261205-getsockopt-memcg-isotp-v6-0-9d42c52a90df@hartkopp.net?part=11

  reply	other threads:[~2026-12-05 13:36 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-05 13:19 [PATCH can-next v6 00/24] can: memcg accounting, CAN_ISOTP fixes and cleanups Oliver Hartkopp
2026-12-05 13:19 ` [PATCH can-next v6 01/24] can: raw: read socket options under conf_lock in raw_getsockopt() Oliver Hartkopp
2026-12-05 13:19 ` [PATCH can-next v6 02/24] can: isotp: read socket options under conf_lock in isotp_getsockopt() Oliver Hartkopp
2026-12-05 13:19 ` [PATCH can-next v6 03/24] can: enable memcg accounting for user triggered allocations Oliver Hartkopp
2026-12-05 13:19 ` [PATCH can-next v6 04/24] can: isotp: do not send FC.OVFLW in listen mode Oliver Hartkopp
2026-12-05 13:19 ` [PATCH can-next v6 05/24] can: isotp: check the CAN_ISOTP_OPTS values before applying them Oliver Hartkopp
2026-12-05 13:19 ` [PATCH can-next v6 06/24] can: isotp: add the frame transmission time to the CF broadcast gap Oliver Hartkopp
2026-12-05 13:19 ` [PATCH can-next v6 07/24] can: isotp: limit the frame transmission time to the N_As/N_Ar timeout Oliver Hartkopp
2026-12-05 13:20 ` [PATCH can-next v6 08/24] can: isotp: add N_As timeout monitoring for SF/FF/CF Oliver Hartkopp
2026-12-05 13:20 ` [PATCH can-next v6 09/24] can: isotp: add N_Ar timeout monitoring for FC Oliver Hartkopp
2026-12-05 13:41   ` sashiko-bot
2026-12-05 13:20 ` [PATCH can-next v6 10/24] can: isotp: check the CAN FD tx_flags in CAN_ISOTP_LL_OPTS Oliver Hartkopp
2026-12-05 13:41   ` sashiko-bot
2026-12-05 13:20 ` [PATCH can-next v6 11/24] can: isotp: reject reserved STmin values in CAN_ISOTP_RECV_FC Oliver Hartkopp
2026-12-05 13:36   ` sashiko-bot [this message]
2026-12-05 13:20 ` [PATCH can-next v6 12/24] can: isotp: ignore CAN_ISOTP_CHK_PAD_DATA without CAN_ISOTP_RX_PADDING Oliver Hartkopp
2026-12-05 13:20 ` [PATCH can-next v6 13/24] can: isotp: drop frames without N_PCI Oliver Hartkopp
2026-12-05 13:20 ` [PATCH can-next v6 14/24] can: isotp: drop FF frames with invalid length extension Oliver Hartkopp
2026-12-05 13:20 ` [PATCH can-next v6 15/24] can: isotp: check the minimum FF_DL Oliver Hartkopp
2026-12-05 13:20 ` [PATCH can-next v6 16/24] can: isotp: check the data length of the last CF Oliver Hartkopp
2026-12-05 13:20 ` [PATCH can-next v6 17/24] can: isotp: drop inline keyword, let the compiler decide Oliver Hartkopp
2026-12-05 13:20 ` [PATCH can-next v6 18/24] can: isotp: rename rx_lock as it has become state machine lock Oliver Hartkopp
2026-12-05 13:20 ` [PATCH can-next v6 19/24] can: isotp: introduce isotp_invalid_canid() to verify proper CAN-IDs Oliver Hartkopp
2026-12-05 13:20 ` [PATCH can-next v6 20/24] can: isotp: rename variable for the required content length Oliver Hartkopp
2026-12-05 13:20 ` [PATCH can-next v6 21/24] can: isotp: rename checkpad functions returning bool values Oliver Hartkopp
2026-12-05 13:20 ` [PATCH can-next v6 22/24] can: isotp: change return type of functions to void Oliver Hartkopp
2026-12-05 13:20 ` [PATCH can-next v6 23/24] can: isotp: rename pointer in isotp_rcv() prototype Oliver Hartkopp
2026-12-05 13:20 ` [PATCH can-next v6 24/24] 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=sashiko-outbox-251585@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