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=1796431319; b=uq2+pNIc+r0bBJWO4dy7Y/Cht6hatkFZfg4bbeStYDeg2a56umEMFVJE6xcuYRsgZSPz OLZggAnV3qwGuMmq8IC2xUYIBQ6XBTkmjT913TL7wWLUDrTd0ZRvpDVyEXRnUeciMjyhd +xkKhQvvbLpgIxW02MRfxFkRxQE2uouu6zMw/cpzx6U8a/RhmT7onSu39W/BEmA6qk53F GQAhuPcxGPmhnXYIYNisbFjYCGL5T6tyniQ0UZerwvBQkg7tBeN3yQ7T1uwKD0mxmHnsU ArJMnK49pYg8+RHc4VdD0tuQPl28LCvpvBkxiRVFKHyGmkRnIvZ20HprQt78aGGxW+Q== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796431319; 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=uQeUA2IeJ3V+b7Ygy/yv/eWTMT76Atve8UqweQu5/aY=; b=2JiA2CWPLchH1iXrr1L7yeT8v5yZDUzocfonp8hR9oERreJHNsfiADMO7L6LVfCLnjmS 1LGucJVeT2rds/72bMdWtep7lQR3anUdl9MAVIslu4tNaXlqJ4yBKhVcngN4HgCQBQ+0w wdnFj4MLyU+Swj5uFg75pDIaY5HLZg4h+GmUHs2iCTUADaR/tElsJIejfhLfqBt4UabiH EgWp09+0r5Bovh4AMlL2NwnlHaeTMiQTIMElJcQCIeDEPLVoHbnFI6b4e7hhhbzxDMxEK Ih29poqX9Up8H3UAHZpbHOb67Ve9w6IxWqz5sjLWLuvqgP5Lc7KYuaAkE+FiL6DQoEg== 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=jqk2cO8u; 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 B80E0606A330 for ; Sat, 5 Dec 2026 00:41:59 +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=jqk2cO8u Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0A54A1F0092B; Sat, 5 Dec 2026 00:41:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796431319; bh=uQeUA2IeJ3V+b7Ygy/yv/eWTMT76Atve8UqweQu5/aY=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=jqk2cO8uvyzoK/ZMVi6r509sMdScUQlC5XyT8XUt4xB/aBcp0GPG9fnagO3LmkkFW PalfjZLbejNgl+WD7L+vxPBTT4x9Xo8S0JAuFEngNhBwAOs5p2St+7qownnMQEenH0 1l+7A6XmLzfLl+LVMd6vhMbiBwS9zLMDiI1DLfMxv5ElDeniE2fN2R06/GT1Pom7y9 s8vlSMbLQzSjH7Rs3vyhpekEXO5jlKqu/goV9GFMqEGC5KglsNC7LD8FakzQcrDqKS ZWRo+GYlQhg4n0WqZHmfsNUHhMPiE8cNXXN7HPfo2YrwYz9YAN7m8Fu3zhaU7zggWQ s1luIE4z/ruYg== Subject: Re: [PATCH v2 1/2] can: vcan: use per-CPU stats to fix KCSAN data-race in vcan_tx From: netdev-bot+sashiko@kernel.org To: rameshsv06@gmail.com Cc: mkl@pengutronix.de, mailhol@kernel.org, linux-can@vger.kernel.org, rameshkumar.t@phytecembedded.in, kuba@kernel.org Date: Sat, 05 Dec 2026 00:41:58 +0000 Message-ID: <179643131859.3142.7946077821412216658@kernel.org> In-Reply-To: <20261203120559.421646-1-rameshsv06@gmail.com> References: <20261203120559.421646-1-rameshsv06@gmail.com> X-sashiko-severity: Medium 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 1 potential issue(s) to consider. Critical: 0 · High: 0 · Medium: 1 · Low: 0 If you believe none of the issues are legitimate, please reply to each issue of Medium severity or higher and explain why the AI is wrong. If any of them are legitimate and you plan to respin, please let patchwork know by including "pw-bot: cr" as a separate line at the end of your reply (one such reply per series is enough). - [Medium] The fix is incomplete: vcan_tx() still makes a plain, non- atomic dev->stats update. -- can: vcan: use per-CPU stats to fix KCSAN data-race in vcan_tx This patch converts vcan to NETDEV_PCPU_STAT_TSTATS. The plain dev->stats tx/rx packet and byte updates in vcan_tx() and vcan_rx() become dev_sw_netstats_tx_add() and dev_sw_netstats_rx_add() calls. Reporting goes through the core dev_get_tstats64() path, so the dev->stats.tx_dropped value from can_dropped_invalid_skb() still shows up in the totals. > diff --git a/drivers/net/can/vcan.c b/drivers/net/can/vcan.c > index 76e6b7b5c6a11..0108c674262ee 100644 > --- a/drivers/net/can/vcan.c > +++ b/drivers/net/can/vcan.c [ ... ] > @@ -93,8 +89,7 @@ static netdev_tx_t vcan_tx(struct sk_buff *skb, struct net_device *dev) > return NETDEV_TX_OK; > > len = can_skb_get_data_len(skb); > - stats->tx_packets++; > - stats->tx_bytes += len; > + dev_sw_netstats_tx_add(dev, 1, len); [Severity: Medium] Does this conversion fully close the KCSAN race in vcan_tx()? The return just above comes from the can_dropped_invalid_skb() check at the top of vcan_tx(). For an invalid frame, that helper still does a plain read-modify-write on dev->stats: drivers/net/can/dev/skb.c:can_dropped_invalid_skb() { ... inval_skb: dev_kfree_skb_any(skb); dev->stats.tx_dropped++; return true; } With NETDEV_PCPU_STAT_TSTATS set, the reader path is dev_get_stats()->dev_get_tstats64()->netdev_stats_to_stats64(s, &dev->stats). That reads the same fields with atomic_long_read(), and it can run on any CPU, for example from rtnetlink or /proc/net/dev. Can this still trigger a KCSAN report against the tx path? Two writers can also race here and lose tx_dropped increments. vcan has no ndo_select_queue, and rtnl_create_link() accepts IFLA_NUM_TX_QUEUES. So "ip link add type vcan numtxqueues N" lets vcan_tx() run on several CPUs at once under different txq locks. A CAP_NET_RAW sender can reach this path. One example is an AF_PACKET socket bound to vcan that sends a frame whose skb->protocol is not ETH_P_CAN, ETH_P_CANFD or ETH_P_CANXL, or whose length is wrong. Could can_dropped_invalid_skb() use DEV_STATS_INC(dev, tx_dropped)? If not, could the commit message say this counter is out of scope? Right now it only says: and dev->stats.tx_dropped updated by can_dropped_invalid_skb() is preserved. [ ... ] -- Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261203120559.421646-1-rameshsv06%40gmail.com