Skip to contentSkip to conversation

net: update netdev_lock_{type,name}

PATCH Superseded Eric Dumazet 2 participants 3 messages Jan 7 – Jan 8

Subsystems (2)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 net: update netdev_lock_{type,name}

Add missing entries in netdev_lock_type[] and netdev_lock_name[] :

CAN, MCTP, RAWIP, CAIF, IP6GRE, 6LOWPAN, NETLINK, VSOCKMON.

Also add a WARN_ONCE() in netdev_lock_pos() to help future bug hunting next time a protocol is added without updating these arrays.

Fixes 1a33e10e4a95 ("net: partially revert dynamic lockdep key changes")

---
v2: added NETLINK, VSOCKMON (Jakub)
v1: https://lore.kernel.org/netdev/[email protected]/

 net/core/dev.c | 19 +++++++++++++++----
 1 file changed, 15 insertions(+), 4 deletions(-)
net/core/dev.c +15 -4
index 36dc5199037edb1506e67f6ab5e977ff41efef59..fed0d4a991a13cc3ebed22bbce7f646ae2987616 100644
@@ -478,15 +478,20 @@ static const unsigned short netdev_lock_type[] = {
 	 ARPHRD_IEEE1394, ARPHRD_EUI64, ARPHRD_INFINIBAND, ARPHRD_SLIP,
 	 ARPHRD_CSLIP, ARPHRD_SLIP6, ARPHRD_CSLIP6, ARPHRD_RSRVD,
 	 ARPHRD_ADAPT, ARPHRD_ROSE, ARPHRD_X25, ARPHRD_HWX25,
+	 ARPHRD_CAN, ARPHRD_MCTP,
 	 ARPHRD_PPP, ARPHRD_CISCO, ARPHRD_LAPB, ARPHRD_DDCMP,
-	 ARPHRD_RAWHDLC, ARPHRD_TUNNEL, ARPHRD_TUNNEL6, ARPHRD_FRAD,
+	 ARPHRD_RAWHDLC, ARPHRD_RAWIP,
+	 ARPHRD_TUNNEL, ARPHRD_TUNNEL6, ARPHRD_FRAD,
 	 ARPHRD_SKIP, ARPHRD_LOOPBACK, ARPHRD_LOCALTLK, ARPHRD_FDDI,
 	 ARPHRD_BIF, ARPHRD_SIT, ARPHRD_IPDDP, ARPHRD_IPGRE,
 	 ARPHRD_PIMREG, ARPHRD_HIPPI, ARPHRD_ASH, ARPHRD_ECONET,
 	 ARPHRD_IRDA, ARPHRD_FCPP, ARPHRD_FCAL, ARPHRD_FCPL,
 	 ARPHRD_FCFABRIC, ARPHRD_IEEE80211, ARPHRD_IEEE80211_PRISM,
 	 ARPHRD_IEEE80211_RADIOTAP, ARPHRD_PHONET, ARPHRD_PHONET_PIPE,
-	 ARPHRD_IEEE802154, ARPHRD_VOID, ARPHRD_NONE};
+	 ARPHRD_IEEE802154,
+	 ARPHRD_CAIF, ARPHRD_IP6GRE, ARPHRD_NETLINK, ARPHRD_6LOWPAN,
+	 ARPHRD_VSOCKMON,
+	 ARPHRD_VOID, ARPHRD_NONE};
 
 static const char *const netdev_lock_name[] = {
 	"_xmit_NETROM", "_xmit_ETHER", "_xmit_EETHER", "_xmit_AX25",
@@ -495,15 +500,20 @@ static const char *const netdev_lock_name[] = {
 	"_xmit_IEEE1394", "_xmit_EUI64", "_xmit_INFINIBAND", "_xmit_SLIP",
 	"_xmit_CSLIP", "_xmit_SLIP6", "_xmit_CSLIP6", "_xmit_RSRVD",
 	"_xmit_ADAPT", "_xmit_ROSE", "_xmit_X25", "_xmit_HWX25",
+	"_xmit_CAN", "_xmit_MCTP",
 	"_xmit_PPP", "_xmit_CISCO", "_xmit_LAPB", "_xmit_DDCMP",
-	"_xmit_RAWHDLC", "_xmit_TUNNEL", "_xmit_TUNNEL6", "_xmit_FRAD",
+	"_xmit_RAWHDLC", "_xmit_RAWIP",
+	"_xmit_TUNNEL", "_xmit_TUNNEL6", "_xmit_FRAD",
 	"_xmit_SKIP", "_xmit_LOOPBACK", "_xmit_LOCALTLK", "_xmit_FDDI",
 	"_xmit_BIF", "_xmit_SIT", "_xmit_IPDDP", "_xmit_IPGRE",
 	"_xmit_PIMREG", "_xmit_HIPPI", "_xmit_ASH", "_xmit_ECONET",
 	"_xmit_IRDA", "_xmit_FCPP", "_xmit_FCAL", "_xmit_FCPL",
 	"_xmit_FCFABRIC", "_xmit_IEEE80211", "_xmit_IEEE80211_PRISM",
 	"_xmit_IEEE80211_RADIOTAP", "_xmit_PHONET", "_xmit_PHONET_PIPE",
-	"_xmit_IEEE802154", "_xmit_VOID", "_xmit_NONE"};
+	"_xmit_IEEE802154",
+	"_xmit_CAIF", "_xmit_IP6GRE", "_xmit_NETLINK", "_xmit_6LOWPAN",
+	"_xmit_VSOCKMON",
+	"_xmit_VOID", "_xmit_NONE"};
 
 static struct lock_class_key netdev_xmit_lock_key[ARRAY_SIZE(netdev_lock_type)];
 static struct lock_class_key netdev_addr_lock_key[ARRAY_SIZE(netdev_lock_type)];
@@ -516,6 +526,7 @@ static inline unsigned short netdev_lock_pos(unsigned short dev_type)
 		if (netdev_lock_type[i] == dev_type)
 			return i;
 	/* the last key is used by default */
+	WARN_ONCE(1, "netdev_lock_pos() could not find dev_type=%u\n", dev_type);
 	return ARRAY_SIZE(netdev_lock_type) - 1;
 }
 
Signature · 1 line
2.52.0.351.gbe84eed79e-goog
syzbot Tested-by [email protected] on v2 1/1
#1 lore raw
syzbot ci has tested the following series

syzbot ci has tested the following series

[v2] net: update netdev_lock_{type,name}
https://lore.kernel.org/all/[email protected]
* [PATCH v2 net] net: update netdev_lock_{type,name}

and found the following issue:
WARNING in register_netdevice

Full report is available here:
https://ci.syzbot.org/series/07a2abd3-8dbc-43d0-a5d9-cdbb1a35d769

***

WARNING in register_netdevice

tree:      net
URL:       https://kernel.googlesource.com/pub/scm/linux/kernel/git/netdev/net.git
base:      1806d210e5a8f431ad4711766ae4a333d407d972
arch:      amd64
compiler:  Debian clang version 21.1.8 (++20251202083448+f68f64eb8130-1~exp1~20251202083504.46), Debian LLD 21.1.8
config:    https://ci.syzbot.org/builds/f4fb7576-ea1f-485d-9ef1-c3270f1560d9/config
C repro:   https://ci.syzbot.org/findings/e4767ea9-6be5-4bce-9523-40ab12d29b67/c_repro
syz repro: https://ci.syzbot.org/findings/e4767ea9-6be5-4bce-9523-40ab12d29b67/syz_repro
------------[ cut here ]------------
netdev_lock_pos() could not find dev_type=805
WARNING: net/core/dev.c:529 at netdev_lock_pos net/core/dev.c:529 [inline], CPU#0: syz.0.17/5972
WARNING: net/core/dev.c:529 at netdev_set_addr_lockdep_class net/core/dev.c:547 [inline], CPU#0: syz.0.17/5972
WARNING: net/core/dev.c:529 at register_netdevice+0x7f9/0x1ba0 net/core/dev.c:11318, CPU#0: syz.0.17/5972
Modules linked in:
CPU: 0 UID: 0 PID: 5972 Comm: syz.0.17 Not tainted syzkaller #0 PREEMPT(full) 
Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.16.2-debian-1.16.2-1 04/01/2014
RIP: 0010:netdev_lock_pos net/core/dev.c:529 [inline]
RIP: 0010:netdev_set_addr_lockdep_class net/core/dev.c:547 [inline]
RIP: 0010:register_netdevice+0x7fc/0x1ba0 net/core/dev.c:11318
Code: ca 56 db f8 48 c7 03 00 00 00 00 41 bd f4 ff ff ff 4c 8b 64 24 28 e9 8f f9 ff ff e8 4e 59 74 f8 48 8d 3d 27 79 82 06 44 89 e6 <67> 48 0f b9 3a 41 bc 40 00 00 00 49 bf 00 00 00 00 00 fc ff df 4c
RSP: 0018:ffffc9000768ef20 EFLAGS: 00010293
RAX: ffffffff894e19b2 RBX: fffffffffffffff8 RCX: ffff8881063c57c0
RDX: 0000000000000000 RSI: 0000000000000325 RDI: ffffffff8fd092e0
RBP: ffffc9000768f090 R08: 0000000000000003 R09: 0000000000000000
R10: dffffc0000000000 R11: ffffed10218fd9d4 R12: 0000000000000325
R13: ffffffff8c902318 R14: 000000000000fffe R15: 0000000000000040
FS:  000055556284f500(0000) GS:ffff88818e40f000(0000) knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00007f4739c706c0 CR3: 00000001bdb86000 CR4: 00000000000006f0
Call Trace:
 <TASK>
 ieee802154_if_add+0xb39/0x1050 net/mac802154/iface.c:667
 ieee802154_add_iface_deprecated+0x43/0x70 net/mac802154/cfg.c:26
 rdev_add_virtual_intf_deprecated net/ieee802154/rdev-ops.h:16 [inline]
 ieee802154_add_iface+0x472/0x860 net/ieee802154/nl-phy.c:218
 genl_family_rcv_msg_doit+0x22a/0x330 net/netlink/genetlink.c:1115
 genl_family_rcv_msg net/netlink/genetlink.c:1195 [inline]
 genl_rcv_msg+0x61c/0x7a0 net/netlink/genetlink.c:1210
 netlink_rcv_skb+0x232/0x4b0 net/netlink/af_netlink.c:2550
 genl_rcv+0x28/0x40 net/netlink/genetlink.c:1219
 netlink_unicast_kernel net/netlink/af_netlink.c:1318 [inline]
 netlink_unicast+0x80f/0x9b0 net/netlink/af_netlink.c:1344
 netlink_sendmsg+0x813/0xb40 net/netlink/af_netlink.c:1894
 sock_sendmsg_nosec net/socket.c:727 [inline]
 __sock_sendmsg+0x21c/0x270 net/socket.c:742
 ____sys_sendmsg+0x4d7/0x810 net/socket.c:2592
 ___sys_sendmsg+0x2a5/0x360 net/socket.c:2646
 __sys_sendmsg net/socket.c:2678 [inline]
 __do_sys_sendmsg net/socket.c:2683 [inline]
 __se_sys_sendmsg net/socket.c:2681 [inline]
 __x64_sys_sendmsg+0x1bd/0x2a0 net/socket.c:2681
 do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline]
 do_syscall_64+0xe2/0xf80 arch/x86/entry/syscall_64.c:94
 entry_SYSCALL_64_after_hwframe+0x77/0x7f
RIP: 0033:0x7f4739d9acb9
Code: ff c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 44 00 00 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 e8 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007ffd43a0e968 EFLAGS: 00000246 ORIG_RAX: 000000000000002e
RAX: ffffffffffffffda RBX: 00007f473a005fa0 RCX: 00007f4739d9acb9
RDX: 0000000020048000 RSI: 00002000000009c0 RDI: 0000000000000004
RBP: 00007f4739e08bf7 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 00007f473a005fac R14: 00007f473a005fa0 R15: 00007f473a005fa0
 </TASK>
----------------
Code disassembly (best guess):
   0:	ca 56 db             	lret   $0xdb56
   3:	f8                   	clc
   4:	48 c7 03 00 00 00 00 	movq   $0x0,(%rbx)
   b:	41 bd f4 ff ff ff    	mov    $0xfffffff4,%r13d
  11:	4c 8b 64 24 28       	mov    0x28(%rsp),%r12
  16:	e9 8f f9 ff ff       	jmp    0xfffff9aa
  1b:	e8 4e 59 74 f8       	call   0xf874596e
  20:	48 8d 3d 27 79 82 06 	lea    0x6827927(%rip),%rdi        # 0x682794e
  27:	44 89 e6             	mov    %r12d,%esi
* 2a:	67 48 0f b9 3a       	ud1    (%edx),%rdi <-- trapping instruction
  2f:	41 bc 40 00 00 00    	mov    $0x40,%r12d
  35:	49 bf 00 00 00 00 00 	movabs $0xdffffc0000000000,%r15
  3c:	fc ff df
  3f:	4c                   	rex.WR

***

If these findings have caused you to resend the series or submit a separate fix, please add the following tag to your commit message:

---
This report is generated by a bot. It may contain errors. syzbot ci engineers can be reached at [email protected].

#2 lore raw
Quoted 26 lines · syzbot ci

syzbot ci has tested the following series

[v2] net: update netdev_lock_{type,name}
https://lore.kernel.org/all/[email protected]
* [PATCH v2 net] net: update netdev_lock_{type,name}

and found the following issue:
WARNING in register_netdevice

Full report is available here:
https://ci.syzbot.org/series/07a2abd3-8dbc-43d0-a5d9-cdbb1a35d769

***

WARNING in register_netdevice

tree:      net
URL:       https://kernel.googlesource.com/pub/scm/linux/kernel/git/netdev/net.git
base:      1806d210e5a8f431ad4711766ae4a333d407d972
arch:      amd64
compiler:  Debian clang version 21.1.8 (++20251202083448+f68f64eb8130-1~exp1~20251202083504.46), Debian LLD 21.1.8
config:    https://ci.syzbot.org/builds/f4fb7576-ea1f-485d-9ef1-c3270f1560d9/config
C repro:   https://ci.syzbot.org/findings/e4767ea9-6be5-4bce-9523-40ab12d29b67/c_repro
syz repro: https://ci.syzbot.org/findings/e4767ea9-6be5-4bce-9523-40ab12d29b67/syz_repro
Quoted 2 lines
------------[ cut here ]------------
netdev_lock_pos() could not find dev_type=805

OK, 805 is ARPHRD_IEEE802154_MONITOR, I am adding it to V3