]> git.baikalelectronics.ru Git - kernel.git/commit
ethtool: don't drop the rtnl_lock half way thru the ioctl
authorJakub Kicinski <kuba@kernel.org>
Sat, 30 Oct 2021 17:18:51 +0000 (10:18 -0700)
committerDavid S. Miller <davem@davemloft.net>
Mon, 1 Nov 2021 13:26:07 +0000 (13:26 +0000)
commit99781dfb9b15c39c10d42b0abd414d3f67ce4711
treebd94424fa9d4bf6788edba77057a6822f3007d14
parente030055fd7e830902a37ac2c06006538302030ec
ethtool: don't drop the rtnl_lock half way thru the ioctl

devlink compat code needs to drop rtnl_lock to take
devlink->lock to ensure correct lock ordering.

This is problematic because we're not strictly guaranteed
that the netdev will not disappear after we re-lock.
It may open a possibility of nested ->begin / ->complete
calls.

Instead of calling into devlink under rtnl_lock take
a ref on the devlink instance and make the call after
we've dropped rtnl_lock.

We (continue to) assume that netdevs have an implicit
reference on the devlink returned from ndo_get_devlink_port

Note that ndo_get_devlink_port will now get called
under rtnl_lock. That should be fine since none of
the drivers seem to be taking serious locks inside
ndo_get_devlink_port.

Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Reviewed-by: Leon Romanovsky <leonro@nvidia.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/net/devlink.h
net/core/devlink.c
net/ethtool/ioctl.c