======================================================
WARNING: possible circular locking dependency detected
6.8.0-rc5-syzkaller-00381-g70ff1fe626a1 #0 Not tainted
------------------------------------------------------
syz-executor.2/14874 is trying to acquire lock:
ffff888056f14230 (k-sk_lock-AF_INET6){+.+.}-{0:0}, at: tcp_diag_put_ulp net/ipv4/tcp_diag.c:100 [inline]
ffff888056f14230 (k-sk_lock-AF_INET6){+.+.}-{0:0}, at: tcp_diag_get_aux+0x595/0xaa0 net/ipv4/tcp_diag.c:137

but task is already holding lock:
ffffc9000134d0d8 (&h->lhash2[i].lock){+.+.}-{2:2}, at: spin_lock include/linux/spinlock.h:351 [inline]
ffffc9000134d0d8 (&h->lhash2[i].lock){+.+.}-{2:2}, at: inet_diag_dump_icsk+0x3b5/0x1e20 net/ipv4/inet_diag.c:1038

which lock already depends on the new lock.


the existing dependency chain (in reverse order) is:

-> #1 (&h->lhash2[i].lock){+.+.}-{2:2}:
       __raw_spin_lock include/linux/spinlock_api_smp.h:133 [inline]
       _raw_spin_lock+0x2e/0x40 kernel/locking/spinlock.c:154
       spin_lock include/linux/spinlock.h:351 [inline]
       __inet_hash+0x116/0xaf0 net/ipv4/inet_hashtables.c:743
       inet6_hash net/ipv6/inet6_hashtables.c:355 [inline]
       inet6_hash+0x60/0x80 net/ipv6/inet6_hashtables.c:350
       inet_csk_listen_start+0x2b8/0x380 net/ipv4/inet_connection_sock.c:1261
       __inet_listen_sk+0x211/0x670 net/ipv4/af_inet.c:217
       inet_listen+0x93/0xd0 net/ipv4/af_inet.c:239
       rds_tcp_listen_init+0x2f2/0x4e0 net/rds/tcp_listen.c:316
       rds_tcp_init_net+0x13a/0x3e0 net/rds/tcp.c:577
       ops_init+0xb9/0x650 net/core/net_namespace.c:136
       __register_pernet_operations net/core/net_namespace.c:1214 [inline]
       register_pernet_operations+0x34b/0x830 net/core/net_namespace.c:1283
       register_pernet_device+0x29/0x80 net/core/net_namespace.c:1370
       rds_tcp_init+0x7a/0xe0 net/rds/tcp.c:735
       do_one_initcall+0x11c/0x670 init/main.c:1236
       do_initcall_level init/main.c:1298 [inline]
       do_initcalls init/main.c:1314 [inline]
       do_basic_setup init/main.c:1333 [inline]
       kernel_init_freeable+0x68d/0xc10 init/main.c:1551
       kernel_init+0x1c/0x2a0 init/main.c:1441
       ret_from_fork+0x45/0x80 arch/x86/kernel/process.c:147
       ret_from_fork_asm+0x1b/0x30 arch/x86/entry/entry_64.S:243

-> #0 (k-sk_lock-AF_INET6){+.+.}-{0:0}:
       check_prev_add kernel/locking/lockdep.c:3134 [inline]
       check_prevs_add kernel/locking/lockdep.c:3253 [inline]
       validate_chain kernel/locking/lockdep.c:3869 [inline]
       __lock_acquire+0x244f/0x3b40 kernel/locking/lockdep.c:5137
       lock_acquire kernel/locking/lockdep.c:5754 [inline]
       lock_acquire+0x1ae/0x520 kernel/locking/lockdep.c:5719
       lock_sock_fast include/net/sock.h:1723 [inline]
       subflow_get_info+0x145/0xcf0 net/mptcp/diag.c:28
       tcp_diag_put_ulp net/ipv4/tcp_diag.c:100 [inline]
       tcp_diag_get_aux+0x595/0xaa0 net/ipv4/tcp_diag.c:137
       inet_sk_diag_fill+0xc57/0x1fc0 net/ipv4/inet_diag.c:345
       inet_diag_dump_icsk+0x5d2/0x1e20 net/ipv4/inet_diag.c:1061
       __inet_diag_dump+0x115/0x300 net/ipv4/inet_diag.c:1263
       netlink_dump+0x58f/0xcc0 net/netlink/af_netlink.c:2264
       __netlink_dump_start+0x6d9/0x9d0 net/netlink/af_netlink.c:2370
       netlink_dump_start include/linux/netlink.h:338 [inline]
       inet_diag_handler_cmd+0x284/0x2e0 net/ipv4/inet_diag.c:1426
       __sock_diag_cmd net/core/sock_diag.c:238 [inline]
       sock_diag_rcv_msg+0x31f/0x450 net/core/sock_diag.c:269
       netlink_rcv_skb+0x16b/0x440 net/netlink/af_netlink.c:2543
       sock_diag_rcv+0x2a/0x40 net/core/sock_diag.c:280
       netlink_unicast_kernel net/netlink/af_netlink.c:1341 [inline]
       netlink_unicast+0x542/0x820 net/netlink/af_netlink.c:1367
       netlink_sendmsg+0x8bb/0xd70 net/netlink/af_netlink.c:1908
       sock_sendmsg_nosec net/socket.c:730 [inline]
       __sock_sendmsg net/socket.c:745 [inline]
       sock_write_iter+0x50a/0x5c0 net/socket.c:1160
       call_write_iter include/linux/fs.h:2087 [inline]
       do_iter_readv_writev+0x41d/0x670 fs/read_write.c:741
       vfs_writev+0x36f/0xdb0 fs/read_write.c:971
       do_writev+0x289/0x370 fs/read_write.c:1018
       do_syscall_x64 arch/x86/entry/common.c:52 [inline]
       do_syscall_64+0xd5/0x270 arch/x86/entry/common.c:83
       entry_SYSCALL_64_after_hwframe+0x6f/0x77

other info that might help us debug this:

 Possible unsafe locking scenario:

       CPU0                    CPU1
       ----                    ----
  lock(&h->lhash2[i].lock);
                               lock(k-sk_lock-AF_INET6);
                               lock(&h->lhash2[i].lock);
  lock(k-sk_lock-AF_INET6);

 *** DEADLOCK ***

5 locks held by syz-executor.2/14874:
 #0: ffffffff8f2f1cc8 (sock_diag_mutex){+.+.}-{3:3}, at: sock_diag_rcv+0x1b/0x40 net/core/sock_diag.c:279
 #1: ffffffff8f2f1e48 (sock_diag_table_mutex){+.+.}-{3:3}, at: __sock_diag_cmd net/core/sock_diag.c:233 [inline]
 #1: ffffffff8f2f1e48 (sock_diag_table_mutex){+.+.}-{3:3}, at: sock_diag_rcv_msg+0x19c/0x450 net/core/sock_diag.c:269
 #2: ffff88802eb36680 (nlk_cb_mutex-SOCK_DIAG){+.+.}-{3:3}, at: netlink_dump+0xc1/0xcc0 net/netlink/af_netlink.c:2211
 #3: ffffffff8f486848 (inet_diag_table_mutex){+.+.}-{3:3}, at: inet_diag_lock_handler+0x6e/0x100 net/ipv4/inet_diag.c:63
 #4: ffffc9000134d0d8 (&h->lhash2[i].lock){+.+.}-{2:2}, at: spin_lock include/linux/spinlock.h:351 [inline]
 #4: ffffc9000134d0d8 (&h->lhash2[i].lock){+.+.}-{2:2}, at: inet_diag_dump_icsk+0x3b5/0x1e20 net/ipv4/inet_diag.c:1038

stack backtrace:
CPU: 1 PID: 14874 Comm: syz-executor.2 Not tainted 6.8.0-rc5-syzkaller-00381-g70ff1fe626a1 #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/25/2024
Call Trace:
 <TASK>
 __dump_stack lib/dump_stack.c:88 [inline]
 dump_stack_lvl+0xd9/0x1b0 lib/dump_stack.c:106
 check_noncircular+0x31b/0x400 kernel/locking/lockdep.c:2187
 check_prev_add kernel/locking/lockdep.c:3134 [inline]
 check_prevs_add kernel/locking/lockdep.c:3253 [inline]
 validate_chain kernel/locking/lockdep.c:3869 [inline]
 __lock_acquire+0x244f/0x3b40 kernel/locking/lockdep.c:5137
 lock_acquire kernel/locking/lockdep.c:5754 [inline]
 lock_acquire+0x1ae/0x520 kernel/locking/lockdep.c:5719
 lock_sock_fast include/net/sock.h:1723 [inline]
 subflow_get_info+0x145/0xcf0 net/mptcp/diag.c:28
 tcp_diag_put_ulp net/ipv4/tcp_diag.c:100 [inline]
 tcp_diag_get_aux+0x595/0xaa0 net/ipv4/tcp_diag.c:137
 inet_sk_diag_fill+0xc57/0x1fc0 net/ipv4/inet_diag.c:345
 inet_diag_dump_icsk+0x5d2/0x1e20 net/ipv4/inet_diag.c:1061
 __inet_diag_dump+0x115/0x300 net/ipv4/inet_diag.c:1263
 netlink_dump+0x58f/0xcc0 net/netlink/af_netlink.c:2264
 __netlink_dump_start+0x6d9/0x9d0 net/netlink/af_netlink.c:2370
 netlink_dump_start include/linux/netlink.h:338 [inline]
 inet_diag_handler_cmd+0x284/0x2e0 net/ipv4/inet_diag.c:1426
 __sock_diag_cmd net/core/sock_diag.c:238 [inline]
 sock_diag_rcv_msg+0x31f/0x450 net/core/sock_diag.c:269
 netlink_rcv_skb+0x16b/0x440 net/netlink/af_netlink.c:2543
 sock_diag_rcv+0x2a/0x40 net/core/sock_diag.c:280
 netlink_unicast_kernel net/netlink/af_netlink.c:1341 [inline]
 netlink_unicast+0x542/0x820 net/netlink/af_netlink.c:1367
 netlink_sendmsg+0x8bb/0xd70 net/netlink/af_netlink.c:1908
 sock_sendmsg_nosec net/socket.c:730 [inline]
 __sock_sendmsg net/socket.c:745 [inline]
 sock_write_iter+0x50a/0x5c0 net/socket.c:1160
 call_write_iter include/linux/fs.h:2087 [inline]
 do_iter_readv_writev+0x41d/0x670 fs/read_write.c:741
 vfs_writev+0x36f/0xdb0 fs/read_write.c:971
 do_writev+0x289/0x370 fs/read_write.c:1018
 do_syscall_x64 arch/x86/entry/common.c:52 [inline]
 do_syscall_64+0xd5/0x270 arch/x86/entry/common.c:83
 entry_SYSCALL_64_after_hwframe+0x6f/0x77
RIP: 0033:0x7f0016a7dda9
Code: 28 00 00 00 75 05 48 83 c4 28 c3 e8 e1 20 00 00 90 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 b0 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007f001779a0c8 EFLAGS: 00000246 ORIG_RAX: 0000000000000014
RAX: ffffffffffffffda RBX: 00007f0016babf80 RCX: 00007f0016a7dda9
RDX: 0000000000000001 RSI: 0000000020000140 RDI: 0000000000000004
RBP: 00007f0016aca47a R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 000000000000000b R14: 00007f0016babf80 R15: 00007fff3b2094c8
 </TASK>
BUG: sleeping function called from invalid context at net/core/sock.c:3553
in_atomic(): 1, irqs_disabled(): 0, non_block: 0, pid: 14874, name: syz-executor.2
preempt_count: 1, expected: 0
RCU nest depth: 0, expected: 0
INFO: lockdep is turned off.
Preemption disabled at:
[<0000000000000000>] 0x0
CPU: 1 PID: 14874 Comm: syz-executor.2 Not tainted 6.8.0-rc5-syzkaller-00381-g70ff1fe626a1 #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/25/2024
Call Trace:
 <TASK>
 __dump_stack lib/dump_stack.c:88 [inline]
 dump_stack_lvl+0x125/0x1b0 lib/dump_stack.c:106
 __might_resched+0x3c7/0x5e0 kernel/sched/core.c:10176
 __lock_sock_fast+0x25/0xe0 net/core/sock.c:3553
 lock_sock_fast include/net/sock.h:1725 [inline]
 subflow_get_info+0x14d/0xcf0 net/mptcp/diag.c:28
 tcp_diag_put_ulp net/ipv4/tcp_diag.c:100 [inline]
 tcp_diag_get_aux+0x595/0xaa0 net/ipv4/tcp_diag.c:137
 inet_sk_diag_fill+0xc57/0x1fc0 net/ipv4/inet_diag.c:345
 inet_diag_dump_icsk+0x5d2/0x1e20 net/ipv4/inet_diag.c:1061
 __inet_diag_dump+0x115/0x300 net/ipv4/inet_diag.c:1263
 netlink_dump+0x58f/0xcc0 net/netlink/af_netlink.c:2264
 __netlink_dump_start+0x6d9/0x9d0 net/netlink/af_netlink.c:2370
 netlink_dump_start include/linux/netlink.h:338 [inline]
 inet_diag_handler_cmd+0x284/0x2e0 net/ipv4/inet_diag.c:1426
 __sock_diag_cmd net/core/sock_diag.c:238 [inline]
 sock_diag_rcv_msg+0x31f/0x450 net/core/sock_diag.c:269
 netlink_rcv_skb+0x16b/0x440 net/netlink/af_netlink.c:2543
 sock_diag_rcv+0x2a/0x40 net/core/sock_diag.c:280
 netlink_unicast_kernel net/netlink/af_netlink.c:1341 [inline]
 netlink_unicast+0x542/0x820 net/netlink/af_netlink.c:1367
 netlink_sendmsg+0x8bb/0xd70 net/netlink/af_netlink.c:1908
 sock_sendmsg_nosec net/socket.c:730 [inline]
 __sock_sendmsg net/socket.c:745 [inline]
 sock_write_iter+0x50a/0x5c0 net/socket.c:1160
 call_write_iter include/linux/fs.h:2087 [inline]
 do_iter_readv_writev+0x41d/0x670 fs/read_write.c:741
 vfs_writev+0x36f/0xdb0 fs/read_write.c:971
 do_writev+0x289/0x370 fs/read_write.c:1018
 do_syscall_x64 arch/x86/entry/common.c:52 [inline]
 do_syscall_64+0xd5/0x270 arch/x86/entry/common.c:83
 entry_SYSCALL_64_after_hwframe+0x6f/0x77
RIP: 0033:0x7f0016a7dda9
Code: 28 00 00 00 75 05 48 83 c4 28 c3 e8 e1 20 00 00 90 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 b0 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007f001779a0c8 EFLAGS: 00000246 ORIG_RAX: 0000000000000014
RAX: ffffffffffffffda RBX: 00007f0016babf80 RCX: 00007f0016a7dda9
RDX: 0000000000000001 RSI: 0000000020000140 RDI: 0000000000000004
RBP: 00007f0016aca47a R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 000000000000000b R14: 00007f0016babf80 R15: 00007fff3b2094c8
 </TASK>