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 08/22] can: isotp: reject CAN_ISOTP_CHK_PAD_DATA without CAN_ISOTP_RX_PADDING
Date: Sat, 28 Nov 2026 10:20:17 +0000 [thread overview]
Message-ID: <179586121772.3131.5988598798132812374@kernel.org> (raw)
In-Reply-To: <20261126-getsockopt-memcg-isotp-v1-8-681ef8d8c2c9@hartkopp.net>
Thank you for your contribution! Sashiko AI review found 3 potential
issue(s) to consider.
Critical: 0 · High: 1 · Medium: 1 · Low: 1
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).
- [High] The new check in isotp_setsockopt_locked()
(net/can/isotp.c:1761-1764) is too broad.
- [Medium] Documentation/networking/iso15765-2.rst (lines 176-178)
documents the UAPI semantics of CAN_ISOTP_CHK_PAD_DATA as: 'check…
- [Low] In check_pad() (net/can/isotp.c:420-427), the branch commented
'/* no valid test against empty value => ignore frame */ return 1;'…
--
can: isotp: reject CAN_ISOTP_CHK_PAD_DATA without CAN_ISOTP_RX_PADDING
With this patch, setsockopt(CAN_ISOTP_OPTS) returns -EINVAL when
CAN_ISOTP_CHK_PAD_DATA is set without CAN_ISOTP_RX_PADDING. The check
runs before the options are copied into so->opt. The goal is to avoid a
configuration in which check_pad() fails for every received frame.
> diff --git a/net/can/isotp.c b/net/can/isotp.c
> index 6471c0ef319a4..0af1a689fdd38 100644
> --- a/net/can/isotp.c
> +++ b/net/can/isotp.c
> @@ -1758,6 +1758,11 @@ static int isotp_setsockopt_locked(struct socket *sock, int optname,
> opt->frame_txtime > ISOTP_MAX_FRAME_TXTIME_NS)
> return -EINVAL;
>
> + /* the padding content check needs the rx padding content */
> + if ((opt->flags & CAN_ISOTP_CHK_PAD_DATA) &&
> + !(opt->flags & CAN_ISOTP_RX_PADDING))
> + return -EINVAL;
[Severity: High]
Does this also reject CAN_ISOTP_CHK_PAD_LEN | CAN_ISOTP_CHK_PAD_DATA
without CAN_ISOTP_RX_PADDING? That combination works before this patch.
When RX_PADDING is clear, check_pad() tests CHK_PAD_LEN first. It never
gets to the content check:
net/can/isotp.c:check_pad() {
/* no RX_PADDING value => check length of optimized frame length */
if (!(so->opt.flags & CAN_ISOTP_RX_PADDING)) {
if (so->opt.flags & CAN_ISOTP_CHK_PAD_LEN)
return check_optimized(cf, start_index);
/* no valid test against empty value => ignore frame */
return 1;
}
...
}
Only CHK_PAD_DATA without CHK_PAD_LEN reaches the return 1. This means
the following statement in the commit message does not hold for the
LEN|DATA combination:
Without CAN_ISOTP_RX_PADDING check_pad() fails for every frame, so that
no PDU can be received and every FC aborts the transmission with
EBADMSG.
The new check returns before memcpy(&so->opt, ...). As a result, every
other option in the same call is discarded too: ext_address,
rx_ext_address, txpad_content, frame_txtime and the remaining flags. An
application that ignores the setsockopt() return value would then keep
running on the default options without noticing.
A "check all padding" mode in userspace tools could produce LEN|DATA
without RX padding. As far as I understand, can-utils -P a is one
example, though I have not verified this.
Would a narrower condition close the broken case without rejecting the
working one? Something like:
if ((opt->flags & CAN_ISOTP_CHK_PAD_DATA) &&
!(opt->flags & (CAN_ISOTP_RX_PADDING | CAN_ISOTP_CHK_PAD_LEN)))
return -EINVAL;
Fixing check_pad() itself would also work.
[Severity: Medium]
Documentation/networking/iso15765-2.rst describes the flag like this:
* CAN_ISOTP_CHK_PAD_DATA: check padding bytes on the received frames
against rxpad_content; if CAN_ISOTP_RX_PADDING is not specified,
this flag is ignored.
After this patch the flag is no longer ignored, and setsockopt() returns
-EINVAL instead. The documentation is not updated in this patch.
The documented behaviour points to a different fix: check_pad() could
ignore CHK_PAD_DATA when RX_PADDING is clear, by returning 0 in that
branch instead of 1. Would that be closer to the existing UAPI contract?
If rejecting the flag is the intended semantics, should
iso15765-2.rst be updated to match?
[Severity: Low]
This isn't a bug, but with this validation in place the "ignore frame"
return 1 branch in check_pad() can no longer be reached.
All callers (isotp_rcv_fc(), isotp_rcv_sf(), isotp_rcv_ff(),
isotp_rcv_cf()) call check_pad() only when ISOTP_CHECK_PADDING is set.
so->opt.flags is written in two places only: isotp_init() sets it to
CAN_ISOTP_DEFAULT_FLAGS, and the memcpy() below copies it after this new
check.
The comment in that branch also says "ignore frame". The code actually
reports a failed check, which drops the frame or aborts the transmission
with EBADMSG.
Could the comment be updated, or the branch removed or reworded to say
that setsockopt() prevents this state?
> +
> memcpy(&so->opt, opt, sizeof(*opt));
>
> /* no separate rx_ext_address is given => use ext_address */
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261126-getsockopt-memcg-isotp-v1-0-681ef8d8c2c9%40hartkopp.net
next prev parent reply other threads:[~2026-11-28 10:20 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-26 21:05 [PATCH can-next 00/22] can: memcg accounting, CAN_ISOTP fixes and cleanups Oliver Hartkopp
2026-11-26 21:05 ` [PATCH can-next 01/22] can: raw: read socket options under conf_lock in raw_getsockopt() Oliver Hartkopp
2026-11-26 21:05 ` [PATCH can-next 02/22] can: isotp: read socket options under conf_lock in isotp_getsockopt() Oliver Hartkopp
2026-11-26 21:05 ` [PATCH can-next 03/22] can: enable memcg accounting for user triggered allocations Oliver Hartkopp
2026-11-27 10:08 ` Oliver Hartkopp
2026-11-27 11:50 ` Oleksij Rempel
2026-11-27 11:58 ` Oliver Hartkopp
2026-11-26 21:05 ` [PATCH can-next 04/22] can: isotp: check the CAN_ISOTP_OPTS values before applying them Oliver Hartkopp
2026-11-26 21:05 ` [PATCH can-next 05/22] can: isotp: add the frame transmission time to the protocol timeouts Oliver Hartkopp
2026-11-28 10:20 ` netdev-bot+sashiko
2026-11-26 21:05 ` [PATCH can-next 06/22] can: isotp: check the CAN FD tx_flags in CAN_ISOTP_LL_OPTS Oliver Hartkopp
2026-11-28 10:20 ` netdev-bot+sashiko
2026-11-26 21:05 ` [PATCH can-next 07/22] can: isotp: reject reserved STmin values in CAN_ISOTP_RECV_FC Oliver Hartkopp
2026-11-26 21:05 ` [PATCH can-next 08/22] can: isotp: reject CAN_ISOTP_CHK_PAD_DATA without CAN_ISOTP_RX_PADDING Oliver Hartkopp
2026-11-28 10:20 ` netdev-bot+sashiko [this message]
2026-11-26 21:05 ` [PATCH can-next 09/22] can: isotp: drop frames without N_PCI Oliver Hartkopp
2026-11-28 10:20 ` netdev-bot+sashiko
2026-11-26 21:05 ` [PATCH can-next 10/22] can: isotp: drop FF frames with invalid length extension Oliver Hartkopp
2026-11-26 21:05 ` [PATCH can-next 11/22] can: isotp: check the minimum FF_DL Oliver Hartkopp
2026-11-28 10:20 ` netdev-bot+sashiko
2026-11-26 21:05 ` [PATCH can-next 12/22] can: isotp: check the data length of the last CF Oliver Hartkopp
2026-11-28 10:20 ` netdev-bot+sashiko
2026-11-26 21:05 ` [PATCH can-next 13/22] can: isotp: do not send FC.OVFLW in listen mode Oliver Hartkopp
2026-11-28 10:20 ` netdev-bot+sashiko
2026-11-26 21:05 ` [PATCH can-next 14/22] can: isotp: ignore invalid SF and FF frames during a reception Oliver Hartkopp
2026-11-28 10:20 ` netdev-bot+sashiko
2026-11-26 21:05 ` [PATCH can-next 15/22] can: isotp: drop inline keyword, let the compiler decide Oliver Hartkopp
2026-11-26 21:05 ` [PATCH can-next 16/22] can: isotp: rename rx_lock as it has become state machine lock Oliver Hartkopp
2026-11-28 10:20 ` netdev-bot+sashiko
2026-11-26 21:05 ` [PATCH can-next 17/22] can: isotp: introduce isotp_invalid_canid() to verify proper CAN-IDs Oliver Hartkopp
2026-11-26 21:06 ` [PATCH can-next 18/22] can: isotp: rename variable for the required content length Oliver Hartkopp
2026-11-26 21:06 ` [PATCH can-next 19/22] can: isotp: rename checkpad functions returning bool values Oliver Hartkopp
2026-11-26 21:06 ` [PATCH can-next 20/22] can: isotp: change return type of functions to void Oliver Hartkopp
2026-11-28 10:20 ` netdev-bot+sashiko
2026-11-26 21:06 ` [PATCH can-next 21/22] can: isotp: rename pointer in isotp_rcv() prototype Oliver Hartkopp
2026-11-26 21:06 ` [PATCH can-next 22/22] can: isotp: introduce CAN_ISOTP_MIN_TX_DL Oliver Hartkopp
2026-11-28 10:20 ` netdev-bot+sashiko
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=179586121772.3131.5988598798132812374@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