summaryrefslogtreecommitdiffstats
path: root/net/core/rtnetlink.c
diff options
context:
space:
mode:
authorStanislav Fomichev <sdf@fomichev.me>2025-03-05 08:37:29 -0800
committerJakub Kicinski <kuba@kernel.org>2025-03-06 12:59:45 -0800
commitdf43d8bf10316a7c3b1e47e3cc0057a54df4a5b8 (patch)
treed31253686f41f2bdad50762ea5b86bf56cc7ad25 /net/core/rtnetlink.c
parent2bcf4772e45adb00649a4e9cbff14b08a144f9e3 (diff)
downloadlinux-df43d8bf10316a7c3b1e47e3cc0057a54df4a5b8.tar.gz
linux-df43d8bf10316a7c3b1e47e3cc0057a54df4a5b8.tar.bz2
linux-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 <sdf@fomichev.me> Link: https://patch.msgid.link/20250305163732.2766420-12-sdf@fomichev.me Signed-off-by: Jakub Kicinski <kuba@kernel.org>
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;