From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796307063; b=JeBibPECQ8tI4c+RhfrfTL8Hrh1MAC6GCC6IZuQRexRD+SVf1eXII5DOZ9Mu9M48PrBQ ZrkzBCBdVYxeGDi6D5FAwujx/OHdXyG8gWC7OU1y4CMGcA5ufgvk6ZMHX2KjAVITUKWS2 LuWoj1TMPpvN3o8AEvwoZZmTakclfd2wvttbhNMrgen96oAMowZzi35mIECu+/gmadelC arjagPlpBL8XkCVQDB+kxy30vT9CRh/cHhHwbtMdcyuiQIoc/4acQlUqHt9o3PJadSknK RPIdisjZEtPRI8Stu5TM8DsmQ2WScD/6KOU8IOp6yjq+L3T/iyoy9IemyaSSz1G/abg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796307063; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=CET4m7iYRmWvgMCWDN+pqxx4fgMDcokM998cSUXv7f0=; b=mPNFw3Fimx4rokisjiHsaKGZk8XUgjmZs63JGE6vowtL0DcY6dkrVETX/WBHSZ0ut6sf kioBd344ZFasvbv+NIB5n/SwJGc/yokrK9v6l4++gGUUMoovbnv5XkWCgoozuYovUW90w lQnahE3FcHo/O4Uz2kR5FK5cejr50n9tcyuUgR/515ssruEtBZR9/DL9h2xUaGX12mJCK kM44rGxlXi2IY1yX0ifduZL0w9yZdUbRx+al19xI08IDGN8EUxCY8WsAS8o9huH4D5JaK am3Y48so+I3gSly6i2jocJumEFuR61ECLwvOvZYHXA3+VLqqvmEcw/41wr0zWW/zGVQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=Mjg9pcNA; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (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 57C47606A322 for ; Thu, 3 Dec 2026 14:11:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=Mjg9pcNA Received: by smtp.kernel.org (Postfix) with ESMTPSA id C32B71F000C1; Thu, 3 Dec 2026 14:11:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796307063; bh=CET4m7iYRmWvgMCWDN+pqxx4fgMDcokM998cSUXv7f0=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=Mjg9pcNA5Pu3pKkJBDLGzEMdGfRELWwm0YMYkm8X93XK3I2m/MzqnRZCD83RUT5g4 AHI0WXY3P9C9VJwV5rQi5HfF/5XaWA3uaxY96JlrC+QZCRCx7XQ9B/yK8uFjjcc8B4 QZW5h8bCQmMd3jXaSgWs6QGQ8kbcXxsCPyca/Yjg+JsPH+BusPToMws3E7BtSynalv xQihueL43Po6PF9DdeTHiCNYnCc+MpH6Rz0CXxOfsngKHJKRDTE8qCBL9ejAJuY7gq 33hYKepqn8X8ykMPXAKy0wyWbqIO52Yi+8eSprvjWV3WGq16P3fyRe58AdZuidEmJ+ M+1y4fqnak0wA== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH can-next v5 08/24] can: isotp: add N_As timeout monitoring for SF/FF/CF Reply-To: sashiko-reviews@lists.linux.dev To: "Oliver Hartkopp" , linux-can@vger.kernel.org Cc: "Marc Kleine-Budde" , "Vincent Mailhol" , "Oleksij Rempel" In-Reply-To: <20261203-getsockopt-memcg-isotp-v5-8-bbe89b3d3b71@hartkopp.net> References: <20261203-getsockopt-memcg-isotp-v5-0-bbe89b3d3b71@hartkopp.net> <20261203-getsockopt-memcg-isotp-v5-8-bbe89b3d3b71@hartkopp.net> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Thu, 03 Dec 2026 14:11:02 +0000 X-Mailing-List: linux-can@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Thank you for your contribution! Sashiko AI review found 1 potential issue to consider: - [Medium] can: isotp: isotp_sendmsg() only cancels echotimer on can_send() error -- commit b37dcf6e7f04378576a9f03bcc246c557c97e4b0 Author: Oliver Hartkopp can: isotp: add N_As timeout monitoring for SF/FF/CF This commit monitors SF, FF, and CF transmissions with the 1 s N_As timeout using the local echo timer, starting the N_Bs flow control timeout when the FF echo arrives or cancelling both timers if an FC arrives first. > diff --git a/net/can/isotp.c b/net/can/isotp.c > index 2ef4cbc9962ea..368e50bd82fd7 100644 > --- a/net/can/isotp.c > +++ b/net/can/isotp.c [ ... ] > @@ -1330,7 +1339,7 @@ static int isotp_sendmsg(struct socket *sock, struc= t msghdr *msg, size_t size) > } > /* WAIT_FIRST_FC for standard FF, else stays ISOTP_SENDING */ > WRITE_ONCE(so->tx.state, new_state); > - hrtimer_start(tx_hrt, ktime_set(hrtimer_sec, 0), > + hrtimer_start(&so->echotimer, ktime_set(ISOTP_TIMEOUT, 0), > HRTIMER_MODE_REL_SOFT); > spin_unlock_bh(&so->rx_lock); > =20 > @@ -1357,7 +1366,7 @@ static int isotp_sendmsg(struct socket *sock, struc= t msghdr *msg, size_t size) > } > =20 > /* no transmission -> no timeout monitoring */ > - hrtimer_cancel(tx_hrt); > + hrtimer_cancel(&so->echotimer); > goto err_out_drop_locked; > } [Severity: Medium] Can this error path leave so->txtimer or so->txfrtimer armed or running when can_send() fails? Because isotp_sendmsg() publishes ISOTP_WAIT_FIRST_FC and drops so->rx_lock before calling can_send(), an incoming FC frame on so->rxid can race with a failing can_send(): CPU0 (isotp_sendmsg) CPU1 (softirq) WRITE_ONCE(so->tx.state, ISOTP_WAIT_FIRST_FC) hrtimer_start(&so->echotimer, ...) spin_unlock_bh(&so->rx_lock) can_send(skb, 1) /* fails */ isotp_rcv() -> isotp_rcv_fc() /* ISOTP_FC_WT arrives */ hrtimer_cancel(&so->echotimer) WRITE_ONCE(so->tx.state, ISOTP_WAIT_FC) hrtimer_start(&so->txtimer, ...) spin_lock_bh(&so->rx_lock) hrtimer_cancel(&so->echotimer) <-- so->txtimer left armed WRITE_ONCE(so->tx.state, ISOTP_IDLE) spin_unlock_bh(&so->rx_lock) Previously tx_hrt pointed to &so->txtimer in standard FF mode, so hrtimer_cancel(tx_hrt) drained it. Now an undrained so->txtimer that is already running can asynchronously set sk->sk_err =3D ECOMM and invoke sk_error_report() after isotp_sendmsg() has already returned the can_send() error. Similarly, if an ISOTP_FC_CTS frame arrives and triggers a CF echo that arms so->txfrtimer, the lock-free isotp_txfr_timer_handler() can re-arm so->echotimer or send a stray CF frame with a non-zero so->cfecho after isotp_sendmsg() returns failure. Jumping to err_event_drop instead would perform the same so->tx_gen check under so->rx_lock and drain so->txfrtimer, so->txtimer, and so->echotimer in order. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261203-getsockopt= -memcg-isotp-v5-0-bbe89b3d3b71@hartkopp.net?part=3D8