From: sashiko-bot@kernel.org
To: "Alexander Hölzl" <alexander.hoelzl@gmx.net>
Cc: "Oliver Hartkopp" <socketcan@hartkopp.net>,
"Marc Kleine-Budde" <mkl@pengutronix.de>,
"Vincent Mailhol" <mailhol@kernel.org>,
"Oleksij Rempel" <o.rempel@pengutronix.de>,
linux-can@vger.kernel.org
Subject: Re: [PATCH v4 1/3] j1939: restrict amount of consecutive retransmission requests
Date: Mon, 06 Jul 2026 22:58:24 +0000 [thread overview]
Message-ID: <20260706225824.ED6EB1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260706224548.100451-1-alexander.hoelzl@gmx.net>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] Flawed retransmit tracking logic causes both spurious connection aborts and counter resets.
- [High] CTS hold messages bypass the retransmit limit, enabling indefinite connection persistence (DoS).
--
--- Patch [1]: [PATCH v4 1/3] j1939: restrict amount of consecutive retransmission requests ---
commit e2e0a35fca4d64ebcdd174aa2094ae405f7ecced
Author: Alexander Hölzl <alexander.hoelzl@gmx.net>
j1939: restrict amount of consecutive retransmission requests
This commit introduces a retransmit counter and aborts the segmented
data transfer if the retransmit limit is reached.
> diff --git a/net/can/j1939/j1939-priv.h b/net/can/j1939/j1939-priv.h
> index 81f58924b4acd..16867d8030922 100644
> --- a/net/can/j1939/j1939-priv.h
> +++ b/net/can/j1939/j1939-priv.h
[ ... ]
> @@ -285,6 +285,8 @@ struct j1939_session {
> unsigned int block;
> /* dpo - ETP.CM_DPO, Data Packet Offset */
> unsigned int dpo;
> + /* retransmits - amount of received retransmit requests (including holds) */
> + unsigned int retransmits;
[Severity: High]
If this counter is intended to include holds, will they actually be counted?
Looking at j1939_xtp_rx_cts_one() in transport.c, if j1939_cts_is_hold(skb)
is true, the function sets the hold timeout and returns early:
if (j1939_cts_is_hold(skb)) {
...
j1939_tp_set_rxtimeout(session, J1939_CTS_HOLD_TIMEOUT_MS);
return;
}
Because this early return bypasses the new retransmits tracking logic,
could a peer keep a session open indefinitely by continuously sending
CTS hold messages?
> } pkt;
> struct hrtimer txtimer, rxtimer;
> };
> diff --git a/net/can/j1939/transport.c b/net/can/j1939/transport.c
> index df93d57907da7..6f999b18bbca5 100644
> --- a/net/can/j1939/transport.c
> +++ b/net/can/j1939/transport.c
[ ... ]
> @@ -1457,6 +1465,19 @@ j1939_xtp_rx_cts_one(struct j1939_session *session, struct sk_buff *skb)
> else if (dat[1] > session->pkt.block /* 0xff for etp */)
> goto out_session_cancel;
>
> + /* If the 'next packet number to be sent' in the CTS is smaller or
> + * equal to an already sent packet it is a retransmit request.
> + */
> + if (session->pkt.tx >= pkt) {
> + session->pkt.retransmits++;
[Severity: High]
Does this logic reliably track retransmits, given that session->pkt.tx
is updated asynchronously by txtimer?
If a peer drops a packet and requests the next one (forward progress),
but txtimer has already sent past that requested packet number, wouldn't
session->pkt.tx >= pkt evaluate to true? This seems like it could
spuriously increment the counter and abort valid transfers over lossy links.
Conversely, if a peer sends a duplicate CTS request before txtimer has sent
the newly requested packet, session->pkt.tx would still be pkt - 1. Wouldn't
that evaluate to false and cause the else block to reset the retransmits
counter to 0?
> + if (session->pkt.retransmits >= J1939_CTS_MAX_NUM_TRANSMITS) {
> + err = J1939_XTP_ABORT_FAULT;
> + goto out_session_cancel;
> + }
> + } else {
> + session->pkt.retransmits = 0;
> + }
> +
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260706224548.100451-1-alexander.hoelzl@gmx.net?part=1
prev parent reply other threads:[~2026-07-06 22:58 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-06 22:41 [PATCH v4 1/3] j1939: restrict amount of consecutive retransmission requests Alexander Hölzl
2026-07-06 22:41 ` [PATCH v4 2/3] j1939: fix implementation not handling holds correctly Alexander Hölzl
2026-07-06 22:58 ` sashiko-bot
2026-07-06 22:41 ` [PATCH v4 3/3] j1939: add J1939 rx CTS tests Alexander Hölzl
2026-07-06 22:52 ` sashiko-bot
2026-07-06 22:58 ` sashiko-bot [this message]
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=20260706225824.ED6EB1F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=alexander.hoelzl@gmx.net \
--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