Article View: linux.kernel.netdev
Article #23976Re: [PATCH net v2] can: j1939: reject an out-of-range data packet offset
From: netdev-bot+sashiko
Date: Sat, 28 Nov 2026 19:27
Date: Sat, 28 Nov 2026 19:27
174 lines
14689 bytes
14689 bytes
Thank you for your contribution! Sashiko AI review found 3 potential
issue(s) to consider.
Critical: 0 · High: 0 · Medium: 2 · 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).
- [Medium] In net/can/j1939/transport.c, the new out-of-range check in
j1939_xtp_rx_dpo_one() cancels the session with J1939_XTP_ABORT_FAULT.
- [Medium] The new reject path in j1939_xtp_rx_dpo_one() calls
j1939_session_timers_cancel() and then j1939_session_cancel() without…
- [Low] The commit message's reason why rejecting an out-of-range DPO
loses nothing is wrong at the boundary.
--
can: j1939: reject an out-of-range data packet offset
This patch makes j1939_xtp_rx_dpo_one() reject an ETP DPO whose offset is
not below pkt.total, and cancel the session when that happens. It also
changes j1939_session_completed() to look up the received message at
offset 0 instead of at the DPO window. The NULL test stays there as a
second guard.
Link: https://lore.kernel.org/all/179553126874.3135.14817947057284289051@kernel.org/
> An out-of-range offset has no other legitimate effect either: every data
> packet that follows is rejected by the "packet > session->pkt.total" test
> in
> j1939_xtp_rx_dat_one(), which computes packet from the same dpo, so the
> session can never complete with data.
[Severity: Low]
Does this hold at the boundary? j1939_xtp_rx_dat_one() does:
packet = (dat[0] - 1 + session->pkt.dpo);
if (packet > session->pkt.total ||
(session->pkt.rx + 1) > session->pkt.total) {
With dpo == total and dat[0] == 1, packet == total passes the > test. The
packet is only rejected later, when j1939_session_skb_get_by_offset()
returns NULL.
With dpo == total and dat[0] == 0 (the sequence number is never checked
for zero), packet works out to total - 1. That passes the test, the
lookup finds the message skb, and the payload is copied into the last
7-byte slot.
The new dpo >= session->pkt.total check closes both cases, so the code
itself is fine. Could the commit message describe the bounds check in
j1939_xtp_rx_dat_one() more precisely? Accepting sequence number 0 may
also be worth a separate look.
> diff --git a/net/can/j1939/transport.c b/net/can/j1939/transport.c
> index 8fcfd13e5e6f8..225467843e428 100644
> --- a/net/can/j1939/transport.c
> +++ b/net/can/j1939/transport.c
[ ... ]
> @@ -1823,14 +1828,25 @@ static void j1939_xtp_rx_dpo_one(struct j1939_session *session,
> struct sk_buff *skb)
> {
> const u8 *dat = skb->data;
> + unsigned int dpo;
>
> if (j1939_xtp_rx_cmd_bad_pgn(session, skb))
> return;
>
> netdev_dbg(session->priv->ndev, "%s: 0x%p\n", __func__, session);
>
> + dpo = j1939_etp_ctl_to_packet(dat);
> + if (dpo >= session->pkt.total) {
> + netdev_info(session->priv->ndev,
> + "%s: 0x%p: data packet offset %u is not below the %u packet(s) of this session\n",
> + __func__, session, dpo, session->pkt.total);
> + j1939_session_timers_cancel(session);
> + j1939_session_cancel(session, J1939_XTP_ABORT_FAULT);
[Severity: Medium]
Is J1939_XTP_ABORT_FAULT the right abort reason here? Its description in
enum j1939_xtp_abort is "Maximal retransmit request limit reached", and
j1939_xtp_abort_to_errno() maps it to ENOTRECOVERABLE.
The file already defines a code for this exact condition, and nothing in
net/can/j1939/ uses it yet:
J1939_XTP_ABORT_BAD_EDPO_OFFSET = 12,
/* Bad EDPO offset */
j1939_xtp_abort_to_errno() maps that one to EPROTO.
__j1939_session_cancel() passes the chosen code to the peer and to the
error queue:
session->err = j1939_xtp_abort_to_errno(priv, err);
...
j1939_xtp_tx_abort(priv, &session->skcb,
!session->transmission,
err, session->skcb.addr.pgn);
So the TP.Conn_Abort frame tells the peer reason 5 instead of 12. The
J1939_ERRQUEUE_RX_ABORT queued for this receive session reports
ENOTRECOVERABLE.
Documentation/networking/j1939.rst lists "Invalid PGN or offset in
EDPO/ECTS" under EPROTO. It keeps ENOTRECOVERABLE for the retransmit
limit. The DPO check in j1939_xtp_rx_cmd_bad_pgn() also uses the specific
J1939_XTP_ABORT_BAD_EDPO_PGN.
The commit message gives j1939_xtp_rx_dat_one() as the precedent. Its
FAULT, though, covers data packet numbers, not EDPO offsets. Would
J1939_XTP_ABORT_BAD_EDPO_OFFSET fit better here?
[Severity: Medium]
Can this path lose the abort timeout? j1939_xtp_rx_dpo() still finds
sessions in J1939_SESSION_WAITING_ABORT, because
j1939_session_get_by_addr_locked() matches only on address and direction.
Suppose a second out-of-range DPO arrives after the first one cancelled
the session, but before the echo of our abort frame is processed:
first bad DPO
j1939_session_timers_cancel()
j1939_session_cancel()
j1939_tp_set_rxtimeout(session, J1939_XTP_ABORT_TIMEOUT_MS)
__j1939_session_cancel()
session->state = J1939_SESSION_WAITING_ABORT
second bad DPO
j1939_session_timers_cancel() <- cancels the abort rxtimer
j1939_session_cancel()
state < J1939_SESSION_WAITING_ABORT is false, so no re-arm
j1939_sk_errqueue(session, J1939_ERRQUEUE_RX_ABORT)
The WAITING_ABORT branch of j1939_tp_rxtimer() is the only timer-driven
cleanup for this session. j1939_xtp_tx_abort() ignores allocation and
can_send() failures, so the abort frame may never be sent or echoed. In
that case, does the session stay on active_session_list, holding its
references and receive skb? It would only go away on a new RTS from the
peer, a peer abort, or the interface going down.
Each such DPO also queues another J1939_ERRQUEUE_RX_ABORT, because that
call in j1939_session_cancel() is unconditional when session->sk is NULL.
j1939_xtp_rx_rts_session_active() already works around the same problem
for a second RTS:
} else if (session->state == J1939_SESSION_WAITING_ABORT) {
/* Force deactivation for the receiver.
* If we rely on the timer starting in j1939_session_cancel,
* a second RTS call here will cancel that timer and fail
* to restart it because the state is already WAITING_ABORT.
*/
j1939_session_deactivate_activate_next(session);
}
Before this patch, a DPO in this state went through
j1939_tp_set_rxtimeout(session, 750), which always re-armed the timer.
Does the new path need a similar state check or forced deactivation?
> + return;
> + }
> +
[ ... ]
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261124181757.638280-1-piyus%40iiitd.ac.in
Technical Details
Message-ID:
<179589404616.3135.8619866704479644293@kernel.org>Path:
mbox-mo1.pugleaf.net!news-can.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-373269-linux-kernel-netdev=dewy.ruReferences:
<20261124181757.638280-1-piyus@iiitd.ac.in>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-can.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-373269-linux-kernel-netdev=dewy.ru From: netdev-bot+sashiko@kernel.org Newsgroups: linux.kernel.netdev Subject: Re: [PATCH net v2] can: j1939: reject an out-of-range data packet offset Date: Sat, 28 Nov 2026 19:27:26 +0000 Organization: Usenet Network Message-ID: <179589404616.3135.8619866704479644293@kernel.org> References: <20261124181757.638280-1-piyus@iiitd.ac.in> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="1013890"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:YuvW7/0Xd2wgvJTz4bOVDyCuPNY= sha256:JAKU0/90XXMVmoB1xolOCS13tOUIy+Y66ZfGnKy57gs= sha1:/p29jYigFDIjclvXUX3WwJzPBd0= sha256:NHKOjwQ0A8LyjMsikNMe0iCAJtcPKOnZv2BUSXdrYho= List-ID: <netdev.vger.kernel.org> X-Mailpost-Empty-Hdrs: X-Spam-Level X-Received: from localhost (localhost [127.0.0.1]) by mail.dewy.ru (Postfix) with ESMTP id 5D3DD125F8B; Sat, 28 Nov 2026 22:27:57 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.4 X-Spam-Status: No, score=-3.4 tagged_above=-9999 required=6.31 tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key) header.d=kernel.org X-Received: from mail.dewy.ru ([127.0.0.1]) by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id SOvAFAIFAVYR; Sat, 28 Nov 2026 22:27:49 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-373269-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10]) by mail.dewy.ru (Postfix) with ESMTPS id E2BAC125F86; Sat, 28 Nov 2026 22:27:38 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sea.lore.kernel.org (Postfix) with ESMTP id AA57428460; Sat, 28 Nov 2026 19:27:33 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1795894053; b=1mDZ61+wj3kjfZHLx7cP03mXJBt3rwtb4VpTzBz3nG5GKlFjPLXZPMNERa5YEl+vxGyw eqg046x3sKTvog555lo6aYk/d3AN0lq70d15pTOknP8FQpbL3t2jskRRMCdvcy6ORLdOd 0y5o1TIXw8QCUjo1YqOtEtvVdQFuQbZNTTNDhmX537W/kEiX1rNDnvc/BhqCZW1dySWHw ORwcwKVns0wee7CxqPxgGR3ovntaNTuBhxAdorGEVh115K5XzNRAStxgGO5QieXjrsQNL qnu7LGv8d6DswVtaypKKakA7/v6lO/YoFvEQ6W6EYOg9UJnh6cOKrb1WTJYvNCdLLNQ== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795894053; h=X-Original-To:Received:Received:DKIM-Signature:Subject:From:To:Cc: Date:Message-ID:In-Reply-To:References:X-sashiko-severity: Content-Type:Content-Transfer-Encoding:X-Mailing-List:List-Id: List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner: Precedence:MIME-Version; bh=cSAHE0gyoRNVfJW+r1yI7115HXK85PiC4X6/NSih0es=; b=vcl4rYRNT6XDV7DkL19XSx8gxN+TCC1r9ATDYoWCRfEH1APj9wgUmgcginNG6+6zEQ7N snhAirvcduKS2GqtU1zeMo0SG4+cp7h/Z/rPqc5qZzM4e0AOWXuq3ALDoCfJK7gXOyih7 HRdtXtXPvf5aZUmYVeqZ3wgljLCEjoGayJkO6tFRlRhjpl8fu7mbaK9JltTBr1jXyrZBH lOPnq7g/uJcQBVl+a/Il5j2pJpHGtPzZ4OwJOfkhJFJ+NkSsJuWQ2Xc5jb3VqiTw3YO28 pWtL/rPcrzGMIJuRBNxJDfhGhEps4fhbhnphNHc1e40nXes03c5wMoSG+TGzkHFC8Mg== X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b="nV9V/Miw"; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 80B61606A323; Sat, 28 Nov 2026 19:27:33 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=nV9V/Miw X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795894047; b=o7L8xi/Xp4NqQnBeu9SCZFlFHZUJdyeGkjveif/EhEUB5WWfQq4YeU9XwUqBw76hAqg3 GjInCn8WlGhDzBmfiQZ/n7FjlwV/m177xFtog+cmVUTbIDt35+kA0drkQzaYmJvYF0xZe yik/B549VCn/wF2lfCg7+F3BxOEtGDpkGRDoYLsK+pOAL27h2atuiUavRS8NFxe05uMf1 kFLVTe1tp9XHviIhO4aEe6hLFjVUAx+TQ0q4/1V/pX4k9kwsy6vxlaYuYFsE9QEp5RauA f/fmPpic5JGNsoAZ41XCCNGjRomytlsS9yE0ijlsRZFBOUggV9XEFLo7+t0nyhF+7gQ== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795894047; h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID: In-Reply-To:References:X-sashiko-severity:Content-Type: Content-Transfer-Encoding:MIME-Version; bh=cSAHE0gyoRNVfJW+r1yI7115HXK85PiC4X6/NSih0es=; b=O+VFpWcfg7eS5kBZbiNpMNx4n0YGDI97cRuXMhpSKZumEbC58BdRfkO7ff3jYWy3cnIS RF6jiIt8miUEb2mUKx3SptJSsQ+2vC5VM40minwdCEtaVxOJj2ZI9Nc8ziGrXXm+lAP/0 w+e0eUiJrUNH+EYmxGxyf5x8cct2luiy4VnDktT7UrEznuRiumy0gv0tQf6UVhsbflKGa PQLYTDVRQLXuGaNbe1TRn8dDhq9lfIdwoeIGc3RQ6xo6RJbraj2uyckZFC2VmpBkyw1p1 dxSJzjNgs5cAOMbF2FtiOlT8WOBsuJ3gPDhpASX6i2YdmggbdGa352UpKuquM/Umy4w== X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b="nV9V/Miw"; arc=none smtp.remote-ip=100.103.45.18 X-Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9CB7A606A31C; Sat, 28 Nov 2026 19:27:27 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 996691F000C1; Sat, 28 Nov 2026 19:27:26 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795894047; bh=cSAHE0gyoRNVfJW+r1yI7115HXK85PiC4X6/NSih0es=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=nV9V/Miw6pC8HqtLOivkTHaWc/+ojNKhl76qfoyRrEho7vt6Leyy9Iz7gL6i4G1OC +py/2LFyquTv/0mwJcGLN+/KN1vf/KesJ/hP2cbs1xGA/dvgUTDIEldvASRi0VnaRY gIrKrWDMOIPNhvU5hjj8XviAmBI9gI+KZTqH03FlmHqmyLobSZswf6qK9b6WGVrmq3 il7R+mi87mW6KlxUQE1xmzrW2r8xurqCRdtUgs0qaPGpzBXEmjdfb8H+3IYocbbxew kFKeUgkhLj3iWiM7QNx6IVE9Kic2xS4YkeIpmC68KCCxMppJXJSQgTitrVbOM4n2/0 vx6ODWo8OObng== X-Cc: robin@protonic.nl, o.rempel@pengutronix.de, socketcan@hartkopp.net, mkl@pengutronix.de, linux-can@vger.kernel.org, netdev@vger.kernel.org, kernel@pengutronix.de, linux-kernel@vger.kernel.org, kapil@presceralabs.ai, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, stable@vger.kernel.org X-In-Reply-To: <20261124181757.638280-1-piyus@iiitd.ac.in> X-sashiko-severity: Medium X-Mailing-List: netdev@vger.kernel.org X-List-Post: <mailto:netdev@vger.kernel.org> X-List-Help: <mailto:netdev+help@vger.kernel.org> X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org> X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org> X-List-Owner: <mailto:netdev+owner@vger.kernel.org> X-Precedence: list