aboutsummaryrefslogtreecommitdiffstats
path: root/net/core/rtnetlink.c
diff options
context:
space:
mode:
authorStanislav Fomichev <[email protected]>2025-03-05 16:37:29 +0000
committerJakub Kicinski <[email protected]>2025-03-06 20:59:45 +0000
commitdf43d8bf10316a7c3b1e47e3cc0057a54df4a5b8 (patch)
treed31253686f41f2bdad50762ea5b86bf56cc7ad25 /net/core/rtnetlink.c
parentnet: ethtool: try to protect all callback with netdev instance lock (diff)
downloadkernel-df43d8bf10316a7c3b1e47e3cc0057a54df4a5b8.tar.gz
kernel-df43d8bf10316a7c3b1e47e3cc0057a54df4a5b8.zip
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 <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
Diffstat (limited to 'net/core/rtnetlink.c')
-rw-r--r--net/core/rtnetlink.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
index 9d539c9ce1a4..88a352b02bce 100644
--- a/net/core/rtnetlink.c
+++ b/net/core/rtnetlink.c
@@ -3089,7 +3089,11 @@ static int do_setlink(const struct sk_buff *skb, struct net_device *dev,
sa->sa_family = dev->type;
memcpy(sa->sa_data, nla_data(tb[IFLA_ADDRESS]),
dev->addr_len);
- err = netif_set_mac_address_user(dev, sa, extack);
+ if (!netdev_need_ops_lock(dev))
+ netdev_lock(dev);
+ err = netif_set_mac_address(dev, sa, extack);
+ if (!netdev_need_ops_lock(dev))
+ netdev_unlock(dev);
kfree(sa);
if (err)
goto errout;