mirror-linux/net/ethtool
Jakub Kicinski 67cfdd9210 ethtool: eeprom: add more safeties to EEPROM Netlink fallback
The Netlink fallback path for reading module EEPROM
(fallback_set_params()) validates that offset < eeprom_len,
but does not check that offset + length stays within eeprom_len.
The ioctl equivalent (ethtool_get_any_eeprom() in ioctl.c) has
always enforced both bounds:

  if (eeprom.offset + eeprom.len > total_len)
      return -EINVAL;

This could lead to surprises in both drivers and device FW.
Add the missing offset + length validation to fallback_set_params(),
mirroring the ioctl.

Similarly - ethtool core in general, and ethtool_get_any_eeprom()
in particular tries to zero-init all buffers passed to the drivers
to avoid any extra work of zeroing things out. eeprom_fallback()
uses a plain kmalloc(), change it to zalloc.

Fixes: 96d971e307 ("ethtool: Add fallback to get_module_eeprom from netlink command")
Reviewed-by: Maxime Chevallier <maxime.chevallier@bootlin.com>
Link: https://patch.msgid.link/20260526153533.2779187-11-kuba@kernel.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2026-05-27 17:42:09 -07:00
..
Makefile ethtool: netlink: add ETHTOOL_MSG_MSE_GET and wire up PHY MSE access 2025-11-03 18:32:27 -08:00
bitset.c ethtool: fix ethnl_bitmap32_not_zero() bit interval semantics 2026-05-12 18:45:13 -07:00
bitset.h net: ethtool: re-order local includes 2026-03-20 19:10:18 -07:00
cabletest.c net: ethtool: re-order local includes 2026-03-20 19:10:18 -07:00
channels.c net, ethtool: Disallow leased real rxqs to be resized 2026-04-09 18:21:46 -07:00
cmis.h ethtool: cmis: fix u16-to-u8 truncation of msleep_pre_rpl 2026-05-26 08:19:33 -07:00
cmis_cdb.c ethtool: cmis: require exact CDB reply length 2026-05-26 08:19:33 -07:00
cmis_fw_update.c ethtool: cmis: validate fw->size against start_cmd_payload_size 2026-05-26 08:19:33 -07:00
coalesce.c ethtool: coalesce: cap profile updates at NET_DIM_PARAMS_NUM_PROFILES 2026-05-27 17:42:07 -07:00
common.c ethtool: Add RSS indirection table resize helpers 2026-03-23 17:59:54 -07:00
common.h net: ethtool: add get_rx_ring_count callback to optimize RX ring queries 2025-09-18 07:07:37 -07:00
debug.c net: ethtool: re-order local includes 2026-03-20 19:10:18 -07:00
eee.c net: ethtool: re-order local includes 2026-03-20 19:10:18 -07:00
eeprom.c ethtool: eeprom: add more safeties to EEPROM Netlink fallback 2026-05-27 17:42:09 -07:00
features.c net: ethtool: re-order local includes 2026-03-20 19:10:18 -07:00
fec.c net: ethtool: re-order local includes 2026-03-20 19:10:18 -07:00
ioctl.c net, ethtool: Disallow leased real rxqs to be resized 2026-04-09 18:21:46 -07:00
linkinfo.c net: ethtool: re-order local includes 2026-03-20 19:10:18 -07:00
linkmodes.c net: ethtool: re-order local includes 2026-03-20 19:10:18 -07:00
linkstate.c ethtool: linkstate: fix unbalanced ethnl_ops_complete() on PHY lookup error 2026-05-27 17:42:08 -07:00
mm.c treewide, timers: Rename from_timer() to timer_container_of() 2025-06-08 09:07:37 +02:00
module.c ethtool: module: fix cleanup if socket used for flashing multiple devices 2026-05-26 08:19:32 -07:00
module_fw.h ethtool: Add ability to flash transceiver modules' firmware 2024-06-28 10:48:23 +01:00
mse.c net: ethtool: re-order local includes 2026-03-20 19:10:18 -07:00
netlink.c ethtool: module: fix cleanup if socket used for flashing multiple devices 2026-05-26 08:19:32 -07:00
netlink.h ethtool: module: fix cleanup if socket used for flashing multiple devices 2026-05-26 08:19:32 -07:00
pause.c net: ethtool: pass genl_info to the ethnl parse_request operation 2026-03-24 20:14:29 -07:00
phc_vclocks.c net: ethtool: re-order local includes 2026-03-20 19:10:18 -07:00
phy.c net: ethtool: phy: avoid NULL deref when PHY driver is unbound 2026-05-12 17:45:12 -07:00
plca.c net: ethtool: re-order local includes 2026-03-20 19:10:18 -07:00
privflags.c net: ethtool: re-order local includes 2026-03-20 19:10:18 -07:00
pse-pd.c ethtool: pse-pd: fix missing ethnl_ops_complete() 2026-05-27 17:42:08 -07:00
rings.c net: ethtool: re-order local includes 2026-03-20 19:10:18 -07:00
rss.c ethtool: rss: avoid device context leak on reply-build failure 2026-05-26 08:17:57 -07:00
stats.c net: ethtool: pass genl_info to the ethnl parse_request operation 2026-03-24 20:14:29 -07:00
strset.c ethtool: strset: fix header attribute index in ethnl_req_get_phydev() 2026-05-27 17:42:09 -07:00
ts.h net: ethtool: tsinfo: Enhance tsinfo to support several hwtstamp by net topology 2024-12-16 12:51:41 +00:00
tsconfig.c ethtool: tsconfig: fix missing ethnl_ops_complete() 2026-05-27 17:42:08 -07:00
tsinfo.c ethtool: tsinfo: don't pass ERR_PTR to genlmsg_cancel on prepare failure 2026-05-27 17:42:08 -07:00
tunnels.c genetlink: use attrs from struct genl_info 2023-08-15 15:00:45 -07:00
wol.c net: ethtool: re-order local includes 2026-03-20 19:10:18 -07:00