net: ethtool: avoid OOB accesses in PAUSE_SET
Subsystems (3)
Jakub Kicinski
maintainerPATCH 1/1 net: ethtool: avoid OOB accesses in PAUSE_SET
We now reuse .parse_request() from GET on SET, so we need to make sure that the policies for both cover the attributes used for .parse_request(). genetlink will only allocate space in info->attrs for ARRAY_SIZE(policy).
---
CC: [email protected]
CC: [email protected]
--- net/ethtool/netlink.h | 2 +- net/ethtool/pause.c | 1 + 2 files changed, 2 insertions(+), 1 deletion(-)
net/ethtool/netlink.h +1 -1
@@ -467,7 +467,7 @@ extern const struct nla_policy ethnl_channels_set_policy[ETHTOOL_A_CHANNELS_COMBextern const struct nla_policy ethnl_coalesce_get_policy[ETHTOOL_A_COALESCE_HEADER +1 ];extern const struct nla_policy ethnl_coalesce_set_policy[ETHTOOL_A_COALESCE_MAX +1 ];extern const struct nla_policy ethnl_pause_get_policy[ETHTOOL_A_PAUSE_STATS_SRC +1 ]; -extern const struct nla_policy ethnl_pause_set_policy[ETHTOOL_A_PAUSE_TX +1 ]; +extern const struct nla_policy ethnl_pause_set_policy[ETHTOOL_A_PAUSE_STATS_SRC +1 ];extern const struct nla_policy ethnl_eee_get_policy[ETHTOOL_A_EEE_HEADER +1 ];extern const struct nla_policy ethnl_eee_set_policy[ETHTOOL_A_EEE_TX_LPI_TIMER +1 ];extern const struct nla_policy ethnl_tsinfo_get_policy[ETHTOOL_A_TSINFO_MAX +1 ];
net/ethtool/pause.c +1 -0
@@ -168,6 +168,7 @@ const struct nla_policy ethnl_pause_set_policy[] = { [ETHTOOL_A_PAUSE_AUTONEG] = { .type = NLA_U8 }, [ETHTOOL_A_PAUSE_RX] = { .type = NLA_U8 }, [ETHTOOL_A_PAUSE_TX] = { .type = NLA_U8 }, + [ETHTOOL_A_PAUSE_STATS_SRC] = { .type = NLA_REJECT }, }; static int
Signature · 1 line
2.50.0
Quoted 7 lines · Jakub Kicinski
We now reuse .parse_request() from GET on SET, so we need to make sure that the policies for both cover the attributes used for .parse_request(). genetlink will only allocate space in
info->attrsforARRAY_SIZE(policy).Reported-by [email protected]Fixes 963781bdfe20 ("net: ethtool: call .parse_request for SET handlers")Signed-off-by Jakub Kicinski <[email protected]>
Thanks, we hit that as well.
BTW, shouldn't you also release the reference from the net device if ethnl_default_parse() fails in ethnl_default_set_doit()?
Jakub Kicinski
maintainerQuoted 9 lines · On Sun, 29 Jun 2025 13:04:35 +0300 Ido Schimmel wrote:
Quoted 7 lines · Jakub Kicinski
We now reuse .parse_request() from GET on SET, so we need to make sure that the policies for both cover the attributes used for .parse_request(). genetlink will only allocate space in
info->attrsforARRAY_SIZE(policy).Reported-by [email protected]Fixes 963781bdfe20 ("net: ethtool: call .parse_request for SET handlers")Signed-off-by Jakub Kicinski <[email protected]>
Quoted 7 lines
Reviewed-by Ido Schimmel <[email protected]>Tested-by Ido Schimmel <[email protected]>Thanks, we hit that as well.
BTW, shouldn't you also release the reference from the net device if
ethnl_default_parse()fails inethnl_default_set_doit()?
Oof, good catch! Let me remove this trap of an API :S
This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Quoted 9 lines · On Thu, 26 Jun 2025 16:39:26 -0700 you wrote:
We now reuse .parse_request() from GET on SET, so we need to make sure that the policies for both cover the attributes used for .parse_request(). genetlink will only allocate space in
info->attrsforARRAY_SIZE(policy).Reported-by [email protected]Fixes 963781bdfe20 ("net: ethtool: call .parse_request for SET handlers")Signed-off-by Jakub Kicinski <[email protected]>[...]
Here is the summary with links:
- [net-next] net: ethtool: avoid OOB accesses in PAUSE_SET
https://git.kernel.org/netdev/net-next/c/99e3eb454cc4
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html