From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 541452EBDDE for ; Mon, 6 Jul 2026 22:58:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783378694; cv=none; b=UjYHFt5VtdkVkY5XZ+AsnjUSdtS+Nc0cutIzvsQHO46YZoUEAhKDkWh27j0BkEmCBp0rRxzaRdRX13LG9t+G/QZkIR7cUa+Hno6db3LOgz4j5bjR6s9wQnB1srMpsqPPbr4WIXu7r38wuKBZbScLXI23KRfYrlNHSujHlFbK9BU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783378694; c=relaxed/simple; bh=VNrwfRnG6HHsO3hjg/yGCGPpYRQdv3wgFypqga4fArY=; h=From:Subject:To:Cc:In-Reply-To:References:Content-Type:Date: Message-Id; b=gpktfbyFlH79gbVJnCIh5w+Y/eZ0nm2tZ1xB8onIu4D7q15m/yYK4WpujJmeDmM0lccjiIaSZxVMXEpEpVratJkvmZB9yA5p3ruKNJAUvdPnYvcZM0XwKw7qirym7vHNL3Gyu7dIMNlSiIBhIDT/EuBU0wtZry0q9EtjeQLIsiE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Xwtprn4x; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Xwtprn4x" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C3EC41F000E9; Mon, 6 Jul 2026 22:58:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1783378692; bh=fMpiJtTgb2ztSJBrzB8UJSn9JjbO6CrdCcMUEFklpt4=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=Xwtprn4xCJOyIi8SLBOIFL0PXY4CO+2UR2sWnF3z8+4GI8aEZ/1HPL595ipt7v4t2 0k1d6HGYBcJEq7aLySOLQ9zGr2JF8xVBOnvdDw8U8S5bD6fCTWrhZxbdrq/itHzgxm kOmMPN1uRzgXD9Z2VMWlcW5ICx1AOUeFywpwfMp5S4TPYJXQtCB4407CRZmsdjyzoj 7Wirra3eA4sP9OHpjJOokDtt+7AjGIBY0tgDgqwBbO/85qt3qP31YctKclcpfDh4sB I9Dc6FuI292hKyYdaJ+68vAobrs+BOSL/+3pZ2wNsiGuI102x0IRajF74dHFm1Wecd LoNBYgZ61dPzQ== From: sashiko-bot@kernel.org Subject: Re: [PATCH v4 2/3] j1939: fix implementation not handling holds correctly Reply-To: sashiko-reviews@lists.linux.dev To: =?utf-8?b?QWxleGFuZGVyIEjDtmx6bA==?= Cc: linux-can@vger.kernel.org, "Vincent Mailhol" , "Oliver Hartkopp" , "Marc Kleine-Budde" , "Oleksij Rempel" In-Reply-To: <20260706224548.100451-2-alexander.hoelzl@gmx.net> References: <20260706224548.100451-1-alexander.hoelzl@gmx.net> <20260706224548.100451-2-alexander.hoelzl@gmx.net> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Mon, 06 Jul 2026 22:58:11 +0000 Message-Id: <20260706225811.C3EC41F000E9@smtp.kernel.org> Precedence: bulk X-Mailing-List: linux-can@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Thank you for your contribution! Sashiko AI review found 1 potential issue(= s) to consider: Pre-existing issues: - [High] Unprotected concurrent access and modification of J1939 session st= ate variables (`pkt.tx`) between the RX softirq and the TX timer softirq, l= eading to potential silent data corruption. -- --- Patch [2]: [PATCH v4 2/3] j1939: fix implementation not handling holds = correctly --- commit eff7a7e71fc39cb6fe94b38a7c7c2264d3d9f7e4 Author: Alexander H=C3=B6lzl j1939: fix implementation not handling holds correctly This commit modifies the behavior of j1939_xtp_rx_cts_one to allow the handling of a hold message. It cancels the TX timer and sets the RX timeout properly while adding a check against requests of already transferred and acked packets. > diff --git a/net/can/j1939/transport.c b/net/can/j1939/transport.c > index 6f999b18bbca5..ae0dc0a0168aa 100644 > --- a/net/can/j1939/transport.c > +++ b/net/can/j1939/transport.c [ ... ] > @@ -1488,19 +1530,13 @@ j1939_xtp_rx_cts_one(struct j1939_session *sessio= n, struct sk_buff *skb) > /* TODO: do not set tx here, do it in txtimer */ > session->pkt.tx =3D session->pkt.tx_acked; [Severity: High] This is a pre-existing issue, but I have a question about the concurrent access to session->pkt.tx. Can modifying session->pkt.tx here in the RX softirq context race with readers in the TX timer softirq context? If the TX timer executes j1939_session_tx_dat() concurrently, it reads session->pkt.tx multiple times within its transmission loop without locking or READ_ONCE(): dat[0] =3D session->pkt.tx - session->pkt.dpo + 1; offset =3D (session->pkt.tx * 7) - se_skcb->offset; Because these softirqs can run concurrently on different CPUs, might the compiler reload session->pkt.tx between the two statements?=20 If the RX path overwrites pkt.tx in that microscopic window, could j1939_session_tx_dat() transmit a frame containing the payload data of one packet but the sequence number of another, leading to silent data corruption on the CAN network? > - session->last_cmd =3D dat[0]; > - if (dat[1]) { > - j1939_tp_set_rxtimeout(session, 1250); > - if (session->transmission) { > - if (session->pkt.tx_acked) > - j1939_sk_errqueue(session, > - J1939_ERRQUEUE_TX_SCHED); > - j1939_session_txtimer_cancel(session); > - j1939_tp_schedule_txtimer(session, 0); > - } > - } else { > - /* CTS(0) */ > - j1939_tp_set_rxtimeout(session, 550); > + j1939_tp_set_rxtimeout(session, 1250); > + if (session->transmission) { > + if (session->pkt.tx_acked) > + j1939_sk_errqueue(session, > + J1939_ERRQUEUE_TX_SCHED); > + j1939_session_txtimer_cancel(session); > + j1939_tp_schedule_txtimer(session, 0); > } > return; --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20260706224548.1004= 51-1-alexander.hoelzl@gmx.net?part=3D2