Skip to content

Commit 5f672b1

Browse files
John J ColemanNipaLocal
John J Coleman
authored and
NipaLocal
committed
ethtool: check device is present when getting ioctl settings
An ioctl caller of SIOCETHTOOL ETHTOOL_GSET can provoke the legacy ethtool codepath on a non-present device, leading to kernel panic: [exception RIP: qed_get_current_link+0x11] kernel-patches#8 [ffffa2021d70f948] qede_get_link_ksettings at ffffffffc07bfa9a [qede] kernel-patches#9 [ffffa2021d70f9d0] __rh_call_get_link_ksettings at ffffffff9bad2723 kernel-patches#10 [ffffa2021d70fa30] ethtool_get_settings at ffffffff9bad29d0 kernel-patches#11 [ffffa2021d70fb18] __dev_ethtool at ffffffff9bad442b kernel-patches#12 [ffffa2021d70fc28] dev_ethtool at ffffffff9bad6db8 kernel-patches#13 [ffffa2021d70fc60] dev_ioctl at ffffffff9ba7a55c kernel-patches#14 [ffffa2021d70fc98] sock_do_ioctl at ffffffff9ba22a44 kernel-patches#15 [ffffa2021d70fd08] sock_ioctl at ffffffff9ba22d1c kernel-patches#16 [ffffa2021d70fd78] do_vfs_ioctl at ffffffff9b584cf4 Device is not present with no state bits set: crash> net_device.state ffff8fff95240000 state = 0x0, Existing patch commit a699781 ("ethtool: check device is present when getting link settings") fixes this in the modern sysfs reader's ksettings path. Fix this in the legacy ioctl path by checking for device presence as well. Fixes: 4bc71cb ("net: consolidate and fix ethtool_ops->get_settings calling") Fixes: 3f1ac7a ("net: ethtool: add new ETHTOOL_xLINKSETTINGS API") Fixes: 1da177e ("Linux-2.6.12-rc2") Tested-by: John J Coleman <[email protected]> Co-developed-by: Jamie Bainbridge <[email protected]> Signed-off-by: Jamie Bainbridge <[email protected]> Signed-off-by: John J Coleman <[email protected]> Signed-off-by: NipaLocal <nipa@local>
1 parent 8eab0f2 commit 5f672b1

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

net/ethtool/ioctl.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -659,6 +659,9 @@ static int ethtool_get_settings(struct net_device *dev, void __user *useraddr)
659659
int err;
660660

661661
ASSERT_RTNL();
662+
if (!netif_device_present(dev))
663+
return -ENODEV;
664+
662665
if (!dev->ethtool_ops->get_link_ksettings)
663666
return -EOPNOTSUPP;
664667

0 commit comments

Comments
 (0)