Article View: linux.kernel.netdev
Article #23410Re: [PATCH v3] net: ethtool: do not call get_regs() for zero-length dumps
From: netdev-bot+sashiko
Date: Fri, 27 Nov 2026 08:30
Date: Fri, 27 Nov 2026 08:30
106 lines
11820 bytes
11820 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 patch adds an early `if (!regs.len) return 0;` in
ethtool_get_regs() (net/ethtool/ioctl.c:1782-1784).
--
net: ethtool: do not call get_regs() for zero-length dumps
This patch adds an early return in ethtool_get_regs() when the
user-supplied regs.len is zero, so the driver's get_regs() callback is
never called for zero-length dumps. The commit message says this does
not remove a way to query the dump size, because the size comes from
ETHTOOL_GDRVINFO.regdump_len.
> diff --git a/net/ethtool/ioctl.c b/net/ethtool/ioctl.c
> index 80b7930b3fe0d..e8af861ee5de3 100644
> --- a/net/ethtool/ioctl.c
> +++ b/net/ethtool/ioctl.c
> @@ -1779,6 +1779,10 @@ static int ethtool_get_regs(struct net_device *dev, char __user *useraddr)
> if (copy_from_user(®s, useraddr, sizeof(regs)))
> return -EFAULT;
>
> + /* A zero-length dump has nothing to fill in. */
> + if (!regs.len)
> + return 0;
> +
> reglen = ops->get_regs_len(dev);
> if (reglen <= 0)
> return reglen;
[Severity: Medium]
The early return sits before ops->get_regs_len() and its error check.
It also comes before the copy_to_user() of the struct ethtool_regs
header. For a request with len == 0, this seems to change
ETHTOOL_GREGS in a few ways userspace can see.
First, is a negative errno from get_regs_len() now reported as success?
ethtool_get_drvinfo() only fills in regdump_len when the driver
returns a positive length:
net/ethtool/ioctl.c:ethtool_get_drvinfo() {
...
if (ops->get_regs_len) {
int ret = ops->get_regs_len(dev);
if (ret > 0)
rsp->info.regdump_len = ret;
}
...
}
So when get_regs_len() fails, ethtool(8) sends GREGS with
len = regdump_len = 0. One example is bnxt_get_regs_len(), which does
this on a VF:
if (!BNXT_PF(bp))
return -EOPNOTSUPP;
Before this patch, "ethtool -d" on a bnxt VF failed with "Operation not
supported". With the early return, the ioctl succeeds and ethtool(8)
prints an empty dump. dsa_conduit_get_regs_len() passes on negative
errors from the conduit in the same way.
Second, the header is no longer written back for len == 0. Several
get_regs() implementations set regs->version, and some also overwrite
regs->len with the full dump size. lan743x_get_regs() is one:
regs->version = LAN743X_ETH_REG_VERSION;
regs->len = regs_len;
emac_get_regs(), axienet_ethtools_get_regs() and
dsa_conduit_get_regs() do something similar. mcs7830_get_regs(), the
driver named in the changelog, sets regs->version.
On those devices, a GREGS call with len == 0 used to return the
version and the full length in the header, because the data
copy_to_user() moved 0 bytes. Does that conflict with this part of
the commit message?
This does not remove a way to query the dump size: the
uAPI tells users to obtain it from ETHTOOL_GDRVINFO.regdump_len,
The struct ethtool_regs kernel-doc in include/uapi/linux/ethtool.h
also describes @version as a driver-supplied output, with no
exception for len == 0. The new comment says there is "nothing to fill
in", but the header still has fields to fill.
Could the zero-length check go after the get_regs_len() call and its
"reglen <= 0" check, so errors still reach userspace? Copying the
header back to userspace, or documenting the new behaviour in the uAPI
header, would cover the version and len cases. Since this is tagged for
stable, the commit message could also mention the change in behaviour.
--
Sashiko AI review ยท https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261126082748.2798-1-25031212351%40stu.xidian.edu.cn
Technical Details
Message-ID:
<179576824874.3135.15886004303093318921@kernel.org>Path:
mbox-mo1.pugleaf.net!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-372540-linux-kernel-netdev=dewy.ruReferences:
<20261126082748.2798-1-25031212351@stu.xidian.edu.cn>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-372540-linux-kernel-netdev=dewy.ru From: netdev-bot+sashiko@kernel.org Newsgroups: linux.kernel.netdev Subject: Re: [PATCH v3] net: ethtool: do not call get_regs() for zero-length dumps Date: Fri, 27 Nov 2026 08:30:48 +0000 Organization: Usenet Network Message-ID: <179576824874.3135.15886004303093318921@kernel.org> References: <20261126082748.2798-1-25031212351@stu.xidian.edu.cn> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="683754"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:hr+wIamNC+rVACCwPQxyTkKHFBg= sha256:Y27R8JE7dTEh2LPZMoXYZqIAB+8bOhVRHsAo3wpebXc= sha1:3vyq7KYNnlB5lv17rFU2PoFLkJU= sha256:BKuIFReb6EZuOyULv7fxO33DD7FgC3BvEdHbyT1Vnhs= 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 8B303125F28; Fri, 27 Nov 2026 11:31:22 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.401 X-Spam-Status: No, score=-3.401 tagged_above=-9999 required=6.31 tests=[DCC_REPUT_70_89=0.1, 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 tqdVSa8nhHy5; Fri, 27 Nov 2026 11:31:19 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=104.64.211.4; helo=sin.lore.kernel.org; envelope-from=netdev+bounces-372540-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 sin.lore.kernel.org (sin.lore.kernel.org [104.64.211.4]) by mail.dewy.ru (Postfix) with ESMTPS id 3ED29125F24; Fri, 27 Nov 2026 11:30:57 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sin.lore.kernel.org (Postfix) with ESMTP id 1071525ECC; Fri, 27 Nov 2026 08:30:53 +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=1795768251; b=5iIQCmcB7ZhU98xhI3mK4lnjU3e21FuN6ImiEZ2+M+tIoP1DhHtykVo2Am5wNC2Ra4vi BJI7vLqPY37EQx1dsaYt7OBTafPeznDjVgTsEdb8qlq3AMZsoB+hflq1x7y8IDindDxUb a6vkZL20CWrpCOBipyuBGmyD248K0AbanuuPlgANGGHKLa6Laz/6USHYvYCgQGg/0CWEk wEZ1VYfaqIpZzEbSyFzF7KQFKWSA5xPSSqynvaayrLFDQRPO2hdxgR8v8jTX7Pfj1bxXN iPG0qQwMsib9CsLOiQUy3nuUPvXZsQltG2iiwGzgyyaFUnwOlpiSWYgqXSukvWHMzZA== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795768251; 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=SKhezHpydXqIPJNJm+VGSWCrhsoJDu4hJDPwIDrJ9Lg=; b=u3haxNeYG3HbSX059gtctZKn4YfqRlsbKe+f1tOstFkQ/73OrevFXiCtnO27ocgVOlO/ 04+GL/7nnoQye+x8YBDWD+U5fuGkhdX0oJr2gjPI84+b+Brjq7EyVFReziVKA91GkMR01 ZIrMlzvmw86GBmECZVxOMCjNYnUidngqMrhJI5vsSKrcqbgv9CrWHrQTsddTTC2f1CZTZ 5zMAIE/7cNkCEYVu5KlSUFgG38hSXS4tWzXXP1FbLZRRqLHqeI+0WBh+sP/hjvPctkSMR VBOEvFa1ySp5/nGDqceyZwiR2kw5rurcJ/4DStGndySB8f3Gc1KI0Edd+rFYESnXQ8Q== 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=BTPx2S+E; 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 AA101606A323; Fri, 27 Nov 2026 08:30:51 +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=BTPx2S+E 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=1795768250; b=nN/IFeGaWvWFkYK/21cJ+qZopaKE4ADPLOI0SBnFerDrN6RIhXc8t1pddWz/90t24S/F pZHDoIc1hDC3ZgciWulZ8VOkNliN5VeDFVYbptFk5hA3DU3fSrd+l6tpILedxS0hd8hJh c3BaIe41nMg+KppAmCsU9y2eRAe8yVGP/Ic88XZw2fKIJuTYNFhQGnELsAALxx4L0O6qM 3F9Kykklhna4YXnebN5gXxlu1K5awkMUtF7k0//AvDa6VFc35HGZS151Q0LI45s5X0VZV C8wFtnQmMRBcwBjl6TTtysbtFDek86u7Nl2nosT4SpgpZ31wnNChrdG4rSbTnEp1rTQ== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795768250; 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=SKhezHpydXqIPJNJm+VGSWCrhsoJDu4hJDPwIDrJ9Lg=; b=T40KLIlT7LRUtM/8aTQ1MDYahBfEZ06vdnD66yf46j/jFIY3ZnmMV6m5ImVRAqtVqPNs ehoPcgMkYb4meOEsX0ywPMD34UmH/SnK6e/IdEeuLn1In3J9Vlyh2krwu6t5DL4th1zGj pn8F1jjRXtndmGxTXqIFij6t65IxuANEI+DkTNlUS56oG3HwILh6ebseGXQAwn6FmfjQb P1uDCtwfFUfJLSRp2jrhIYHJdS7kyJCsapia1qrLDdMXhsgGcWLkcSVGDuS12bWwjxoBX unngsZy0uejyzENO17XHOj4VxxVdEq/jAPOaPLpYupzeta+WHU70ao9E8g7e7NBrphA== 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=BTPx2S+E; 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 CA71A606A31E; Fri, 27 Nov 2026 08:30:50 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3922E1F000C1; Fri, 27 Nov 2026 08:30:49 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795768249; bh=SKhezHpydXqIPJNJm+VGSWCrhsoJDu4hJDPwIDrJ9Lg=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=BTPx2S+EGlZjm3KfcLpfIEgmE6e43JbEtkrOnX+whJH+UDx1OKqadCEs4PIcqpCEQ 3pStgyQzrCAFYdIDESQgPNVsXcDG5D0D60+XS2DzRr9vR4imD9m0uBYpf0cTDfnXfn TeiNSU5BEFUUq5eKuBrYeiO/xwRP5nNB8Jl84ZZ6WiADu4BroSQXZPRe6gD6+vDy4I BGwT2cRAKlUKsn08b6lLeyAwC3wwn4yVZQTIHBExi75gvmME0bBMt+MbTURY1YcAaM tBeO//vvYes9C4Ok52o4ZhXHL5ip0YH8v0bwvNU2bTdh5YZAe5elM++jHY9718xNI7 DfHo4vwJ6rDXA== X-Cc: andrew@lunn.ch, kuba@kernel.org, davem@davemloft.net, edumazet@kernel.org, pabeni@redhat.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org, horms@kernel.org, byu@xidian.edu.cn, wencheng@xidian.edu.cn X-In-Reply-To: <20261126082748.2798-1-25031212351@stu.xidian.edu.cn> 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