[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <4806ef46-a162-4782-8c15-17e12ad88de7@gmail.com>
Date: Wed, 21 Feb 2024 08:24:40 +0100
From: Heiner Kallweit <hkallweit1@...il.com>
To: Andrew Lunn <andrew@...n.ch>,
Russell King - ARM Linux <linux@...linux.org.uk>,
Paolo Abeni <pabeni@...hat.com>, Jakub Kicinski <kuba@...nel.org>,
David Miller <davem@...emloft.net>, Eric Dumazet <edumazet@...gle.com>
Cc: "netdev@...r.kernel.org" <netdev@...r.kernel.org>
Subject: [PATCH net-next] 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.
Signed-off-by: Heiner Kallweit <hkallweit1@...il.com>
---
net/ethtool/ioctl.c | 7 -------
1 file changed, 7 deletions(-)
diff --git a/net/ethtool/ioctl.c b/net/ethtool/ioctl.c
index 1763e8b69..ff28c113b 100644
--- a/net/ethtool/ioctl.c
+++ b/net/ethtool/ioctl.c
@@ -1513,20 +1513,13 @@ static void eee_to_keee(struct ethtool_keee *keee,
{
memset(keee, 0, sizeof(*keee));
- keee->supported_u32 = eee->supported;
keee->advertised_u32 = eee->advertised;
- keee->lp_advertised_u32 = eee->lp_advertised;
- 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.43.2
Powered by blists - more mailing lists