From: Chaosheng Qu <quchaosheng000406@163.com>
To: Robin van der Gracht <robin@protonic.nl>,
Oleksij Rempel <o.rempel@pengutronix.de>,
Oliver Hartkopp <socketcan@hartkopp.net>,
Marc Kleine-Budde <mkl@pengutronix.de>
Cc: kernel@pengutronix.de, linux-can@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: [PATCH net v8 4/4] can: j1939: reject a CTS that names more packets than the message has
Date: Wed, 11 Nov 2026 15:24:00 +0800 [thread overview]
Message-ID: <1794300104.11111.1000004@163.com> (raw)
j1939_xtp_rx_cts_one() rejects a zero packet number and a window above
pkt.block, but not a packet number above pkt.total. It then stores
"pkt - 1" in pkt.tx_acked, and the transmitter reports that value back in
an ETP.CM_DPO.
That value is what j1939_xtp_rx_dpo_one() now bounds, so an oversized CTS
is currently caught one step later and reported as a bad EDPO offset.
Reject it where it originates instead, with the abort code that describes
it: J1939_XTP_ABORT_ECTS_TOO_BIG, "ECTS requested packets exceeds message
size".
Signed-off-by: Chaosheng Qu <quchaosheng000406@163.com>
---
net/can/j1939/transport.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/net/can/j1939/transport.c b/net/can/j1939/transport.c
index 124054668650..49ddf6c8f22d 100644
--- a/net/can/j1939/transport.c
+++ b/net/can/j1939/transport.c
@@ -1512,6 +1512,15 @@ j1939_xtp_rx_cts_one(struct j1939_session *session, struct sk_buff *skb)
goto out_session_cancel;
else if (dat[1] > session->pkt.block /* 0xff for etp */)
goto out_session_cancel;
+ else if (pkt > session->pkt.total) {
+ /* The responder asks for more packets than the message has.
+ * pkt - 1 becomes pkt.tx_acked below, and the transmitter
+ * reports that value in an ETP.CM_DPO, where it would name a
+ * packet past the end of the message.
+ */
+ err = J1939_XTP_ABORT_ECTS_TOO_BIG;
+ goto out_session_cancel;
+ }
/* set packet counters only when not CTS(0) */
session->pkt.tx_acked = pkt - 1;
--
2.43.0
reply other threads:[~2026-11-11 7:18 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=1794300104.11111.1000004@163.com \
--to=quchaosheng000406@163.com \
--cc=kernel@pengutronix.de \
--cc=linux-can@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mkl@pengutronix.de \
--cc=o.rempel@pengutronix.de \
--cc=robin@protonic.nl \
--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
all inboxes | Powered by JetHome®