WSL2-Linux-Kernel/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
bitset.h
cabletest.c
channels.c
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
debug.c
eee.c
eeprom.c ethtool: Validate module EEPROM offset as part of policy 2021-06-22 10:40:54 -07:00
features.c
fec.c
ioctl.c ethtool: ioctl: fix potential NULL deref in ethtool_set_coalesce() 2021-11-26 11:17:47 -08:00
linkinfo.c
linkmodes.c
linkstate.c
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
rings.c
stats.c
strset.c ethtool: strset: fix message length calculation 2021-06-14 12:14:24 -07:00
tsinfo.c
tunnels.c
wol.c