Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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.

Fixes: 0bef512012b1 ("net: add netdev_lockdep_set_classes() to virtual drivers")
Reported-by: syzbot+1240b33467289f5ab50b@syzkaller.appspotmail.com
Closes: https://lore.kernel.org/netdev/695d439f.050a0220.1c677c.0347.GAE@google.com/T/#u
Signed-off-by: Eric Dumazet <edumazet@google.com>
Link: https://patch.msgid.link/20260106172426.1760721-1-edumazet@google.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Eric Dumazet and committed by
Jakub Kicinski
872ac785 56d0aea0

+14 -4
+12 -1
include/net/ip_tunnels.h
··· 19 19 #include <net/rtnetlink.h> 20 20 #include <net/lwtunnel.h> 21 21 #include <net/dst_cache.h> 22 + #include <net/netdev_lock.h> 22 23 23 24 #if IS_ENABLED(CONFIG_IPV6) 24 25 #include <net/ipv6.h> ··· 373 372 fl4->flowi4_flags = flow_flags; 374 373 } 375 374 376 - int ip_tunnel_init(struct net_device *dev); 375 + int __ip_tunnel_init(struct net_device *dev); 376 + #define ip_tunnel_init(DEV) \ 377 + ({ \ 378 + struct net_device *__dev = (DEV); \ 379 + int __res = __ip_tunnel_init(__dev); \ 380 + \ 381 + if (!__res) \ 382 + netdev_lockdep_set_classes(__dev);\ 383 + __res; \ 384 + }) 385 + 377 386 void ip_tunnel_uninit(struct net_device *dev); 378 387 void ip_tunnel_dellink(struct net_device *dev, struct list_head *head); 379 388 struct net *ip_tunnel_get_link_net(const struct net_device *dev);
+2 -3
net/ipv4/ip_tunnel.c
··· 1281 1281 } 1282 1282 EXPORT_SYMBOL_GPL(ip_tunnel_changelink); 1283 1283 1284 - int ip_tunnel_init(struct net_device *dev) 1284 + int __ip_tunnel_init(struct net_device *dev) 1285 1285 { 1286 1286 struct ip_tunnel *tunnel = netdev_priv(dev); 1287 1287 struct iphdr *iph = &tunnel->parms.iph; ··· 1308 1308 1309 1309 if (tunnel->collect_md) 1310 1310 netif_keep_dst(dev); 1311 - netdev_lockdep_set_classes(dev); 1312 1311 return 0; 1313 1312 } 1314 - EXPORT_SYMBOL_GPL(ip_tunnel_init); 1313 + EXPORT_SYMBOL_GPL(__ip_tunnel_init); 1315 1314 1316 1315 void ip_tunnel_uninit(struct net_device *dev) 1317 1316 {