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, kuba@kernel.org
Subject: Re: [PATCH can-next v2 09/22] can: isotp: reject reserved STmin values in CAN_ISOTP_RECV_FC
Date: Mon, 30 Nov 2026 20:25:07 +0000	[thread overview]
Message-ID: <179607030732.3142.6219909436645380074@kernel.org> (raw)
In-Reply-To: <20261128-getsockopt-memcg-isotp-v2-9-034ba95e17a4@hartkopp.net>

Thank you for your contribution! Sashiko AI review found 3 potential
issue(s) to consider.

Critical: 0 · High: 0 · Medium: 1 · Low: 2

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 uAPI header now contradicts the code.
- [Low] The commit message does not say that 'can: isotp: reject reserved
  STmin values in CAN_ISOTP_RECV_FC' changes the uAPI, and it does not…
- [Low] The 'Flow Control options' section of
  Documentation/networking/iso15765-2.rst (lines 253-258) lists the…

--

can: isotp: reject reserved STmin values in CAN_ISOTP_RECV_FC

This patch makes setsockopt(CAN_ISOTP_RECV_FC) return -EINVAL when the
STmin value is in one of the ISO 15765-2 reserved ranges, 0x80 - 0xF0 or
0xFA - 0xFF. Before this change, any value was accepted and sent on the
bus in the receiver's flow control frames.

> can: isotp: reject reserved STmin values in CAN_ISOTP_RECV_FC
>
> The STmin value of struct can_isotp_fc_options is sent in the flow
> control frames of the receiver. ISO 15765-2 reserves the values 0x80 -
> 0xF0 and 0xFA - 0xFF, but CAN_ISOTP_RECV_FC accepted any value and the
> reserved values were sent on the bus. The sender side replaces received
> reserved values with 0x7F already.
>
> Reject the reserved STmin values with -EINVAL before the options are
> applied.

[Severity: Low]
Is this meant as a bug fix or as a deliberate tightening of the uAPI? The
message calls the old behaviour a defect ("the reserved values were sent
on the bus"). It has no Fixes: tag, and it gives no reason for leaving one
out.

The sibling patch in this series, "can: isotp: check the CAN FD tx_flags
in CAN_ISOTP_LL_OPTS", says "This is an intentional tightening of the
uAPI and no bug fix". It also names CAN_RAW as the fallback for testing.

Could this commit message say the same kind of thing? It could also
mention that the change reverses the "intentionally _not_ checked"
behaviour documented in include/uapi/linux/can/isotp.h. Without that,
stable/AUTOSEL handling is unclear. Users who set reserved STmin values on
purpose also get no explanation and no alternative.

> diff --git a/net/can/isotp.c b/net/can/isotp.c
> index ea3790a855827..22bfc1c7b131f 100644
> --- a/net/can/isotp.c
> +++ b/net/can/isotp.c
> @@ -1770,9 +1770,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;

[Severity: Medium]
Does this now contradict the uAPI header? The "Remark on
CAN_ISOTP_DEFAULT_RECV_* values" block in include/uapi/linux/can/isotp.h
still says:

 * 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.

Before this patch, the value went straight into so->rxfc, and
isotp_send_fc() put it on the bus:

	ncf->data[ae + 2] = so->rxfc.stmin;

Now setsockopt(fd, SOL_CAN_ISOTP, CAN_ISOTP_RECV_FC, &fc, 3) with
fc.stmin in 0x80 - 0xF0 or 0xFA - 0xFF fails with -EINVAL. It used to
return 0. Because the whole option is rejected, bs and wftmax from the
same call are not applied either.

Some userspace may rely on the documented behaviour, for example ECU
simulators or robustness tools that send reserved STmin values to check
that the peer clamps them to 0x7F, as isotp_rcv_fc() does here. Is that
break intended?

If it is, should the header comment be updated in this patch? It is
still unchanged at the end of the series, at "can: isotp: introduce
CAN_ISOTP_MIN_TX_DL".

[Severity: Low]
Should Documentation/networking/iso15765-2.rst mention this new error
return? Its "Flow Control options" section lists the stmin ranges and
says only "(others are reserved)". It does not say that setsockopt() now
rejects those values.

The tx_flags entry in the same file does document its restriction:

  ``CANFD_FDF`` marker) can be set, other flags are rejected with ``-EINVAL``.

The stmin entry is still unchanged at the end of the series.

> +
> +		memcpy(&so->rxfc, fc, sizeof(*fc));
>  		break;
> +	}
>
>  	case CAN_ISOTP_TX_STMIN:
>  		so->force_tx_stmin = *(const u32 *)val;

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261128-getsockopt-memcg-isotp-v2-0-034ba95e17a4%40hartkopp.net

  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 [this message]
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
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=179607030732.3142.6219909436645380074@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