2
0
mirror of git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git synced 2025-09-04 20:19:47 +08:00
linux/net/ethtool
Maxime Chevallier 637399bf7e net: ethtool: netlink: Allow NULL nlattrs when getting a phy_device
ethnl_req_get_phydev() is used to lookup a phy_device, in the case an
ethtool netlink command targets a specific phydev within a netdev's
topology.

It takes as a parameter a const struct nlattr *header that's used for
error handling :

       if (!phydev) {
               NL_SET_ERR_MSG_ATTR(extack, header,
                                   "no phy matching phyindex");
               return ERR_PTR(-ENODEV);
       }

In the notify path after a ->set operation however, there's no request
attributes available.

The typical callsite for the above function looks like:

	phydev = ethnl_req_get_phydev(req_base, tb[ETHTOOL_A_XXX_HEADER],
				      info->extack);

So, when tb is NULL (such as in the ethnl notify path), we have a nice
crash.

It turns out that there's only the PLCA command that is in that case, as
the other phydev-specific commands don't have a notification.

This commit fixes the crash by passing the cmd index and the nlattr
array separately, allowing NULL-checking it directly inside the helper.

Fixes: c15e065b46 ("net: ethtool: Allow passing a phy index for some commands")
Signed-off-by: Maxime Chevallier <maxime.chevallier@bootlin.com>
Reviewed-by: Kory Maincent <kory.maincent@bootlin.com>
Reported-by: Parthiban Veerasooran <parthiban.veerasooran@microchip.com>
Link: https://patch.msgid.link/20250301141114.97204-1-maxime.chevallier@bootlin.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2025-03-04 17:12:01 -08:00
..
bitset.c ethtool: Fix wrong mod state in case of verbose and no_mask bitset 2024-12-04 18:54:43 -08:00
bitset.h ethtool: add ethnl_parse_bitset() helper 2020-03-12 15:32:32 -07:00
cabletest.c net: ethtool: netlink: Allow NULL nlattrs when getting a phy_device 2025-03-04 17:12:01 -08:00
channels.c ethtool: refactor checking max channels 2024-08-09 21:52:13 -07:00
cmis_cdb.c net: ethtool: Add support for writing firmware blocks using EPL payload 2024-10-13 18:02:50 +01:00
cmis_fw_update.c net: ethtool: Add support for writing firmware blocks using EPL payload 2024-10-13 18:02:50 +01:00
cmis.h net: ethtool: Add support for writing firmware blocks using EPL payload 2024-10-13 18:02:50 +01:00
coalesce.c net: ethtool: Fix the panic caused by dev being null when dumping coalesce 2024-07-01 13:43:50 +01:00
common.c net: ethtool: fix ioctl confusing drivers about desired HDS user config 2025-02-24 14:15:42 -08:00
common.h net: ethtool: fix ioctl confusing drivers about desired HDS user config 2025-02-24 14:15:42 -08:00
debug.c ethtool: netlink: always pass genl_info to .prepare_data 2023-08-15 15:01:03 -07:00
eee.c net: ethtool: eee: Remove legacy _u32 from keee 2024-02-28 12:18:05 +00:00
eeprom.c ethtool: move firmware flashing flag to struct ethtool_netdev_state 2024-07-04 15:45:15 -07:00
features.c ethtool: netlink: Add missing ethnl_ops_begin/complete 2024-01-18 13:21:06 +01:00
fec.c ethtool: netlink: always pass genl_info to .prepare_data 2023-08-15 15:01:03 -07:00
ioctl.c net: ethtool: fix ioctl confusing drivers about desired HDS user config 2025-02-24 14:15:42 -08:00
linkinfo.c Revert "net: ethtool: Avoid thousands of -Wflex-array-member-not-at-end warnings" 2024-11-18 18:52:11 -08:00
linkmodes.c Revert "net: ethtool: Avoid thousands of -Wflex-array-member-not-at-end warnings" 2024-11-18 18:52:11 -08:00
linkstate.c net: ethtool: netlink: Allow NULL nlattrs when getting a phy_device 2025-03-04 17:12:01 -08:00
Makefile net: ethtool: Add support for tsconfig command to get/set hwtstamp config 2024-12-16 12:51:41 +00:00
mm.c ethtool: netlink: always pass genl_info to .prepare_data 2023-08-15 15:01:03 -07:00
module_fw.h ethtool: Add ability to flash transceiver modules' firmware 2024-06-28 10:48:23 +01:00
module.c net: ethtool: Monotonically increase the message sequence number 2024-07-13 15:37:36 -07:00
netlink.c net: ethtool: netlink: Allow NULL nlattrs when getting a phy_device 2025-03-04 17:12:01 -08:00
netlink.h net: ethtool: netlink: Allow NULL nlattrs when getting a phy_device 2025-03-04 17:12:01 -08:00
pause.c ethtool: netlink: always pass genl_info to .prepare_data 2023-08-15 15:01:03 -07:00
phc_vclocks.c ethtool: netlink: always pass genl_info to .prepare_data 2023-08-15 15:01:03 -07:00
phy.c net: ethtool: netlink: Allow NULL nlattrs when getting a phy_device 2025-03-04 17:12:01 -08:00
plca.c net: ethtool: netlink: Allow NULL nlattrs when getting a phy_device 2025-03-04 17:12:01 -08:00
privflags.c ethtool: netlink: always pass genl_info to .prepare_data 2023-08-15 15:01:03 -07:00
pse-pd.c net: ethtool: netlink: Allow NULL nlattrs when getting a phy_device 2025-03-04 17:12:01 -08:00
rings.c net: ethtool: fix ioctl confusing drivers about desired HDS user config 2025-02-24 14:15:42 -08:00
rss.c ethtool: rss: fix hiding unsupported fields in dumps 2025-02-03 18:38:52 -08:00
stats.c net: ethtool: netlink: Allow NULL nlattrs when getting a phy_device 2025-03-04 17:12:01 -08:00
strset.c net: ethtool: netlink: Allow NULL nlattrs when getting a phy_device 2025-03-04 17:12:01 -08: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 net: ethtool: tsconfig: Fix netlink type of hwtstamp flags 2025-02-06 16:35:21 -08:00
tsinfo.c net: ethtool: ts: add separate counter for unconfirmed one-step TX timestamps 2025-01-17 20:01:09 -08:00
tunnels.c genetlink: use attrs from struct genl_info 2023-08-15 15:00:45 -07:00
wol.c net: move ethtool-related netdev state into its own struct 2024-06-28 18:53:17 -07:00