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=1796070310; b=Hmbat4/bOTYb11wji6nrRyLw0209hjjRIfKJr6acah2TkL+zV1N3eED4RE/yeqCbggWz gKYT47rhJHKJBlmnuYrdefhRJN1kWGtE3rZmt4SMlrDqxbGR/+dQtk+6kT90tAFluW1Iw v/0q4ZjtOuedv/XeVAULYGCJQKGyE4XWChxPfiZbP4CT1K06upfMiIa2+mGj51GLQhsiI FgAFU7PnrpyON249YCH7tQVz4GCP+yXXPgufXAitECx/o1a9YqCBNqFQ5VARRf7fYBIrt 2DhfKaOF+NU3mW+/RFAqsuYjd083WsT2+2iVLYOjPzPHzy9jfMUWdtklJNKbqc/dg2Q== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796070310; h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID: In-Reply-To:References:X-sashiko-severity:Content-Type: Content-Transfer-Encoding:MIME-Version; bh=m4fD3zTYxrABd0yjOeFl9s7me7+lpJqmQXwpm2Wlj/g=; b=gDeScKiys3yEI1Qbvw2glullCJwjqgo5QynCkkqkxjve/+tAH5Pv4s3oJEffyRhutrIy 5vNC+iHKpwUSADtG0dWgky3H71fDzcJxlUNSZlABlU1Q1yJCLqXUXgNJet9WByenKfmoe JpW38ANytvTpSC7c0QHE2IX+huv3RlUS/cytFbf98rtjVhb4GclMW5BOHurKG2A/iEbrS rvBQLoQAAA3WIwUZxe6QyFX15O3tj0fNu8OFkoS9EWj4YqbNSzDebVDahQigjbqfz0cDQ pqGYlSvrBvPmR0Mh57aA+6QS3t6NDZN+cHUMP2FIOtnXgkXuSrZD2xn0gta4r13ewqQ== 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=CAr3AXm8; 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 01639606A320 for ; Mon, 30 Nov 2026 20:25:09 +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=CAr3AXm8 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6F5AF1F000C1; Mon, 30 Nov 2026 20:25:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796070309; bh=m4fD3zTYxrABd0yjOeFl9s7me7+lpJqmQXwpm2Wlj/g=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=CAr3AXm8/CLK00czjek5EQloLbBJFsU8xaAxDW+hwaW8K707/pH7gfB2N8F0TAZeV cUFOf2stSWeTKbEr7TnreYcG6fS9l+bTgdhyiGdtpMgXyRmDQtOYLmlELnAhDTstCW XfZ2zDg5DNr5SpxTqzU5TaBT/pN1zP3eeHfasZoNFAJ87PIbagrsxBeuG6FvtinNti Iml8Tq0054Z3YEOIXbGGB0CZysesWFezZg+fSQdpZsx/9+dKFGVKCVj6OQ+PYHv5uZ noojpXNctHyWIq5zuT+/7ElezsIcerJl0suNBRsGati5W6WJ6UMxScyCjXo0XCIMsP Ym71Qu73BAx8w== Subject: Re: [PATCH can-next v2 16/22] can: isotp: rename rx_lock as it has become state machine lock From: netdev-bot+sashiko@kernel.org To: socketcan@hartkopp.net Cc: linux-can@vger.kernel.org, mkl@pengutronix.de, kuba@kernel.org Date: Mon, 30 Nov 2026 20:25:08 +0000 Message-ID: <179607030897.3142.5056120019122025022@kernel.org> In-Reply-To: <20261128-getsockopt-memcg-isotp-v2-16-034ba95e17a4@hartkopp.net> References: <20261128-getsockopt-memcg-isotp-v2-16-034ba95e17a4@hartkopp.net> X-sashiko-severity: Low Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit X-Mailing-List: linux-can@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Thank you for your contribution! Sashiko AI review found more severe issue(s) in other patches of this series. This mail is only an FYI, in case you want to address the nit picks below when you respin. Low priority / nit picks for your consideration: - [Low] This patch adds a comment in isotp_rcv() (net/can/isotp.c) saying that so->sm_lock "serializes the rx path with the claim of a transfer… -- can: isotp: rename rx_lock as it has become state machine lock This patch renames so->rx_lock to so->sm_lock in net/can/isotp.c. The commit message says the lock is now used as a full state machine lock. It also rewrites the locking comment in isotp_rcv() to list the paths the lock serializes against. > diff --git a/net/can/isotp.c b/net/can/isotp.c > index 0780a0ec98677..1590627e34bd8 100644 > --- a/net/can/isotp.c > +++ b/net/can/isotp.c [ ... ] > @@ -795,10 +795,11 @@ static void isotp_rcv(struct sk_buff *skb, void *data) > n_pci_type = cf->data[ae] & 0xF0; > > /* Make sure the state changes and data structures stay consistent at > - * CAN frame reception time. This locking is not needed in real world > - * use cases but the inconsistency can be triggered with syzkaller. > + * CAN frame reception time: so->sm_lock serializes the rx path with > + * the claim of a transfer in isotp_sendmsg(), with isotp_rcv_echo() > + * and with isotp_release(). > */ > - spin_lock(&so->rx_lock); > + spin_lock(&so->sm_lock); [Severity: Low] Is the isotp_release() part of this comment accurate? Together with the commit message's description of the lock as "a full state machine locking primitive", the comment suggests that the rx path is serialized against isotp_release(). In fact isotp_release() only holds sm_lock for the tx.state transition: net/can/isotp.c:isotp_release() { ... spin_lock_bh(&so->sm_lock); WRITE_ONCE(so->tx.state, ISOTP_SHUTDOWN); spin_unlock_bh(&so->sm_lock); WRITE_ONCE(so->rx.state, ISOTP_IDLE); ... } The CAN filters are unregistered later, under conf_lock. So isotp_rcv() can still be running on another CPU at this point. Under sm_lock, isotp_rcv()->isotp_rcv_ff() does: so->rx.sn = 1; WRITE_ONCE(so->rx.state, ISOTP_WAIT_DATA); and then arms rxtimer. That can overwrite the ISOTP_IDLE that isotp_release() wrote without holding the lock. isotp_rx_timer_handler() also reads and writes rx.state without sm_lock. isotp_rcv_cf() already notes this: /* isotp_rx_timer_handler() may have raced us for so->rx.state * while hrtimer_cancel() above waited for it to finish => recheck */ This has no visible effect at runtime today. Later in isotp_release(), synchronize_rcu() and hrtimer_cancel(&so->rxtimer) drain it before the socket is orphaned. The comment and the unlocked rx.state write in isotp_release() are unchanged at the end of the series, after "can: isotp: introduce CAN_ISOTP_MIN_TX_DL". Could the comment and the commit message be limited to the tx.state ISOTP_SHUTDOWN transition in isotp_release()? Otherwise a later change could rely on rx path serialization that isn't there. One example would be reordering synchronize_rcu() and the rxtimer cancel in isotp_release(). -- Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261128-getsockopt-memcg-isotp-v2-0-034ba95e17a4%40hartkopp.net