From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.216.54 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796009673; b=bKuA77ZuHTjAjHJrOj20XTuLi7eyN76U8Tf91WDr/nWx5TBa8EshTlX9/1ZT3b9MLksj Dw7RKiuj+3UH5Koofx+1IwAIjRvILx4KVGhjwOZMA2sQg4tPnbHB3I2fzNB50pzmykyxZ fRoCRW1bNrTKMvE7J1EKAgiJgiD91QXpLxPcmCK9i4FMlYnGW3XX0U21j5eBlCOG39DoP 47QNK1QuEs+DRcgPcqr0eduj34nMf70lTPcPQ5sJwCON6a691r+uJdbM1EkSfZP44fsnE e54AUdoGE0ur5ISKZawmeiYTM3oSMMK36ROoafHZejytDN04naIz4E2r9UgndGKDF/g== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796009673; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: From:To:Cc:Subject:Date:Message-Id:X-Mailer:In-Reply-To:References: MIME-Version:Content-Transfer-Encoding; bh=Ilbn/NecyyMgMji3899YvrLwVZRl3WgCEcOBiA0r7Ek=; b=oLoHpgZZj0ZT6mWEaPgK78S5/Zs5UC2PKjrleXeXhF1xGJz+RFnnZcAM7/mTxz35AVLp mCigkENSnkzSUMIlTpuRoDhoWMourNmbD1ama3j7O/YMSznwBLAVsmicncVYlDlLbI3hE 27b4EVSaDQvIBchu3YvCUa5nTso4pc6XSfYSoe+w0aFRbQ9BXrKT2tGokefO3bWO36Q0U gIVzj1BvSDX3cPNxOuqOiLkMcTH8rHS5JO1M3CVQro1PjS/P7ECx6WLpvKZd1llU+sW38 YX0Ssqdk+8rC7ew6oPbbNVJylj3GGV7JSlBWBR7n5mhmZCueXT7OVtyHvEfl6kQHZEA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none header.from=iiitd.ac.in; spf=pass smtp.mailfrom=iiitd.ac.in; dkim=pass header.d=iiitd.ac.in header.i=@iiitd.ac.in header.a=rsa-sha256 header.s=google header.b=dJKJ+hnX; arc=none smtp.remote-ip=209.85.216.54 Received: from mail-pj1-f54.google.com (mail-pj1-f54.google.com [209.85.216.54]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4C50E606A32A for ; Mon, 30 Nov 2026 03:34:33 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 4C50E606A32A Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=iiitd.ac.in Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=iiitd.ac.in Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=iiitd.ac.in header.i=@iiitd.ac.in header.a=rsa-sha256 header.s=google header.b=dJKJ+hnX Received: by mail-pj1-f54.google.com with SMTP id 98e67ed59e1d1-3b4021b572dso6096041a91.2 for ; Sun, 29 Nov 2026 19:34:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=iiitd.ac.in; s=google; t=1796009672; x=1796614472; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=Ilbn/NecyyMgMji3899YvrLwVZRl3WgCEcOBiA0r7Ek=; b=dJKJ+hnX1rd5MIJ3ZsgMCT6NpvL7bdTF9e8GyIdnnFPPEfKs7TFmpx4ZCiRFPWMtXy Zod2DuF6HblwvlJrB3t+J25h60hkVCop+EYHytG9D3jD+9f5QkHwYZsEyGr06eopwHmh sp/ryMNuXGNbPA880AV79tUdMlToyYEKyOwZw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796009672; x=1796614472; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=Ilbn/NecyyMgMji3899YvrLwVZRl3WgCEcOBiA0r7Ek=; b=q2P+0JpAOjP5u/Enh9AkdZsj8b2AQ1IdyPTrTn/DVzxqh7IK5AeHdFk4fgn5KJNKJw O3+ARoco5l2mKoKgLijl/b0DBN3w7pg8Ooj0hVZWKlkMuSG2N9vzolg7V4N4w7/raIBu Hc075e/PC+R+GTUebd3auaWddLN3356eNSVQ0vOl9jTg/Ijz/hQDZJ4ZFrAE8JCooYPO x/cdFALykK4dCqE/Us42ZuuTTZ57g7pXnib7aLJWuts1Jl0/HSv1UyEtFiV+agGRbSDZ hVIZdlRsTyDM8IXXe00tU4DnKAAJ5iElQyJWF5HCHbO1nbyuvOVP3wzvIJ0YlajTZHTZ y6NA== X-Forwarded-Encrypted: i=1; AL+hErFWWtS+zYl5UlG5IENOj350rknmhead0foGy5NMvByTZXIf/CDyNTsTOnAZfT+cLwbHh4JCQn1z4h6DQqs=@vger.kernel.org X-Gm-Message-State: APuU4Z8kkxrCHpN9fkfduiZZhFw8zp9GBgtjQsQcWOin3Q7f4saSrUYk 9wJx6PhKsw0COuSVcZgefG5uBxvkJNdhKvfbxxJ0CtGu424pez3OZsRjbfW2MSIG3KM= X-Gm-Gg: AZFdTZeeOrROIwcvRy/KZxlOk/ixpJDYZcqX+s6EdynXfN0FSPrYY9kYIaja2mxv7eJ d37hq0NzUy7VlbUK2l5TkAc8aoqWcKOEEGccoKPj3FUS4fJZFsxEqSyPtUk+eet8QlnRg+JgiIP IqusYuaYtUsqmhoUKTjdV4BXiGA4rfgqPSV115eXYNEFfsAURjF0GKiK/wNpTlnUK+XtG2kupaU o6fhEJzESszY/dTKR0Nq0P9fz8FMDrnC+h7eA3b4igsgckhQEsnbFOo588EyfCIhO3ilbmZVKGf 9hXK7ce1+6uAmseK9l4FtyUvjwJ/bAXNZ5xVWV0i/gCxmy53wskSQYCYFP2Al/E9W08rDIJhzah l0FXUdrxza0fdM9BFzFAGmkCpQr7wI5f/jFDX4gy7w5XTTfS7l2dfl0cmPgYrwFjv5zIaKe8oO5 PiWxQXaVBoKv7CE1g1mQc9yvmNrdlRwtCugWulF/aSZUfyHHVH6pyqfYTZW7UyqoW841phxGlgc h8OgO0BCNn9SWsWIvUV0NffLM5SgDxQSM3o+TR7H+WpxDqvAKgoLE8SoyKXyNSztXAJnVavO2h6 u/07LWFgvrw4Uq0CW98W8Lzxu/2/Dye3usqdp1gUswpTvunKFRAK14Kds15nIpdzXha1wP0dfjj jGWNRdEYCoIk1wZXDYmCUxv1FnBXipiJBaCS58T+zqqSgDWwuJH+9zYTXYlotWr4h X-Received: by 2002:a17:90b:4983:b0:3b0:97b8:d6b7 with SMTP id 98e67ed59e1d1-3b41c931d29mr33036975a91.42.1796009672517; Sun, 29 Nov 2026 19:34:32 -0800 (PST) Received: from iiitd-S2600STB.iiitd.edu.in ([103.25.231.160]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3b4b0f482bdsm34714519a91.14.2026.11.29.19.34.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 29 Nov 2026 19:34:31 -0800 (PST) From: Piyus Kedia To: Robin van der Gracht , Oleksij Rempel , Oliver Hartkopp , Marc Kleine-Budde , linux-can@vger.kernel.org Cc: kernel@pengutronix.de, linux-kernel@vger.kernel.org, Kapil Vaswani Subject: [PATCH net v4 1/2] can: j1939: do not pass a NULL skb to the socket layer Date: Mon, 30 Nov 2026 09:04:21 +0530 Message-Id: <20261130033422.2143435-2-piyus@iiitd.ac.in> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20261130033422.2143435-1-piyus@iiitd.ac.in> References: <20261130033422.2143435-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-Transfer-Encoding: 8bit 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 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 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. These checks follow as a separate patch. 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 Cc: stable@vger.kernel.org Co-developed-by: Kapil Vaswani Signed-off-by: Kapil Vaswani Signed-off-by: Piyus Kedia --- 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.34.1