ethtool: ignore unused/unreliable fields in set_eee op
authorHeiner Kallweit <hkallweit1@gmail.com>
Sat, 2 Mar 2024 14:18:27 +0000 (15:18 +0100)
committerJakub Kicinski <kuba@kernel.org>
Wed, 6 Mar 2024 03:07:13 +0000 (19:07 -0800)
commit344f7a4651497ffc62166ec6318b33f79d71c3df
tree06554963f9cfd567f956107eda96c76e592b3ddd
parentff73f8344e58e7557819f92c88f289ffa6116be7
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@gmail.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Link: https://lore.kernel.org/r/ad7ee11e-eb7a-4975-9122-547e13a161d8@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
net/ethtool/ioctl.c