* [PATCH v2 net-next] ethtool: ignore unused/unreliable fields in set_eee op
@ 2024-03-02 14:18 Heiner Kallweit
2024-03-02 15:59 ` Andrew Lunn
2024-03-06 3:20 ` patchwork-bot+netdevbpf
0 siblings, 2 replies; 3+ messages in thread
From: Heiner Kallweit @ 2024-03-02 14:18 UTC (permalink / raw)
To: Andrew Lunn, Russell King - ARM Linux, Paolo Abeni,
Jakub Kicinski, David Miller, Eric Dumazet
Cc: netdev
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.
Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
---
v2:
- rebased
---
net/ethtool/ioctl.c | 5 -----
1 file changed, 5 deletions(-)
diff --git a/net/ethtool/ioctl.c b/net/ethtool/ioctl.c
index 317308bdb..5a55270aa 100644
--- a/net/ethtool/ioctl.c
+++ b/net/ethtool/ioctl.c
@@ -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,
--
2.44.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v2 net-next] ethtool: ignore unused/unreliable fields in set_eee op
2024-03-02 14:18 [PATCH v2 net-next] ethtool: ignore unused/unreliable fields in set_eee op Heiner Kallweit
@ 2024-03-02 15:59 ` Andrew Lunn
2024-03-06 3:20 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: Andrew Lunn @ 2024-03-02 15:59 UTC (permalink / raw)
To: Heiner Kallweit
Cc: Russell King - ARM Linux, Paolo Abeni, Jakub Kicinski,
David Miller, Eric Dumazet, netdev
On Sat, Mar 02, 2024 at 03:18:27PM +0100, Heiner Kallweit 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.
>
> Note: Such unsafe driver behavior has been found and fixed in the
> tg3 driver.
>
> Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Andrew
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v2 net-next] ethtool: ignore unused/unreliable fields in set_eee op
2024-03-02 14:18 [PATCH v2 net-next] ethtool: ignore unused/unreliable fields in set_eee op Heiner Kallweit
2024-03-02 15:59 ` Andrew Lunn
@ 2024-03-06 3:20 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2024-03-06 3:20 UTC (permalink / raw)
To: Heiner Kallweit; +Cc: andrew, linux, pabeni, kuba, davem, edumazet, netdev
Hello:
This patch was applied to netdev/net-next.git (main)
by Jakub Kicinski <kuba@kernel.org>:
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!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-03-06 3:20 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-03-02 14:18 [PATCH v2 net-next] ethtool: ignore unused/unreliable fields in set_eee op Heiner Kallweit
2024-03-02 15:59 ` Andrew Lunn
2024-03-06 3:20 ` patchwork-bot+netdevbpf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).