aboutsummaryrefslogtreecommitdiffstats
path: root/include/net/netdev_lock.h
diff options
context:
space:
mode:
authorJakub Kicinski <kuba@kernel.org>2025-04-15 20:04:47 -0700
committerJakub Kicinski <kuba@kernel.org>2025-04-17 18:55:14 -0700
commit22cbc1ee268b7ec0000848708944daa61c6e4909 (patch)
treed6c50fc047a853e866aea2b61ef0dfe735633609 /include/net/netdev_lock.h
parentnet/mlx5e: ethtool: Fix formatting of ptp_rq0_csum_complete_tail_slow (diff)
downloadlinux-22cbc1ee268b7ec0000848708944daa61c6e4909.tar.gz
linux-22cbc1ee268b7ec0000848708944daa61c6e4909.zip
netdev: fix the locking for netdev notifications
Kuniyuki reports that the assert for netdev lock fires when there are netdev event listeners (otherwise we skip the netlink event generation). Correct the locking when coming from the notifier. The NETDEV_XDP_FEAT_CHANGE notifier is already fully locked, it's the documentation that's incorrect. Fixes: 99e44f39a8f7 ("netdev: depend on netdev->lock for xdp features") Reported-by: syzkaller <syzkaller@googlegroups.com> Reported-by: Kuniyuki Iwashima <kuniyu@amazon.com> Link: https://lore.kernel.org/20250410171019.62128-1-kuniyu@amazon.com Acked-by: Stanislav Fomichev <sdf@fomichev.me> Link: https://patch.msgid.link/20250416030447.1077551-1-kuba@kernel.org Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Diffstat (limited to 'include/net/netdev_lock.h')
-rw-r--r--include/net/netdev_lock.h16
1 files changed, 16 insertions, 0 deletions
diff --git a/include/net/netdev_lock.h b/include/net/netdev_lock.h
index 5706835a660c..2a753813f849 100644
--- a/include/net/netdev_lock.h
+++ b/include/net/netdev_lock.h
@@ -48,6 +48,22 @@ static inline void netdev_unlock_ops(struct net_device *dev)
netdev_unlock(dev);
}
+static inline void netdev_lock_ops_to_full(struct net_device *dev)
+{
+ if (netdev_need_ops_lock(dev))
+ netdev_assert_locked(dev);
+ else
+ netdev_lock(dev);
+}
+
+static inline void netdev_unlock_full_to_ops(struct net_device *dev)
+{
+ if (netdev_need_ops_lock(dev))
+ netdev_assert_locked(dev);
+ else
+ netdev_unlock(dev);
+}
+
static inline void netdev_ops_assert_locked(const struct net_device *dev)
{
if (netdev_need_ops_lock(dev))