Skip to contentSkip to conversation

net: ethtool: correct MAX attribute value for stats

PATCH Applied Jakub Kicinski 3 participants 3 messages Jun 8, 2023 – Jun 12, 2023

Subsystems (3)
lore
Share & tools
lore

Jakub Kicinski

author maintainer
#0 lore raw

PATCH 1/1 net: ethtool: correct MAX attribute value for stats

When compiling YNL generated code compiler complains about array-initializer-out-of-bounds. Turns out the MAX value for STATS_GRP uses the value for STATS.

This may lead to random corruptions in user space (kernel itself doesn't use this value as it never parses stats).

Fixes f09ea6fb1272 ("ethtool: add a new command for reading standard stats")
---
 include/uapi/linux/ethtool_netlink.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/uapi/linux/ethtool_netlink.h +1 -1
index 1ebf8d455f07..73e2c10dc2cc 100644
@@ -783,7 +783,7 @@ enum {
 
 	/* add new constants above here */
 	__ETHTOOL_A_STATS_GRP_CNT,
-	ETHTOOL_A_STATS_GRP_MAX = (__ETHTOOL_A_STATS_CNT - 1)
+	ETHTOOL_A_STATS_GRP_MAX = (__ETHTOOL_A_STATS_GRP_CNT - 1)
 };
 
 enum {
Signature · 1 line
2.40.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 29 lines · Jakub Kicinski

When compiling YNL generated code compiler complains about array-initializer-out-of-bounds. Turns out the MAX value for STATS_GRP uses the value for STATS.

This may lead to random corruptions in user space (kernel itself doesn't use this value as it never parses stats).

Fixes f09ea6fb1272 ("ethtool: add a new command for reading standard stats")
---
 include/uapi/linux/ethtool_netlink.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/uapi/linux/ethtool_netlink.h +1 -1
index 1ebf8d455f07..73e2c10dc2cc 100644
@@ -783,7 +783,7 @@ enum {
 
 	/* add new constants above here */
 	__ETHTOOL_A_STATS_GRP_CNT,
-	ETHTOOL_A_STATS_GRP_MAX = (__ETHTOOL_A_STATS_CNT - 1)
+	ETHTOOL_A_STATS_GRP_MAX = (__ETHTOOL_A_STATS_GRP_CNT - 1)
 };
 
 enum {
Signature · 1 line
2.40.1
#2 lore raw
In reply to Jakub Kicinski
This patch was applied to netdev/net.git (main) by David S. Miller <[email protected]>:

Hello:

This patch was applied to netdev/net.git (main)
by David S. Miller <[email protected]>:

Quoted 8 lines · On Thu, 8 Jun 2023 09:23:44 -0700 you wrote:

When compiling YNL generated code compiler complains about array-initializer-out-of-bounds. Turns out the MAX value for STATS_GRP uses the value for STATS.

This may lead to random corruptions in user space (kernel itself doesn't use this value as it never parses stats).

[...]

Here is the summary with links:
- [net] net: ethtool: correct MAX attribute value for stats

    https://git.kernel.org/netdev/net/c/52f79609c0c5

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html