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 v3 09/23] can: isotp: check the CAN FD tx_flags in CAN_ISOTP_LL_OPTS
Date: Wed, 02 Dec 2026 03:48:55 +0000 [thread overview]
Message-ID: <179618333533.3142.4629180442411724805@kernel.org> (raw)
In-Reply-To: <20261130-getsockopt-memcg-isotp-v3-9-21d72c15ad1d@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] In isotp_setsockopt_locked() (net/can/isotp.c), the
CAN_ISOTP_LL_OPTS handler now always runs `so->ll.tx_flags |=…
--
can: isotp: check the CAN FD tx_flags in CAN_ISOTP_LL_OPTS
This patch tightens the CAN_ISOTP_LL_OPTS checks so that CAN FD sockets
only accept CANFD_BRS and CANFD_FDF in tx_flags. All other flags are
rejected with -EINVAL. It also always adds CANFD_FDF to the stored
tx_flags for CAN FD, so that getsockopt() reports the flags of the
created CAN FD frames.
> diff --git a/net/can/isotp.c b/net/can/isotp.c
> index aa7bfed15500e..992e8d016e9d4 100644
> --- a/net/can/isotp.c
> +++ b/net/can/isotp.c
> @@ -1796,8 +1796,17 @@ static int isotp_setsockopt_locked(struct socket *sock, int optname,
> (ll->tx_dl > CAN_MAX_DLEN || ll->tx_flags != 0))
> return -EINVAL;
>
> + /* only CANFD_BRS (and the CANFD_FDF marker) for CAN FD frames */
> + if (ll->mtu == CANFD_MTU &&
> + (ll->tx_flags & ~(CANFD_BRS | CANFD_FDF)))
> + return -EINVAL;
> +
> memcpy(&so->ll, ll, sizeof(*ll));
>
> + /* CAN FD frames are always marked with CANFD_FDF */
> + if (so->ll.mtu == CANFD_MTU)
> + so->ll.tx_flags |= CANFD_FDF;
> +
[Severity: Medium]
Could this break a getsockopt()/setsockopt() round trip that worked
before?
Say an unbound socket is set up with {mtu = CANFD_MTU, tx_dl = 64,
tx_flags = 0}. The stored tx_flags now becomes CANFD_FDF (0x04), and
isotp_getsockopt() returns it unchanged:
net/can/isotp.c:isotp_getsockopt() {
...
val.ll = so->ll;
...
}
If userspace then reads the options, changes only mtu to CAN_MTU and
tx_dl to 8, and writes the struct back, the existing classical CAN
check in isotp_setsockopt_locked() rejects it:
if (ll->mtu == CAN_MTU &&
(ll->tx_dl > CAN_MAX_DLEN || ll->tx_flags != 0))
return -EINVAL;
Before this patch the same sequence succeeded. In addition, code that
writes tx_flags = 0 and compares the value it reads back now sees 0x04.
can_send() in net/can/af_can.c already sets the marker on every CAN FD
frame:
cfd->flags |= CANFD_FDF;
So storing it in so->ll does not change what goes on the bus. It only
changes the value userspace sees.
The commit message describes the tightening in terms of CANFD_ESI and
undefined flags. Neither it nor the iso15765-2.rst text says that
CANFD_FDF has to be cleared before switching an existing configuration
back to classical CAN. Would it be better to not store CANFD_FDF in
so->ll.tx_flags? Another option is to ignore or mask CANFD_FDF in the
CAN_MTU check, so the value returned by getsockopt() is always
accepted by setsockopt().
> /* set ll_dl for tx path to similar place as for rx */
> so->tx.ll_dl = ll->tx_dl;
> break;
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261130-getsockopt-memcg-isotp-v3-0-21d72c15ad1d%40hartkopp.net
next prev parent reply other threads:[~2026-12-02 3:48 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-30 13:22 [PATCH can-next v3 00/23] can: memcg accounting, CAN_ISOTP fixes and cleanups Oliver Hartkopp
2026-11-30 13:22 ` [PATCH can-next v3 01/23] can: raw: read socket options under conf_lock in raw_getsockopt() Oliver Hartkopp
2026-11-30 13:22 ` [PATCH can-next v3 02/23] can: isotp: read socket options under conf_lock in isotp_getsockopt() Oliver Hartkopp
2026-11-30 13:22 ` [PATCH can-next v3 03/23] can: enable memcg accounting for user triggered allocations Oliver Hartkopp
2026-12-02 3:48 ` netdev-bot+sashiko
2026-11-30 13:22 ` [PATCH can-next v3 04/23] can: isotp: do not send FC.OVFLW in listen mode Oliver Hartkopp
2026-11-30 13:22 ` [PATCH can-next v3 05/23] can: isotp: check the CAN_ISOTP_OPTS values before applying them Oliver Hartkopp
2026-11-30 13:22 ` [PATCH can-next v3 06/23] can: isotp: add the frame transmission time to the CF broadcast gap Oliver Hartkopp
2026-12-02 3:48 ` netdev-bot+sashiko
2026-11-30 13:22 ` [PATCH can-next v3 07/23] can: isotp: add the frame transmission time to the protocol timeouts Oliver Hartkopp
2026-11-30 13:22 ` [PATCH can-next v3 08/23] can: isotp: use the N_As timeout for the local echo Oliver Hartkopp
2026-11-30 13:22 ` [PATCH can-next v3 09/23] can: isotp: check the CAN FD tx_flags in CAN_ISOTP_LL_OPTS Oliver Hartkopp
2026-12-02 3:48 ` netdev-bot+sashiko [this message]
2026-11-30 13:22 ` [PATCH can-next v3 10/23] can: isotp: reject reserved STmin values in CAN_ISOTP_RECV_FC Oliver Hartkopp
2026-11-30 13:22 ` [PATCH can-next v3 11/23] can: isotp: ignore CAN_ISOTP_CHK_PAD_DATA without CAN_ISOTP_RX_PADDING Oliver Hartkopp
2026-12-02 3:48 ` netdev-bot+sashiko
2026-11-30 13:22 ` [PATCH can-next v3 12/23] can: isotp: drop frames without N_PCI Oliver Hartkopp
2026-11-30 13:22 ` [PATCH can-next v3 13/23] can: isotp: drop FF frames with invalid length extension Oliver Hartkopp
2026-11-30 13:22 ` [PATCH can-next v3 14/23] can: isotp: check the minimum FF_DL Oliver Hartkopp
2026-12-02 3:48 ` netdev-bot+sashiko
2026-11-30 13:22 ` [PATCH can-next v3 15/23] can: isotp: check the data length of the last CF Oliver Hartkopp
2026-11-30 13:22 ` [PATCH can-next v3 16/23] can: isotp: drop inline keyword, let the compiler decide Oliver Hartkopp
2026-11-30 13:22 ` [PATCH can-next v3 17/23] can: isotp: rename rx_lock as it has become state machine lock Oliver Hartkopp
2026-11-30 13:22 ` [PATCH can-next v3 18/23] can: isotp: introduce isotp_invalid_canid() to verify proper CAN-IDs Oliver Hartkopp
2026-11-30 13:22 ` [PATCH can-next v3 19/23] can: isotp: rename variable for the required content length Oliver Hartkopp
2026-11-30 13:22 ` [PATCH can-next v3 20/23] can: isotp: rename checkpad functions returning bool values Oliver Hartkopp
2026-11-30 13:22 ` [PATCH can-next v3 21/23] can: isotp: change return type of functions to void Oliver Hartkopp
2026-11-30 13:22 ` [PATCH can-next v3 22/23] can: isotp: rename pointer in isotp_rcv() prototype Oliver Hartkopp
2026-11-30 13:22 ` [PATCH can-next v3 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=179618333533.3142.4629180442411724805@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