From: Andrew Lunn <andrew@lunn.ch>
To: YuanZhe Liu <25031212351@stu.xidian.edu.cn>
Cc: Jakub Kicinski <kuba@kernel.org>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@kernel.org>,
Paolo Abeni <pabeni@redhat.com>,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
Simon Horman <horms@kernel.org>, Bin Yu <byu@xidian.edu.cn>,
Cheng Wen <wencheng@xidian.edu.cn>
Subject: Re: [PATCH v4] net: ethtool: do not call get_regs() for zero-length dumps
Date: Sat, 28 Nov 2026 17:05:43 +0100 [thread overview]
Message-ID: <f08168f4-b76c-4147-a18d-1385b4955c0f@lunn.ch> (raw)
In-Reply-To: <20261127072348.5277-1-25031212351@stu.xidian.edu.cn>
On Fri, Nov 27, 2026 at 03:23:48PM +0800, YuanZhe Liu wrote:
> ethtool_get_regs() passes the user-supplied regs.len to the driver
> unchanged, including zero. A zero-length dump has nothing to fill in,
> but the driver callback still runs and may use that length for its own
> I/O. A zero-length transfer cannot move any data, and some transports
> report a warning for it, which becomes a denial of service when
> panic_on_warn is set.
>
> Return success without calling into the driver when the requested dump
> length is zero. The check comes after get_regs_len() so that drivers
> which cannot provide a dump still return their error to userspace:
> ethtool(8) sends a zero-length request when ETHTOOL_GDRVINFO reported
> no regdump_len, which is what happens when get_regs_len() fails.
>
> This does not remove a way to query the dump size: the uAPI tells users
> to obtain it from ETHTOOL_GDRVINFO.regdump_len, and the core only clamps
> an oversized regs.len down to get_regs_len(). Since a zero-length dump
> returns no data, the driver also cannot fill in regs.version; callers
> that need the version have to request the dump.
>
> The problem was found while testing the ethtool register dump path of
> an MCS7830 adapter.
>
> Co-developed-by: Bin Yu <byu@xidian.edu.cn>
> Signed-off-by: Bin Yu <byu@xidian.edu.cn>
> Co-developed-by: Cheng Wen <wencheng@xidian.edu.cn>
> Signed-off-by: Cheng Wen <wencheng@xidian.edu.cn>
> Signed-off-by: YuanZhe Liu <25031212351@stu.xidian.edu.cn>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Andrew
prev parent reply other threads:[~2026-11-28 16:05 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-27 7:23 YuanZhe Liu
2026-11-28 16:05 ` Andrew Lunn [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=f08168f4-b76c-4147-a18d-1385b4955c0f@lunn.ch \
--to=andrew@lunn.ch \
--cc=25031212351@stu.xidian.edu.cn \
--cc=byu@xidian.edu.cn \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=horms@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=wencheng@xidian.edu.cn \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®