Article View: linux.kernel.netdev
Article #25342[PATCH net 2/3] can: j1939: do not pass a NULL skb to the socket layer
From: Marc Kleine-Budde
Date: Tue, 01 Dec 2026 14:46
Date: Tue, 01 Dec 2026 14:46
82 lines
13191 bytes
13191 bytes
From: Piyus Kedia <piyus@iiitd.ac.in>
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. The
dereference happens in the receive softirq, so it is fatal:
BUG: KASAN: null-ptr-deref in j1939_sk_recv+0xd4/0x3c0
Read of size 8 at addr 0000000000000018 by task repro/9528
<IRQ>
j1939_sk_recv+0xd4/0x3c0
j1939_xtp_rx_eoma+0x207/0x300
j1939_tp_recv+0x64c/0xa10
j1939_can_recv+0x51a/0x640
can_receive+0x19e/0x2a0
__netif_receive_skb+0x120/0x270
process_backlog+0x427/0xd50
net_rx_action+0x3f7/0x870
handle_softirqs+0x1e5/0x6a0
</IRQ>
netif_rx+0x89/0xa0
can_send+0x71f/0x7e0
raw_sendmsg+0x9ed/0xab0
Kernel panic - not syncing: Fatal exception in interrupt
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. Those checks need further changes in the
session code, so they follow as their own patch once this one is in.
Found by AI-driven fuzzing built on top of syzkaller; the analysis was
then checked by hand against the code. Measured on current net.git main
with KASAN and kasan_multi_shot=1, over one vcan pair, with the same
reproducer each time: without this patch the report above and the panic;
with it no report and no panic, and the new warning fires once per round
of the reproducer, so the path is still being reached and is now handled.
Fixes: 9d71dd0c7009 ("can: add support of SAE J1939 protocol")
Suggested-by: Oleksij Rempel <o.rempel@pengutronix.de>
Cc: stable@vger.kernel.org
Co-developed-by: Kapil Vaswani <kapil@presceralabs.ai>
Signed-off-by: Kapil Vaswani <kapil@presceralabs.ai>
Signed-off-by: Piyus Kedia <piyus@iiitd.ac.in>
Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
Link: https://patch.msgid.link/20261201-ore-j1939-fixes-2026-11-30-v1-1-a40cb7bf9569@pengutronix.de
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
net/can/j1939/transport.c | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)
diff --git a/net/can/j1939/transport.c b/net/can/j1939/transport.c
index 8fcfd13e5e6f..fa30273df326 100644
--- a/net/can/j1939/transport.c
+++ b/net/can/j1939/transport.c
@@ -1243,9 +1243,17 @@ static void j1939_session_completed(struct j1939_session *session)
if (!session->transmission) {
se_skb = j1939_session_skb_get(session);
- /* distribute among j1939 receivers */
- j1939_sk_recv(session->priv, se_skb);
- consume_skb(se_skb);
+ 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);
+ }
}
j1939_session_deactivate_activate_next(session);
--
2.53.0
Technical Details
Message-ID:
<20261201145025.2264811-3-mkl@pengutronix.de>Path:
mbox-mo1.pugleaf.net!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-375174-linux-kernel-netdev=dewy.ruReferences:
<20261201145025.2264811-1-mkl@pengutronix.de>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-375174-linux-kernel-netdev=dewy.ru From: mkl@pengutronix.de (Marc Kleine-Budde) Newsgroups: linux.kernel.netdev Subject: [PATCH net 2/3] can: j1939: do not pass a NULL skb to the socket layer Date: Tue, 1 Dec 2026 15:46:11 +0100 Organization: Usenet Network Message-ID: <20261201145025.2264811-3-mkl@pengutronix.de> References: <20261201145025.2264811-1-mkl@pengutronix.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="1740091"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:rrz9cT0E3H1JjDqeeVTTP5uH3L8= sha256:oxJ+KJnV5FDCrsn+/Zjr331Vj14hfjCSvWvjHDhR6Fc= sha1:F2tPPY+huyQw3tKu0fAKXqSzBLY= sha256:g9ByjHqLuM5wAAfoNgubrB5qyMVEmlfYg1s9Zu+cfKg= 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 CE4151173ED; Tue, 1 Dec 2026 17:51:02 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.05 X-Spam-Status: No, score=-3.05 tagged_above=-9999 required=6.31 tests=[DCC_REPUT_70_89=0.1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.249, 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=pengutronix.de 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 6jx7J9ybCLDK; Tue, 1 Dec 2026 17:50:59 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=104.64.211.4; helo=sin.lore.kernel.org; envelope-from=netdev+bounces-375174-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> X-Authentication-Results: OpenDMARC; dmarc=none (p=none dis=none) header.from=pengutronix.de X-Received: from sin.lore.kernel.org (sin.lore.kernel.org [104.64.211.4]) by mail.dewy.ru (Postfix) with ESMTPS id 007BB1173EF; Tue, 1 Dec 2026 17:50:50 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sin.lore.kernel.org (Postfix) with ESMTP id 5B01125715; Tue, 1 Dec 2026 14:50:45 +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=3; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1796136643; b=Kx2DPWuKbS0+LTwiv+a1Cx/HIS17NRm7SEHTxvDvbxR7pkTgwa4ASdpqioUmQHe/EnAx Oiy+U2tB6kqKlVwVZSgNMWzNx5eEdxaNrEujDWsK7QJo1iMKd04ju1maRxsQhFlDC+79Z NFI3r0jlbOajfH7tLnTLjnE5mM+Ge6LE54YmCDx+wpltoYYav7as81fQ1iTorrdDJg/wq aZMR4d8Yqw3mEmFaDmPlu+tJfM8nL1NgEBO44LCu4w6cjZqbbQ6lRPRNhzW8pzQ4NHidR r8JGcaIaUqxV/n/2RATAv86SVmUsF9EoJRKhF0SMnWKocMBDC6kTb9i+tYzzD9H1VhA== X-ARC-Message-Signature: i=3; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796136643; h=X-Original-To:Received:DMARC-Filter:Received:DKIM-Signature:From:To: Cc:Subject:Date:Message-ID:X-Mailer:In-Reply-To:References: X-Mailing-List:List-Id:List-Post:List-Help:List-Subscribe: List-Unsubscribe:List-Owner:Precedence:MIME-Version: Content-Transfer-Encoding; bh=OUA4BKiqhSAyLZX4qQoPVRjL56OjTfs+wlLFEUfI1qw=; b=OF+hR7C5VWaKgXASrT4+jYZ7A9as88egWnuYf8GtmDNsCd2OhdoIZ/xg5+dMjUpPx1fG L79ZRIrpA+esb0EbQRxr85S0hOSxXxjnKXLumYlWdSrfAeNlY1OYl56bUjfoIrZefsoVE gicmW95d0Lr6l4CnmwUG6RCD8V9QfduAu0LmWlQC3Y8lvyyv++EjcGKgx9+eU3mWyxepp MiTpl+e7CnPZxH7pSi8WbvhEz1/L+Y4F3WsH9BzkHK+YmrQiV3dTSJugIlooM4Yv891ww XzAVh8wDacYM+BesIvDR5FuKEDG5Sh80CFBwRtm2k8g5/N+nEoNhPY0WpOhjGVHtJMw== X-ARC-Authentication-Results: i=3; smtp.subspace.kernel.org; dkim=pass header.d=pengutronix.de header.i=@pengutronix.de header.a=rsa-sha256 header.s=20260414 header.b=QVnv09gT; dmarc=none header.from=pengutronix.de; spf=pass smtp.mailfrom=pengutronix.de; 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 52E94606A330; Tue, 1 Dec 2026 14:50:43 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=pengutronix.de header.i=@pengutronix.de header.a=rsa-sha256 header.s=20260414 header.b=QVnv09gT X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=185.203.200.13 X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1796136642; b=Lu0K2OczK+74ZUVEqV7xOAlK1VyX62Ue6HljrKdjVFh60aUy3N73M5BjEPtwoziLmT1J kQEZLaTOZq5kDjvqTNNknU+RA5McOcjqZcKAzbWXJewPzmjUOC+Bji1oC9dwq+109s74v 1vCSzJ4j3qg3bS1GUO50g0+hUTE49zLvpdOytFa3Ls99tkaQgIgzO72cm6FESCydXblzl JX/u9hdKu7djGrqgxJifPqPKUkLQQG0d5QTJk9DtFw1hI3u9KAr3RMz6aLZ121bqsocO3 SxbKFbCaflvGC4dBV9SYulq7LFiI+j1smjFdv7OJqo4NYAo3FF9x7fY09xsi4lxQ31Q== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796136642; h=DMARC-Filter:Received:DKIM-Signature:From:To:Cc:Subject:Date: Message-ID:X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding; bh=OUA4BKiqhSAyLZX4qQoPVRjL56OjTfs+wlLFEUfI1qw=; b=jY1N28qdWA03XMxFOVu5BZE3HO1uSKPFeRmT1qvcUdUH06dSKETQ9hx7qYTQxvVcCNtw MOONepd/I73b8LmDd7S+QYmollwD5zmTNrXo8gnM+kTjpYVB8o3GpwumXhYhtK8TaP4Us /wEmw8+8vK560FBhz5cO1FxLwHbDqBmqmt2HXU6qJD9QHVc6CKYGRUUKo5UxivYukK+29 pNKbfOBo6NYTe3y0heB5RrgvGg/PsUYvC1eGDqxByTCX0DUA80cidIEcAuyjjHO+VB4Dc th1NM1nI6MyfltmkCwFDq6tJyoDjF+KIhbmGBliQFyWbQwGIJ60VqcD2tMGTbJrF6KQ== X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=none header.from=pengutronix.de; spf=pass smtp.mailfrom=pengutronix.de; dkim=pass header.d=pengutronix.de header.i=@pengutronix.de header.a=rsa-sha256 header.s=20260414 header.b=QVnv09gT; arc=pass header.oldest-pass=0 smtp.remote-ip=185.203.200.13 X-Received: from mx1.white.stw.pengutronix.de (mx1.white.stw.pengutronix.de [185.203.200.13]) (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 7D68D606A33F; Tue, 1 Dec 2026 14:50:41 +0000 (UTC) X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 7D68D606A33F X-Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=pengutronix.de X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pengutronix.de X-Received: from pengutronix.de (p20030102af17cb00c4330b233ae7cbb8.dip0.t-ipconnect.de [IPv6:2003:102:af17:cb00:c433:b23:3ae7:cbb8]) (Authenticated sender: mkl@pengutronix.de) by mx1.white.stw.pengutronix.de (Postfix) with ESMTPSA id A1D0220582F; Tue, 01 Dec 2026 15:50:35 +0100 (CET) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pengutronix.de; s=20260414; t=1796136635; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=OUA4BKiqhSAyLZX4qQoPVRjL56OjTfs+wlLFEUfI1qw=; b=QVnv09gTN8wqgd4gbQXjUtEY5sC2lwxjK46+IQTrh0nNrtpvEG0vJzCecMuyHD7XVSpiZ1 YDZQLfdXiTx7R+jSgV2S9RAzCNjmAE9BSak+dBqHoJwEode7RLL7gm8KveGutvj1FdraMZ JZAWiZBzhPOcLtNObqB51bWMo+fn+ERo894xuebL1vjepDwrhiOd0uQWXvdtaSxzNtYs01 ObHoGIvw3Px3k4nzjbHYetGlMPub64XgWJ2nN1QlJ/AddthoRkI4dq5NTwCfGjGCQ855ks LE1x+9JwxFQEq7CA668o+aDJU1St39o696NpwY67WL0bEqlGyQBT1UgeUTEkRQ== X-ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=pengutronix.de; s=20260414; t=1796136635; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=OUA4BKiqhSAyLZX4qQoPVRjL56OjTfs+wlLFEUfI1qw=; b=QRRHNa3WK+eFaYp7QuxSBAFYFiaFJz5wGIQBg18tnez/hBbgpLKHpLnlU0WsKBXFQHLrdL j0EXEIteK+7VfsG3ajVJcNPNHYOOAo/Lmfn9cjgLPTDpbiYLIOmkBb8zXILBNVUKf/EUV0 uxIpJBBFT7p7VI2upcNN7OcjbLb1/3jEFmY8qf0u8aUeUbmtawwtq2ZivYLjWJ8/hPvVCy 4fdbbhBO0hDGLr7U9B0tBtKKIxk36xZgTHWias0nK9gBrhTSK3vofszCihUAefYPUZIaqU z+HMvJue/boUuTQofa4if9fWZ7xXjA3z+y8CDLYwYKjWFnCMIWTukpU4cjYRkw== X-ARC-Authentication-Results: i=1; ORIGINATING; auth=pass smtp.auth=mkl@pengutronix.de smtp.mailfrom=mkl@pengutronix.de X-ARC-Seal: i=1; s=20260414; d=pengutronix.de; t=1796136635; a=rsa-sha256; cv=none; b=OumuFKoD+AGuXRpSpVEwaAK4A+3JY8j3cIe2fGLSy6Q2vGkvI2wtP7K01EAQ97tnA1Q0f9 Qy1gwun5hFBzBSo7yGz9zkWLYJj8jNoVhEj8T5sxtbtR41bYwbOOXPVPokGtPNyBmyHEeh i/Icj9wTmUJ79ohq6FAz/hCO+73NJ/sPNOz5tLEl7tI3xLYERJlqqLnsW/MMtVmYS+D7E9 gDesTftKoGsUYSmAFwAl250TPM8dK09fvs9QAl5aDWtw0+C9vt9QOTw17wL+yaOI3atxVg DIcIb3P/yWjeNrNeeyLNU6ajSFNo8VIqHZjdqAp6l6477PwGelhIxOZARlFapw== X-Cc: davem@davemloft.net, kuba@kernel.org, linux-can@vger.kernel.org, kernel@pengutronix.de, Piyus Kedia <piyus@iiitd.ac.in>, Oleksij Rempel <o.rempel@pengutronix.de>, stable@vger.kernel.org, Kapil Vaswani <kapil@presceralabs.ai>, Marc Kleine-Budde <mkl@pengutronix.de> X-Mailer: git-send-email 2.53.0 X-In-Reply-To: <20261201145025.2264811-1-mkl@pengutronix.de> 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