๐Ÿš€ go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #18103

Re: [net PATCH 3/6] fbnic: Cover all of the HW stats with the stats lock

#18103
From: netdev-bot+sashiko
Date: Tue, 17 Nov 2026 21:14
92 lines
11411 bytes
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 commit message and Fixes: tag describe a race that cannot
  happen at this commit.

--

fbnic: Cover all of the HW stats with the stats lock

This patch puts the fbnic MAC stats under hw_stats.lock. The lock is now
taken in the ethtool pause, eth-mac, eth-ctrl and rmon getters and in
fbnic_reset_hw_stats(), and the ASSERT_RTNL() is gone. It also drops
rtnl_lock() from the PCIe stats debugfs read.

> That is no
> longer the case. ethtool only takes RTNL on the Netlink path for the
> operations a driver lists in op_needs_rtnl, and fbnic lists only the
> pause getter among the stats ones, so the eth-mac, eth-ctrl and rmon
> getters update the MAC stats with only the netdev instance lock held,
> racing each other and the reset.

[ ... ]

> Fixes: 45079e00133e ("net: ethtool: optionally skip rtnl_lock on Netlink path for GET ops")

[Severity: Medium]
Can the race described here actually happen at this commit?

fbnic is ops-locked. fbnic_netdev_alloc() sets queue_mgmt_ops
unconditionally:

    netdev->queue_mgmt_ops = &fbnic_queue_mgmt_ops;

That makes netdev_need_ops_lock() true, so netdev_lock_ops() really takes
netdev->lock for this device.

ethnl_default_doit() takes that lock around prepare_data() whether or not
RTNL is needed:

    if (need_rtnl)
        rtnl_lock();
    netdev_lock_ops(req_info->dev);
    }
    ret = ops->prepare_data(req_info, reply_data, info);

The dump path does the same, and the notify path asserts the same lock.
The only core callers of the fbnic get_eth_mac_stats, get_eth_ctrl_stats,
get_rmon_stats and get_pause_stats callbacks are stats_prepare_data() and
pause_prepare_data(). So the getters are already serialized against each
other by the instance lock.

fbnic_reset_hw_stats() has two callers. fbnic_init_hw_stats() runs from
fbnic_probe() before the netdev is allocated or registered, so no ethtool
request can reach the device yet. __fbnic_pm_attach() holds the same
instance lock around the reset:

    rtnl_lock();
    netdev_lock(netdev);

    fbnic_reset_hw_stats(fbd);

Nothing else touches fbd->hw_stats.mac or calls the fbd->mac->get_*_stats
callbacks.

After 45079e00133e, the old comment and ASSERT_RTNL() in
fbnic_reset_hw_stats() were out of date. But netdev->lock still seems to
serialize every path that touches the MAC stats.

The locking change itself looks fine as a consistency cleanup. Later in
this series the reset moves into __fbnic_pm_resume() and runs under
hw_stats.lock only, without netdev_lock. That later change is what makes
the lock added here necessary.

Could the commit message say that the instance lock already serializes
these paths, and that this patch makes hw_stats.lock the single
protection to prepare for the later reset move? Could the Fixes: tag
also be dropped, or could the message name a path that actually reaches
the race? As written, the tag may lead to this being backported to
stable as a fix for a race that does not exist there.

-- 
Sashiko AI review ยท https://netdev-ai.bots.linux.dev/sashiko/#/patchset/179460241885.8819.7179935130629202331.stgit%40ahduyck-xeon-server.home.arpa
Technical Details
Message-ID: <179495006109.3136.9222422977894063290@kernel.org>
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-365614-linux-kernel-netdev=dewy.ru
References: <179460250360.8819.2203630667210523871.stgit@ahduyck-xeon-server.home.arpa>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-365614-linux-kernel-netdev=dewy.ru
From: netdev-bot+sashiko@kernel.org
Newsgroups: linux.kernel.netdev
Subject: Re: [net PATCH 3/6] fbnic: Cover all of the HW stats with the stats lock
Date: Tue, 17 Nov 2026 21:14:21 +0000
Organization: Usenet Network
Message-ID: <179495006109.3136.9222422977894063290@kernel.org>
References: <179460250360.8819.2203630667210523871.stgit@ahduyck-xeon-server.home.arpa>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="2428898"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:yJlITpdLMXsyc3OZUkRF9nMuXck= sha256:AJpStdqwHLCydoMcoIDDCfjp5nJupFr7IGVM6U08HtM=
	sha1:wfvgXQWbKZSDfVXIDOGMY3CxfmI= sha256:P3CMAHZsjh495FOxkSKwMcvAHZolvVG2PZlNOnlv60c=
List-ID: <netdev.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
	by mail.dewy.ru (Postfix) with ESMTP id 0359D115089; Wed, 18 Nov 2026 00:14:37 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.501
X-Spam-Status: No, score=-3.501 tagged_above=-9999 required=6.31
	tests=[DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1,
	DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MAILING_LIST_MULTI=-1,
	RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001]
	autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
	header.d=kernel.org
X-Received: from mail.dewy.ru ([127.0.0.1])
	by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id 0N1nL4EB6wY7;
	Wed, 18 Nov 2026 00:14:33 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.232.135.74; helo=sto.lore.kernel.org; envelope-from=netdev+bounces-365614-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org
X-Received: from sto.lore.kernel.org (sto.lore.kernel.org [172.232.135.74])
	by mail.dewy.ru (Postfix) with ESMTPS id 0B3D8115085; Wed, 18 Nov 2026 00:14:24 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by sto.lore.kernel.org (Postfix) with ESMTP id BA0F2616154; Tue, 17 Nov 2026 21:14:23 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
	t=1794950063;
	b=pqLWuPwzNGWhonLXAaZiQYoiXs91xkvJolJivY6rKpnAMUg8ZiWsndTQNfzYxEG1E6Yh
	 1YJUU1bB2ddw4bRsQkx/48YCxrKfhsgDUwXJj36sSbGRaJvI1hZSomuxfs3g/OZWnItzj
	 RkvGOX/dT647VOZrKbHgPRdBthZvrLQ893zTY8pIXS97LyYPuJ1tnhY8BBixiYAm3YdHN
	 GYOiKAlNYcRruOI/olivefYA0/jsCUWHm8ZOaNgSpf0bNS/6e0bLXeR4YZZWcN+ULOpdC
	 KDfXv347rDLvG50leXz9Gu//qpA9rLo2qdy2DGOk6b9F6cIrrs7lkrLOJsX8MQdcpkg==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1794950063;
	h=X-Original-To:Received:Received:DKIM-Signature:Subject:From:To:Cc:
	 Date:Message-ID:In-Reply-To:References:X-sashiko-severity:
	 Content-Type:Content-Transfer-Encoding:X-Mailing-List:List-Id:
	 List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner:
	 Precedence:MIME-Version;
	bh=SdPRRe+HXuGNV3z6Rw6BrKjM2bO4XfhywsJ6yCYXhJw=;
	b=K6El80fBf4E62c6n0yZsBFhQfc0C6B2b6nn0+eViPjAiWfI0tIKYDpifhSzRJ0oTK0C/
	 eXbAIUjwiVDt07sOV8ltNTEmBJ3QlOVfQBZ0DN5jkmywBBGiUsJl+I/4YyQrdHJKF4wsp
	 QwaVZoWSBpPTkcT6w2ba5jEF3dOX4fe5aactGdTXNd24euTrgOo6CzK9ieoqcKqLoz1j+
	 ilkxp6HWa0XO0JQS7doI7t0/EVBlt4XtLL4RfacuF7XtpKxp6E4DtKwDlSgRvndH5x9eX
	 XAdjnEK2hMtSke7RlYjtGQmXxuI1vJavxTzW0kItAG+8Cb2eMtCvQzyF/UvSfxZImwg==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=IrOU4LAu;
	arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id 22B26606A337;
	Tue, 17 Nov 2026 21:14:23 +0000 (UTC)
X-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=IrOU4LAu
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1794950062;
	b=cw2/oR7SHj0+ADRlxaivjR0dEzMuqOARPRlhSgd8bxVz4EgIrTMIS6xiUOHQ7EnZUVYS
	 pcCrwlTyt1RVaRCqEEpooQgRWj/aY8V5syNc+7nf9xZi66P31msf3O/Ji15AXWz0Gb5cY
	 /kW0dgmQmk3QyFvRLLV23PVqnmYZ2lW9AJ47MhFAh66K0TISPftyjlOaR4anSO8jSdUat
	 T6iZZqYryXKzAA9MDXxttjae2ELkU8n7nfNtq3ZysnVSyobUSMCWxjqz6ORVS/vmig8XT
	 hbLA4Hd69lcdRJ13GKtGjWZUmXkAT6AsDI3J/hfIA2AjOdDR0GLizRyWYEJuL01nEnw==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1794950062;
	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=SdPRRe+HXuGNV3z6Rw6BrKjM2bO4XfhywsJ6yCYXhJw=;
	b=qbjeRXrKbkTnhzIPJp2ZRQi7RTL7zlhQjQOeb8Y2Qbo7dS1SRS7XwqGm2qSqx81o3xqe
	 RH1+AduMezVIpXAnnxQ2HYbxvXWimQrWYPQO85RKou7KXlEfchS8MOcE0979UrEmgsL1t
	 q8KE8t261ycoHReX5zwZS81nhSW109jbYJHxX8jbQFUtj0Fr65dI3nL7IZnFzDGaqgTSv
	 gR+LL2fe9ZD+Kz8EJn94QZVmUsdMouxz9pWLmD/PyHQXQ7cQppHi4L9ZES3IdxpmjPxgY
	 JpO8MnlrUKFrw0ps5oCWphlMiK7AZDJqIDBTiRwZVuifyrUMk242wtVvik0SybrG8NA==
X-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=IrOU4LAu;
	arc=none smtp.remote-ip=100.103.45.18
X-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 45A7A606A32C
	for <netdev@vger.kernel.org>; Tue, 17 Nov 2026 21:14:22 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7D5551F000C4;
	Tue, 17 Nov 2026 21:14:21 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1794950062;
	bh=SdPRRe+HXuGNV3z6Rw6BrKjM2bO4XfhywsJ6yCYXhJw=;
	h=Subject:From:To:Cc:Date:In-Reply-To:References;
	b=IrOU4LAu3uOhwDADT/RlwMKStCrvK59zzrEn1Ju74GtJK79wyV+ZdECXjT6GGlQoC
	 DXfYg/2qu2Juuy6DTRooi5FZvgDN61AKx17rJVFpxMcD9a7oii9yjJ4FGKSucMHvXN
	 sxbRyKGuUp47mIlxsFhPNQz2v0ygjYY4g1JIx1t+ozIYqhZeDgi711XXgQ7BG2G5XB
	 QI9pI+e2GCV7sodfihiX2JinamFG/TkCzAlybv/D1bIW0ee8HavSLKi0LQjgz69Dm3
	 krIZvfdnPrGf9RBCDUuSXf7Sd43nFdeSE5az8Ld3NnGCqjh7EcOp9Ehy6QqSpRFbbQ
	 SYC/bxeO0cOwQ==
X-Cc: netdev@vger.kernel.org, andrew+netdev@lunn.ch, davem@davemloft.net,
 edumazet@google.com, horms@kernel.org, kernel-team@meta.com, kuba@kernel.org,
 pabeni@redhat.com
X-In-Reply-To: <179460250360.8819.2203630667210523871.stgit@ahduyck-xeon-server.home.arpa>
X-sashiko-severity: Medium
X-Mailing-List: netdev@vger.kernel.org
X-List-Post: <mailto:netdev@vger.kernel.org>
X-List-Help: <mailto:netdev+help@vger.kernel.org>
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:netdev+owner@vger.kernel.org>
X-Precedence: list