From: Oleksij Rempel <o.rempel@pengutronix.de>
To: Piyus Kedia <piyus@iiitd.ac.in>
Cc: Robin van der Gracht <robin@protonic.nl>,
Oliver Hartkopp <socketcan@hartkopp.net>,
Marc Kleine-Budde <mkl@pengutronix.de>,
linux-can@vger.kernel.org, netdev@vger.kernel.org,
kernel@pengutronix.de, linux-kernel@vger.kernel.org,
Kapil Vaswani <kapil@presceralabs.ai>,
davem@davemloft.net, edumazet@google.com, kuba@kernel.org,
pabeni@redhat.com, stable@vger.kernel.org
Subject: Re: [PATCH net v2] can: j1939: reject an out-of-range data packet offset
Date: Sun, 29 Nov 2026 17:02:55 +0100 [thread overview]
Message-ID: <awxMr_bAtgqEwbrf@pengutronix.de> (raw)
In-Reply-To: <20261124181757.638280-1-piyus@iiitd.ac.in>
Hi Piyus,
On Thu, Nov 26, 2026 at 08:33:39PM +0530, Piyus Kedia wrote:
> Reject an offset that is not below session->pkt.total, and look the
> completed receive message up at offset 0 rather than at whatever window
> the peer's last DPO named.
Thank you for the reproducer.
As far as I can see, the range check needs more changes in the session
code. I would like to keep the fix for stable small.
Could you send the NULL check in j1939_session_completed() as a separate
patch for stable first? The range check for the DPO can follow as its
own patch.
For the stable patch, I would expect something like this (untested):
if (!session->transmission) {
se_skb = j1939_session_skb_get(session);
if (!se_skb) {
if (net_ratelimit())
netdev_warn(session->priv->ndev, "%s: 0x%p: no skb found for completed session\n",
__func__, session);
session->err = EPROTO;
} else {
/* distribute among j1939 receivers */
j1939_sk_recv(session->priv, se_skb);
consume_skb(se_skb);
}
}
Other places in transport.c also set session->err without
active_session_list_lock. As far as I can see, no lock is needed here.
Please say in the commit message that this is only a mitigation. Then
the review bots should not ask for the protocol checks in this patch.
Something like this:
can: j1939: do not pass a NULL skb to the socket layer
Check for a NULL skb in j1939_session_completed() and end the session
with EPROTO, so that sockets reading the error queue get an RX abort.
Print a rate-limited warning, because a peer can cause the missing skb.
A peer can send an ETP DPO at or beyond the end of the message. When
the session completes after that, j1939_session_completed() finds no
skb and passes NULL to j1939_sk_recv(), which dereferences it.
This is only a mitigation, and it leaves the transport protocol alone
on purpose. The DPO is still not checked when it arrives, and no abort
frame is sent to the peer. These checks follow as a separate patch.
<how it was found and how you tested it>
Fixes: 9d71dd0c7009 ("can: add support of SAE J1939 protocol")
Cc: stable@vger.kernel.org
Several other people have sent fixes for the same crash.
Please send CAN patches only to linux-can and the CAN maintainers, not
to netdev.
pw-bot: cr
Regards,
Oleksij
next prev parent reply other threads:[~2026-11-29 16:02 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-24 18:17 [PATCH net v2] can: j1939: reject an out-of-range data packet offset Piyus Kedia
2026-11-28 19:27 ` netdev-bot+sashiko
2026-11-29 16:02 ` Oleksij Rempel [this message]
[not found] <sashiko-outbox-233959@kernel.org>
2026-11-26 15:03 ` Piyus Kedia
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=awxMr_bAtgqEwbrf@pengutronix.de \
--to=o.rempel@pengutronix.de \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=kapil@presceralabs.ai \
--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@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=piyus@iiitd.ac.in \
--cc=robin@protonic.nl \
--cc=socketcan@hartkopp.net \
--cc=stable@vger.kernel.org \
/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