From: "Quchaosheng" <quchaosheng000406@163.com>
To: netdev-bot+sashiko@kernel.org
Cc: robin@protonic.nl, o.rempel@pengutronix.de,
kernel@pengutronix.de, socketcan@hartkopp.net,
mkl@pengutronix.de, linux-can@vger.kernel.org,
linux-kernel@vger.kernel.org, kuba@kernel.org
Subject: Re: [PATCH net v2 RESEND] can: j1939: validate the EDPO packet number
Date: Fri, 09 Oct 2026 09:00:52 +0800 [thread overview]
Message-ID: <179150765233.22689.7239412530475901049@163.com> (raw)
In-Reply-To: <179100326445.1406898.9460146166731761306@kernel.org>
On Sat, 03 Oct 2026, netdev-bot+sashiko@kernel.org wrote:
> Critical: 0 - High: 0 - Medium: 2 - Low: 1 (1)
>
> - [Medium] The commit message says the transmitter role is unaffected by
> the new check: "a transmitter derives the offset from pkt.tx_acked,...
> - [Medium] The new EDPO abort branch in j1939_xtp_rx_dpo_one() calls
> j1939_session_timers_cancel() and then j1939_session_cancel() without...
Thanks for the review. One of the two Medium items is a real problem with
my commit message and one I believe is a false positive. Details below.
On the first one: you are right and my summary was wrong. I wrote that a
transmitter derives the offset from pkt.tx_acked, which is "cts_packet - 1"
with cts_packet <= pkt.total, so the largest value it ever announces is
pkt.total - 1. Nothing in j1939_xtp_rx_cts_one() enforces that bound. The
only checks there are:
if (!pkt)
goto out_session_cancel;
else if (dat[1] > session->pkt.block)
goto out_session_cancel;
session->pkt.tx_acked = pkt - 1;
and for ETP pkt comes from (dat[4] << 16) | (dat[3] << 8) | dat[2], so a
peer can set tx_acked past pkt.total. The clamp a few lines further down
only bounds pkt.last:
if (session->pkt.last > session->pkt.total)
session->pkt.last = session->pkt.total;
tx_acked is left as received. So the sentence about the transmitter role
does not hold on what the code does today, and I will drop it rather than
try to prop it up. Whether j1939_xtp_rx_cts_one() should also reject
pkt > pkt.total is a separate question from this patch, and I would send
that as its own change rather than fold it in here.
On the second one I think the code is fine, but here is what I based it on
rather than just asserting it. j1939_xtp_rx_dpo_one() is called from
j1939_xtp_rx_dpo(), which takes the session with
j1939_session_get_by_addr() and always does j1939_session_put() on the way
out:
j1939_xtp_rx_dpo_one(session, skb);
j1939_session_put(session);
So returning early from the abort branch drops the reference the caller
took and there is no leak. Cancelling the timers before calling
j1939_session_cancel() is the same order the existing out_session_cancel
label in j1939_xtp_rx_cts_one() uses.
What I do not think is needed here is j1939_session_deactivate(). The
session is being aborted, not parked for reuse, and j1939_session_cancel()
already moves it out of the active range before scheduling the abort:
if (session->state >= J1939_SESSION_ACTIVE &&
session->state < J1939_SESSION_WAITING_ABORT) {
j1939_tp_set_rxtimeout(session, J1939_XTP_ABORT_TIMEOUT_MS);
__j1939_session_cancel(session, err);
}
If you have a specific invariant in mind that deactivate() maintains on
this path, say which one and I will add the call. I would rather not add
it on a guess.
On the Low item about the commit message: fair, that sentence describes
the reproduction I ran before the range check existed and reads as a claim
about the patch. I will split the two so it is clear the NULL guard and
the DPO range check are separate steps and neither is presented as
sufficient on its own.
I will send a v3 with the commit message reworded so it no longer claims
something the CTS path does not enforce.
pw-bot: cr
prev parent reply other threads:[~2026-10-09 1:01 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-30 5:59 [PATCH net v2 RESEND] can: j1939: validate the EDPO packet number Chaosheng Qu
2026-10-03 4:54 ` netdev-bot+sashiko
2026-10-09 1:00 ` Quchaosheng [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=179150765233.22689.7239412530475901049@163.com \
--to=quchaosheng000406@163.com \
--cc=kernel@pengutronix.de \
--cc=kuba@kernel.org \
--cc=linux-can@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mkl@pengutronix.de \
--cc=netdev-bot+sashiko@kernel.org \
--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