Article View: linux.kernel.netdev
Article #24170Re: [PATCH net v2] can: j1939: reject an out-of-range data packet offset
From: Oleksij Rempel
Date: Sun, 29 Nov 2026 16:02
Date: Sun, 29 Nov 2026 16:02
68 lines
12678 bytes
12678 bytes
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
Technical Details
Message-ID:
<awxMr_bAtgqEwbrf@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-373559-linux-kernel-netdev=dewy.ruReferences:
<20261124181757.638280-1-piyus@iiitd.ac.in>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-373559-linux-kernel-netdev=dewy.ru From: o.rempel@pengutronix.de (Oleksij Rempel) Newsgroups: linux.kernel.netdev Subject: Re: [PATCH net v2] can: j1939: reject an out-of-range data packet offset Date: Sun, 29 Nov 2026 17:02:55 +0100 Organization: Usenet Network Message-ID: <awxMr_bAtgqEwbrf@pengutronix.de> References: <20261124181757.638280-1-piyus@iiitd.ac.in> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Injection-Info: usenet.network; logging-data="1203486"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:YTfc4mQB+bKTDzqKXY7LDTSFeDU= sha256:sEXmLAsfCmU5Q2fal+7+N089veaahyeBVR3fOLzSLXQ= sha1:BpaeDFsVM/PBRUoJ1DBz9r1mum0= sha256:vwUZrWybbYVnghxMhe3VzB/j2E9LyBMU1A1qb3ZyujI= Content-Disposition: inline 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 8321E125F99; Sun, 29 Nov 2026 19:03:12 +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 77O7iNmkZXy4; Sun, 29 Nov 2026 19:03:09 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-373559-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 sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10]) by mail.dewy.ru (Postfix) with ESMTPS id 57F15125F98; Sun, 29 Nov 2026 19:03:01 +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 E654123193; Sun, 29 Nov 2026 16:02:59 +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=1795968179; b=hAHkcK26pbUzuU5BgWXPOmOVySSCmuIjSweW+v4f6qJA1tf1UKyrhCujuiWEdIKjJLF5 M9Op7xYg1kb5WtomJANczNsB/DKD/hk/chIaqZQAWE6eHsg6ZnXL6IuDBOpIzJM/whekb ctmHzYYqpee7z85DYVc7nIXTHzoAKQGQ3PPLO5pdsc8nbchtOXSVfLwSvWeYn3yQeNwpL +LG7OTmk1O/hgXwSMGsDSq0Sf4SpKP/SKbs11t3GQIGhvGks1HutXYGJD75rf40oLMjvY q/UcXFfEiK3RFi1xJ+GIymNJG8J+ZwiXWQS8DzIUr9ZyY7vbeGlaUGtS7+j4QVkk0Lg== X-ARC-Message-Signature: i=3; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795968179; h=X-Original-To:Received:DMARC-Filter:Received:DKIM-Signature:Received: Date:From:To:Cc:Subject:Message-ID:References:X-Mailing-List:List-Id: List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner: Precedence:MIME-Version:Content-Type:Content-Disposition:In-Reply-To; bh=xaBi6Bsibk0T7M3xKxqKrMrwiApwcgdYEplW1OtGNMw=; b=CaIrZeGUFuu4Z6XvxP/2dijlWDiuW/XpTYHEiMLgspicESJzo3amSBRlUQ0uzijXihBI PO+cfEWfd8Re/Mp127fMvYgbSgC8109Uv81xQQPvAAS/HZGzSQgph8xeZzmXR0fRIUrc4 O7HtkRMRycOe+zwCGMAiqM/CqeLbO50XtMHuGDHU5v2ikzJoVykn9hmY+xwd02Kyq6UHe HNNNFjrsN4EnvM2NTZWMLCCmTC7ETRzYR9Xe6QdEKSzAYOtp4fO1tCvARLKbXIkWoPoor f+q4SSB2LND+FiEAEgBhgvK9Qt7ifQVC4GeYcGAvmVL/WU6+EUrQxTsbGoO5NBk+I+w== 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=LtwbAcEf; 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 BDA54606A32F; Sun, 29 Nov 2026 16:02:59 +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=LtwbAcEf 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=1795968178; b=zwFRjHC3a0KWtlxziPumv4uk2xzy4b5YbRPHatKrY4EIH21gNt2N/JkCeGr3ZZVUXPzk M//4RhS1+5j3pGoRNccNLENkn4oS/FU2hKLUJvc5+Q9PSUooXLISdTQahn+ZBgIxevbE2 E7I8Hyu9vTtqOEpWj2zvPoDjL8w94mdcOb9Inkz3OhenqhUgrtvB24rNfUJEQBQeeN2hj 5aeKxKENMpf7BzlN++3DlFgN9d9mqO9Iikm6mn0jx857iOk07wuj8D3Fjyyj+0qvdLLiI aqLBEKq2mJNqCYPsszFIekvhIafxLh05lph88zoHdkMdgklGqllDrg7/QIQrBjWXeTg== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795968178; h=DMARC-Filter:Received:DKIM-Signature:Received:Date:From:To:Cc: Subject:Message-ID:References:MIME-Version:Content-Type: Content-Disposition:In-Reply-To; bh=xaBi6Bsibk0T7M3xKxqKrMrwiApwcgdYEplW1OtGNMw=; b=MSPSjKHPqP5sRqf0llYKVIbOnLXX/lJmyQoMg+vingAOFjDIFPHSGfHCkIZ9RAxtFxqf UvQrf2H+XCXD9G0JrtUYfdvcMgNq7uF0e8yTZ6srzxTnmAyXuHRHmm0wESFj5ai2pscQf 8h3p9Lsy0/g+0Z/F0KzTMdMVXVOA2fgaYKI3a6fxLtnMEhaVQaCHX7XYxge1zbFq+TDUJ nXcWJabXLDEs0fpt2NxPjni6Ux0vnPDRqgjlVbnn26jgf/NiQxw4KF/cYB9VoR19PtJc2 u7/SOyPNqMQ4gHp68Vwnuzbnh1Vf4W0Qu+dMFMtzUC5IwgYkeTwoSObNZw/Z6x+Vicw== 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=LtwbAcEf; 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 E79C0606A31C; Sun, 29 Nov 2026 16:02:57 +0000 (UTC) X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org E79C0606A31C 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 ptx.office.stw.pengutronix.de (ptx.office.stw.4.pengutronix.de [10.9.0.3]) (Authenticated sender: relay-from-ptx.office.stw.pengutronix.de) by mx1.white.stw.pengutronix.de (Postfix) with ESMTPSA id CAAC62016CA; Sun, 29 Nov 2026 17:02:55 +0100 (CET) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pengutronix.de; s=20260414; t=1795968175; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=xaBi6Bsibk0T7M3xKxqKrMrwiApwcgdYEplW1OtGNMw=; b=LtwbAcEf6SrYBebAbBWxVf/mIkold4BR51pqPmiVx2OYr20p5dFZJR2aQOnzGollwXfGzQ Ro6BzTf+B+W/Jxa96eK3+w9Nf32iDEKUDBq8R6gmwq8TdgLMGUeCbjpHdaG43VwsfzOq+l tul7johXzA4nbVuOA0G9gBgwr8HlMiWDNAJG75Yug4GE/7zaeDxRwVPulODzBYGDKkaHOd byfU2Rkae0Tkd/zfMWtKpBiP878+l6D+v71H6pMGLhoCdJiHLkvH88zNMakf97Gj7wrGFX YO3nFhBd10RVWcoTzGXbec6YTRgBc7wWu26mQbAlOOS/KLIa7p9HbAvhfq4KIQ== X-ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=pengutronix.de; s=20260414; t=1795968175; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=xaBi6Bsibk0T7M3xKxqKrMrwiApwcgdYEplW1OtGNMw=; b=Z4BFFe+JzqjZFT06ySiAuxI0vNFoMGmiiNlY9r9J589//IDPbcVsW/OcpNwbVUBGPpg6GR rhD2CXxyXsKIFXE6lg24TSW8jBhv892aIeACtB46IaGeQ+s7MEampbRTPB2y45xmLDSIeh +LHilXKJfEmPdAEgtDEsCDgXjWJfeZRGHDo0WzbfxlNJFn8NETSspXoaaKEiqadjCL44Gg DfCK2/+7GnnKDqtOCpRO7uW+K5TOON9DzMJ0e9/4mRlFnTvGuODIvNHUAX/VT7T6pYgX9g jMfx91ri3JcK9BYOExBfvHFIaiDa4m6rMFvDEiLsIUq7V4dp1WNMIfp/HZVSXw== X-ARC-Authentication-Results: i=1; ORIGINATING; auth=pass smtp.auth=relay-from-ptx.office.stw.pengutronix.de smtp.mailfrom=ore@pengutronix.de X-ARC-Seal: i=1; s=20260414; d=pengutronix.de; t=1795968175; a=rsa-sha256; cv=none; b=R7MbbDU1SkRehX83Th0Zed3joX9rOWoyHloYhBYmKBacQxeOEqSx28CG7+3J0WLd+Fg0qg zgKXJJVAH8yXwj9PoQPznvzRGa6w0a1vUGth3ShcBhnehQ2qda+/R/Qb16lR0o+WFEeK+i vMUliMK/8RUTAlKqIMl0OgjO0RFVdUmtxWHN40PYPLhTkSNSaBg0Qb4Qp5Ic9jE/x3o0u4 2IF24b2YQ6Zw2oXDP6FZ//nuBom1nnK8S/YB/7tre2J7St/FUrr8yCSEjxrQHvVtTUlpqB 0dUwa0uLLwIuZHiPBGrr1UQqWFFLwoVPotCy6Y3sBwjIkiV0tIlGqta13dl+hw== X-Received: by ptx.office.stw.pengutronix.de (Postfix, from userid 1058) id B18991BF334; Sun, 29 Nov 2026 17:02:55 +0100 (CET) X-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 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 X-In-Reply-To: <20261124181757.638280-1-piyus@iiitd.ac.in>