Skip to contentSkip to conversation

ethtool: ignore unused/unreliable fields in set_eee op

PATCH Applied Heiner Kallweit 3 participants 3 messages Mar 2, 2024 – Mar 6, 2024

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 ethtool: ignore unused/unreliable fields in set_eee op

This function is used with the set_eee() ethtool operation. Certain fields of struct ethtool_keee() are relevant only for the get_eee() operation. In addition, in case of the ioctl interface, we have no guarantee that userspace sends sane values in struct ethtool_eee. Therefore explicitly ignore all fields not needed for set_eee(). This protects from drivers trying to use unchecked and unreliable data, relying on specific userspace behavior.

Note: Such unsafe driver behavior has been found and fixed in the tg3 driver.

---
v2:
- rebased

---
 net/ethtool/ioctl.c | 5 -----
 1 file changed, 5 deletions(-)
net/ethtool/ioctl.c +0 -5
index 317308bdb..5a55270aa 100644
@@ -1514,17 +1514,12 @@ static void eee_to_keee(struct ethtool_keee *keee,
 {
 	memset(keee, 0, sizeof(*keee));
 
-	keee->eee_active = eee->eee_active;
 	keee->eee_enabled = eee->eee_enabled;
 	keee->tx_lpi_enabled = eee->tx_lpi_enabled;
 	keee->tx_lpi_timer = eee->tx_lpi_timer;
 
-	ethtool_convert_legacy_u32_to_link_mode(keee->supported,
-						eee->supported);
 	ethtool_convert_legacy_u32_to_link_mode(keee->advertised,
 						eee->advertised);
-	ethtool_convert_legacy_u32_to_link_mode(keee->lp_advertised,
-						eee->lp_advertised);
 }
 
 static void keee_to_eee(struct ethtool_eee *eee,
Signature · 1 line
2.44.0
maintainer Reviewed-by on v2 1/1
#1 lore raw
Quoted 8 lines · Heiner Kallweit

This function is used with the set_eee() ethtool operation. Certain fields of struct ethtool_keee() are relevant only for the get_eee() operation. In addition, in case of the ioctl interface, we have no guarantee that userspace sends sane values in struct ethtool_eee. Therefore explicitly ignore all fields not needed for set_eee(). This protects from drivers trying to use unchecked and unreliable data, relying on specific userspace behavior.

Quoted 4 lines

Note: Such unsafe driver behavior has been found and fixed in the tg3 driver.

Andrew

#2 lore raw
In reply to Heiner Kallweit
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 Sat, 2 Mar 2024 15:18:27 +0100 you wrote:

This function is used with the set_eee() ethtool operation. Certain fields of struct ethtool_keee() are relevant only for the get_eee() operation. In addition, in case of the ioctl interface, we have no guarantee that userspace sends sane values in struct ethtool_eee. Therefore explicitly ignore all fields not needed for set_eee(). This protects from drivers trying to use unchecked and unreliable data, relying on specific userspace behavior.

[...]

Here is the summary with links:
- [v2,net-next] ethtool: ignore unused/unreliable fields in set_eee op

    https://git.kernel.org/netdev/net-next/c/344f7a465149

You are awesome, thank you!

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