linux-stable/net/ethtool
Julian Wiedmann 0276af2176 ethtool: ioctl: fix potential NULL deref in ethtool_set_coalesce()
ethtool_set_coalesce() now uses both the .get_coalesce() and
.set_coalesce() callbacks. But the check for their availability is
buggy, so changing the coalesce settings on a device where the driver
provides only _one_ of the callbacks results in a NULL pointer
dereference instead of an -EOPNOTSUPP.

Fix the condition so that the availability of both callbacks is
ensured. This also matches the netlink code.

Note that reproducing this requires some effort - it only affects the
legacy ioctl path, and needs a specific combination of driver options:
- have .get_coalesce() and .coalesce_supported but no
 .set_coalesce(), or
- have .set_coalesce() but no .get_coalesce(). Here eg. ethtool doesn't
  cause the crash as it first attempts to call ethtool_get_coalesce()
  and bails out on error.

Fixes: f3ccfda193 ("ethtool: extend coalesce setting uAPI with CQE mode")
Cc: Yufeng Mo <moyufeng@huawei.com>
Cc: Huazhong Tan <tanhuazhong@huawei.com>
Cc: Andrew Lunn <andrew@lunn.ch>
Cc: Heiner Kallweit <hkallweit1@gmail.com>
Signed-off-by: Julian Wiedmann <jwi@linux.ibm.com>
Link: https://lore.kernel.org/r/20211126175543.28000-1-jwi@linux.ibm.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2021-11-26 11:17:47 -08:00
..
Makefile ethtool: Add ability to control transceiver modules' power mode 2021-10-06 17:47:49 -07:00
bitset.c ethtool: fix stack overflow in ethnl_parse_bitset() 2020-12-09 15:50:38 -08:00
bitset.h ethtool: add ethnl_parse_bitset() helper 2020-03-12 15:32:32 -07:00
cabletest.c ethtool: link up ethnl_header_policy as a nested policy 2020-10-06 06:25:55 -07:00
channels.c ethtool: fix the check logic of at least one channel for RX/TX 2021-02-28 11:49:07 -08:00
coalesce.c ethtool: extend coalesce setting uAPI with CQE mode 2021-08-24 07:38:29 -07:00
common.c net: sock: extend SO_TIMESTAMPING for PHC binding 2021-07-01 13:08:18 -07:00
common.h net: ethtool: Export helpers for getting EEPROM info 2021-04-11 16:34:56 -07:00
debug.c ethtool: link up ethnl_header_policy as a nested policy 2020-10-06 06:25:55 -07:00
eee.c ethtool: fix incorrect datatype in set_eee ops 2021-04-06 16:42:25 -07:00
eeprom.c ethtool: Validate module EEPROM offset as part of policy 2021-06-22 10:40:54 -07:00
features.c ethtool: netlink: add missing netdev_features_change() call 2020-11-09 17:15:34 -08:00
fec.c ethtool: add FEC statistics 2021-04-15 17:08:29 -07:00
ioctl.c ethtool: ioctl: fix potential NULL deref in ethtool_set_coalesce() 2021-11-26 11:17:47 -08:00
linkinfo.c ethtool: link up ethnl_header_policy as a nested policy 2020-10-06 06:25:55 -07:00
linkmodes.c ethtool: Expose the number of lanes in use 2021-02-03 18:37:29 -08:00
linkstate.c ethtool: link up ethnl_header_policy as a nested policy 2020-10-06 06:25:55 -07:00
module.c ethtool: Add ability to control transceiver modules' power mode 2021-10-06 17:47:49 -07:00
netlink.c ethtool: Add ability to control transceiver modules' power mode 2021-10-06 17:47:49 -07:00
netlink.h ethtool: Add ability to control transceiver modules' power mode 2021-10-06 17:47:49 -07:00
pause.c ethtool: fix ethtool msg len calculation for pause stats 2021-11-03 11:20:45 +00:00
phc_vclocks.c ethtool: add a new command for getting PHC virtual clocks 2021-07-01 13:08:18 -07:00
privflags.c ethtool: link up ethnl_header_policy as a nested policy 2020-10-06 06:25:55 -07:00
rings.c ethtool: link up ethnl_header_policy as a nested policy 2020-10-06 06:25:55 -07:00
stats.c ethtool: stats: Fix a copy-paste error 2021-05-19 11:57:33 -07:00
strset.c ethtool: strset: fix message length calculation 2021-06-14 12:14:24 -07:00
tsinfo.c ethtool: link up ethnl_header_policy as a nested policy 2020-10-06 06:25:55 -07:00
tunnels.c ethtool: link up ethnl_header_policy as a nested policy 2020-10-06 06:25:55 -07:00
wol.c ethtool: link up ethnl_header_policy as a nested policy 2020-10-06 06:25:55 -07:00