ipv4: ip_tunnel: spread netdev_lockdep_set_classes()
Subsystems (3)
PATCH 1/1 ipv4: ip_tunnel: spread netdev_lockdep_set_classes()
Inspired by yet another syzbot report.
IPv6 tunnels call netdev_lockdep_set_classes() for each tunnel type, while IPv4 currently centralizes netdev_lockdep_set_classes() call from ip_tunnel_init().
Make ip_tunnel_init() a macro, so that we have different lockdep classes per tunnel type.
--- include/net/ip_tunnels.h | 13 ++++++++++++- net/ipv4/ip_tunnel.c | 5 ++--- 2 files changed, 14 insertions(+), 4 deletions(-)
include/net/ip_tunnels.h +12 -1
@@ -19,6 +19,7 @@#include <net/rtnetlink.h> #include <net/lwtunnel.h> #include <net/dst_cache.h> +#include <net/netdev_lock.h> #if IS_ENABLED (CONFIG_IPV6 )#include <net/ipv6.h>
@@ -372,7 +373,17 @@ static inline void ip_tunnel_init_flow(struct flowi4 *fl4, fl4->flowi4_flags = flow_flags; } -int ip_tunnel_init (struct net_device *dev); +int __ip_tunnel_init (struct net_device *dev); +#define ip_tunnel_init (DEV ) \ +({ \ + struct net_device *__dev = (DEV); \ + int __res = __ip_tunnel_init(__dev); \ + \ + if (!__res) \ + netdev_lockdep_set_classes(__dev);\ + __res; \ +}) +void ip_tunnel_uninit (struct net_device *dev);void ip_tunnel_dellink (struct net_device *dev,struct list_head *head);struct net *ip_tunnel_get_link_net (const struct net_device *dev);
net/ipv4/ip_tunnel.c +2 -3
@@ -1281,7 +1281,7 @@ int ip_tunnel_changelink(struct net_device *dev, struct nlattr *tb[], }EXPORT_SYMBOL_GPL (ip_tunnel_changelink); -int ip_tunnel_init (struct net_device *dev) +int __ip_tunnel_init (struct net_device *dev) {struct ip_tunnel *tunnel =netdev_priv (dev);struct iphdr *iph = &tunnel->parms.iph;
@@ -1308,10 +1308,9 @@ int ip_tunnel_init(struct net_device *dev)if (tunnel->collect_md)netif_keep_dst (dev); -netdev_lockdep_set_classes (dev);return 0 ; } -EXPORT_SYMBOL_GPL (ip_tunnel_init); +EXPORT_SYMBOL_GPL (__ip_tunnel_init);void ip_tunnel_uninit (struct net_device *dev) {
Signature · 1 line
2.52.0.351.gbe84eed79e-goog
This patch was applied to netdev/net.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This patch was applied to netdev/net.git (main)
by Jakub Kicinski <[email protected]>:
Quoted 10 lines · On Tue, 6 Jan 2026 17:24:26 +0000 you wrote:
Inspired by yet another syzbot report.
IPv6 tunnels call
netdev_lockdep_set_classes()for each tunnel type, while IPv4 currently centralizesnetdev_lockdep_set_classes()call fromip_tunnel_init().Make
ip_tunnel_init()a macro, so that we have different lockdep classes per tunnel type.[...]
Here is the summary with links:
- [net] ipv4: ip_tunnel: spread netdev_lockdep_set_classes()
https://git.kernel.org/netdev/net/c/872ac785e768
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html