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=1796278533; b=E+qqLDmeQQIR5rMmbLzg0NxxQs3YOaQHKiH7kvoZ2ZNWr+BdSG57/rHq39ObUrReC3FH 4KIZMKFClnJyG/YOqI2CjGEYEuMyPpgDYGQl7SZ5z1t6mI+rUgsmRFc92kqDwPXEYBzPQ tQxWK2YPvy+xncH+TEe31q8WoO4dpzIbjav55iYYNlaC7pIZDfUlAEk96L+tHr+8YKMTj VpbE7ho+3UKdwFANM1aVSCG+CbPuVuiR525sOF1bTkDoLLnx7lG+SOgojodeRBalgRT/W 0JPEW/0yxg9Z/fnE/+W28pAaJTFDEKqu+AJUoRsA1NXaCwY5TtBh9ZwBpPfPhB4eX4w== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796278533; 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=Bu/1i0hkx/RqvczwfUNFgXdaVboi/1duaKZyzi8/BSo=; b=ZJv5WwBVa4tqkYCiczOE8bPSyNloZbIxHlmDAdv7Ib++LQ6+V0T+1eK1Z1yeM4IhfV/R rC6aZZG3zfuvb0q6vgHauLe0XBqvwFMFE0slgL9x+juZVk+qQsQL22AWFMEcHpk9n2/fU AruWDYo3K8r+6INd81qP0F9kjzELMq071Y0esmYFgBCX2oIsNBExIv9/kTpy39Kk1x9bs 1EMmqM02N5n4/2PTHdWPquIoQfws2payH5+KP9WOjJ9n0UYJeP8rXhPvJSxeqMe52ck8f KbXbjDFcmeOitIH95Hj2hRBBZWhDI+M34+VKGFiyMpnSwcAYV9SBub6KmbNk86IyjMQ== 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=CSNJ7YpP; 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 EBFE8606A322 for ; Thu, 3 Dec 2026 06:15:32 +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=CSNJ7YpP Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1CDCC1F00893; Thu, 3 Dec 2026 06:15:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796278532; bh=Bu/1i0hkx/RqvczwfUNFgXdaVboi/1duaKZyzi8/BSo=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=CSNJ7YpPfSReu9gNl8o15mD1R41gPctuZgSjwEa/24QsthsaK9gOdf+x7pA5kZZnz WMa0njUPCORsEmH2ysP8z09ZsJzDh4xneFgyPF/3JSWbkgpERv276FkxIKalD8KVWu nztVSu6CF46q0/7KdAFzpVBWRTko6Pq67dJJCIxPN3CQgr55XgAKVB55FflKF8Vfzm f1UGri2GpCna9yYW0ZT6lD3LYmzPAQYaKCnciMZg4Qva9V4oWAfhFuMh2QJknXLE09 c2xvB0PndvkfJkDGeYNaOdI4s/wgWUkbY+DgwdTWRGqd4e24DlSWSKBqF4VQ3jhkZv C4jJ57twVD+jg== Subject: Re: [PATCH can-next v4 17/23] 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, sashiko-bot@kernel.org, zihanx@nebusec.ai, o.rempel@pengutronix.de, yewentian395@gmail.com, kuba@kernel.org Date: Thu, 03 Dec 2026 06:15:31 +0000 Message-ID: <179627853164.3142.4785591419832350774@kernel.org> In-Reply-To: <20261201-getsockopt-memcg-isotp-v4-17-97261be8e38e@hartkopp.net> References: <20261201-getsockopt-memcg-isotp-v4-17-97261be8e38e@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's goal is to make the lock's name and comments match what it protects, and it only partly gets there. -- can: isotp: rename rx_lock as it has become state machine lock This commit renames the isotp_sock rx_lock spinlock to sm_lock, because it now does more than lock parts of the receive path. It also updates the comment in isotp_rcv() to list the paths the lock serializes against. > can: isotp: rename rx_lock as it has become state machine lock > > rx_lock has been used to lock some receive path functionalities. > With the latest changes the semantic has been extended as a full > state machine locking primitive so give it a proper name sm_lock. > diff --git a/net/can/isotp.c b/net/can/isotp.c > index d556f4152f07f..1d89dc7f64049 100644 > --- a/net/can/isotp.c > +++ b/net/can/isotp.c > @@ -181,7 +181,7 @@ struct isotp_sock { > struct tpcon rx, tx; > struct list_head notifier; > wait_queue_head_t wait; > - spinlock_t rx_lock; /* protect single thread state machine */ > + spinlock_t sm_lock; /* protect single thread state machine */ [Severity: Low] This isn't a bug, but are the new name, the unchanged field comment and the "full state machine locking primitive" wording in the commit message accurate? Several state machine transitions still happen without sm_lock. isotp_rx_timer_handler() resets rx.state without the lock: if (READ_ONCE(so->rx.state) == ISOTP_WAIT_DATA) { ... WRITE_ONCE(so->rx.state, ISOTP_IDLE); } isotp_tx_timeout(), which the txtimer and echotimer callbacks share, moves tx.state with cmpxchg() and is documented as "must stay lock-free". isotp_txfr_timer_handler()->isotp_send_cframe() updates the tx context without the lock: cf->data[ae] = N_PCI_CF | so->tx.sn++; so->tx.sn %= 16; so->tx.bs++; ... WRITE_ONCE(so->cfecho, csx->can_skb_uid); It also changes tx.idx through isotp_fill_dataframe(). isotp_release() also writes rx.state after it drops the lock: spin_unlock_bh(&so->sm_lock); WRITE_ONCE(so->rx.state, ISOTP_IDLE); isotp_sendmsg() and isotp_rcv_echo() call hrtimer_cancel() on these timers while holding sm_lock. The timer callbacks therefore can never take sm_lock without deadlocking against the canceller. The new comment in isotp_rcv() lists the real serialization partners. Could the field comment do the same, and also say that the hrtimer callbacks run lock-free and must not take sm_lock? > struct mutex conf_lock; /* protects bind and sockopts */ > }; > [ ... ] -- Sashiko AI review ยท https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261201-getsockopt-memcg-isotp-v4-0-97261be8e38e%40hartkopp.net