net: replace dev_addr_sem with netdev instance lock

Lockdep reports possible circular dependency in [0]. Instead of
fixing the ordering, replace global dev_addr_sem with netdev
instance lock. Most of the paths that set/get mac are RTNL
protected. Two places where it's not, convert to explicit
locking:
- sysfs address_show
- dev_get_mac_address via dev_ioctl

0: https://netdev-3.bots.linux.dev/vmksft-forwarding-dbg/results/993321/24-router-bridge-1d-lag-sh/stderr

Signed-off-by: Stanislav Fomichev <sdf@fomichev.me>
Link: https://patch.msgid.link/20250305163732.2766420-12-sdf@fomichev.me
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
Stanislav Fomichev
2025-03-05 08:37:29 -08:00
committed by Jakub Kicinski
parent 2bcf4772e4
commit df43d8bf10
9 changed files with 41 additions and 56 deletions

View File

@@ -82,19 +82,6 @@ void dev_set_group(struct net_device *dev, int new_group)
netdev_unlock_ops(dev);
}
int dev_set_mac_address_user(struct net_device *dev, struct sockaddr *sa,
struct netlink_ext_ack *extack)
{
int ret;
netdev_lock_ops(dev);
ret = netif_set_mac_address_user(dev, sa, extack);
netdev_unlock_ops(dev);
return ret;
}
EXPORT_SYMBOL(dev_set_mac_address_user);
/**
* dev_change_net_namespace() - move device to different nethost namespace
* @dev: device
@@ -310,9 +297,9 @@ int dev_set_mac_address(struct net_device *dev, struct sockaddr *sa,
{
int ret;
netdev_lock_ops(dev);
netdev_lock(dev);
ret = netif_set_mac_address(dev, sa, extack);
netdev_unlock_ops(dev);
netdev_unlock(dev);
return ret;
}