From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=185.203.200.13 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== 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== 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 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) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org E79C0606A31C Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=pengutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pengutronix.de 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 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) 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== 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== ARC-Authentication-Results: i=1; ORIGINATING; auth=pass smtp.auth=relay-from-ptx.office.stw.pengutronix.de smtp.mailfrom=ore@pengutronix.de 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== Received: by ptx.office.stw.pengutronix.de (Postfix, from userid 1058) id B18991BF334; Sun, 29 Nov 2026 17:02:55 +0100 (CET) Date: Sun, 29 Nov 2026 17:02:55 +0100 From: Oleksij Rempel To: Piyus Kedia Cc: Robin van der Gracht , Oliver Hartkopp , Marc Kleine-Budde , linux-can@vger.kernel.org, netdev@vger.kernel.org, kernel@pengutronix.de, linux-kernel@vger.kernel.org, Kapil Vaswani , 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 Message-ID: References: <20261124181757.638280-1-piyus@iiitd.ac.in> X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline 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. 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