Re: [PATCH v2] net: ethtool: do not call get_regs() for zero-length dumps
From: YuanZhe Liu
Date: Thu Nov 26 2026 - 03:22:20 EST
On Thu, Nov 26, 2026 at 03:58:03AM +0100, Andrew Lunn wrote:
> Your commit message is focusing on USB too much. Very few Ethernet
> drivers are USB. Since you are modifying the core, you should make the
> commit message generic.
Agreed, v3 describes the ethtool side instead of the USB stack.
> Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
>
> Who does this bother?
The zero-length request itself is harmless, but it now trips the
direction check in the USB core and, in setups with panic_on_warn, turns
a privileged ETHTOOL_GREGS call into a kernel panic. That is the same
class of issue as the plusb fix (CVE-2023-52742), which also carried a
Fixes tag and a stable Cc, so I kept both.
> Some of the kAPIs consider passing 0 as being special. It is user
> space asking the kernel how big a buffer is needed to hold the full
> dump. The kernel sets the value in the structure and returns. User
> space then allocates a buffer of that size, and makes the request
> again.
>
> I don't know if this API actually does this. You need to look at the
> logic and decide. But by returning this early, if it did, you have
> broken that.
I checked. ETHTOOL_GREGS has no zero-length size query: the uAPI tells
users to get the dump size from ETHTOOL_GDRVINFO.regdump_len, ethtool(8)
does exactly that, and ethtool_get_regs() only clamps a too-large
regs.len down to get_regs_len(); with regs.len == 0 it does not fill in
a size. So the early return does not remove a size query; it only stops
asking the driver for a dump that cannot return any data.
v3 to follow separately.