syzbot


possible deadlock in tcp_diag_get_aux

Status: upstream: reported C repro on 2024/03/01 15:08
Bug presence: origin:lts-only
[Documentation on labels]
Reported-by: syzbot+84cd030a6fb929645bfc@syzkaller.appspotmail.com
First crash: 106d, last: 102d
Bug presence (2)
Date Name Commit Repro Result
2024/03/02 linux-6.1.y (ToT) a3eb3a74aa8c C [report] possible deadlock in tcp_diag_get_aux
2024/03/02 upstream (ToT) d17468c6f1f4 C Didn't crash
Similar bugs (2)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
upstream possible deadlock in tcp_diag_get_aux net C 117 99d 117d 26/27 fixed on 2024/04/02 11:36
linux-5.15 possible deadlock in tcp_diag_get_aux origin:lts-only C error 7 102d 106d 0/3 upstream: reported C repro on 2024/03/01 14:44
Fix bisection attempts (1)
Created Duration User Patch Repo Result
2024/03/10 02:05 1h19m fix candidate upstream job log (0)

Sample crash report:
======================================================
WARNING: possible circular locking dependency detected
6.1.80-syzkaller #0 Not tainted
------------------------------------------------------
syz-executor166/4222 is trying to acquire lock:
ffff0000d5190130 (k-sk_lock-AF_INET){+.+.}-{0:0}, at: tcp_diag_put_ulp net/ipv4/tcp_diag.c:100 [inline]
ffff0000d5190130 (k-sk_lock-AF_INET){+.+.}-{0:0}, at: tcp_diag_get_aux+0x680/0x750 net/ipv4/tcp_diag.c:137

but task is already holding lock:
ffff0000c4f993b0 (&h->lhash2[i].lock){+.+.}-{2:2}, at: spin_lock include/linux/spinlock.h:351 [inline]
ffff0000c4f993b0 (&h->lhash2[i].lock){+.+.}-{2:2}, at: inet_diag_dump_icsk+0xed8/0x1204 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+0x54/0x6c kernel/locking/spinlock.c:154
       spin_lock include/linux/spinlock.h:351 [inline]
       __inet_hash+0x29c/0xb60 net/ipv4/inet_hashtables.c:728
       inet_hash+0x74/0x9c net/ipv4/inet_hashtables.c:753
       inet_csk_listen_start+0x1e4/0x2c8 net/ipv4/inet_connection_sock.c:1264
       inet_listen+0x254/0x6d0 net/ipv4/af_inet.c:228
       mptcp_listen+0x198/0x43c net/mptcp/protocol.c:3817
       __sys_listen+0x1ac/0x21c net/socket.c:1840
       __do_sys_listen net/socket.c:1849 [inline]
       __se_sys_listen net/socket.c:1847 [inline]
       __arm64_sys_listen+0x5c/0x74 net/socket.c:1847
       __invoke_syscall arch/arm64/kernel/syscall.c:38 [inline]
       invoke_syscall+0x98/0x2c0 arch/arm64/kernel/syscall.c:52
       el0_svc_common+0x138/0x258 arch/arm64/kernel/syscall.c:142
       do_el0_svc+0x64/0x218 arch/arm64/kernel/syscall.c:206
       el0_svc+0x58/0x168 arch/arm64/kernel/entry-common.c:637
       el0t_64_sync_handler+0x84/0xf0 arch/arm64/kernel/entry-common.c:655
       el0t_64_sync+0x18c/0x190 arch/arm64/kernel/entry.S:585

-> #0 (k-sk_lock-AF_INET){+.+.}-{0:0}:
       check_prev_add kernel/locking/lockdep.c:3090 [inline]
       check_prevs_add kernel/locking/lockdep.c:3209 [inline]
       validate_chain kernel/locking/lockdep.c:3825 [inline]
       __lock_acquire+0x3338/0x7680 kernel/locking/lockdep.c:5049
       lock_acquire+0x26c/0x7cc kernel/locking/lockdep.c:5662
       lock_sock_fast include/net/sock.h:1777 [inline]
       subflow_get_info+0x164/0xba8 net/mptcp/diag.c:28
       tcp_diag_put_ulp net/ipv4/tcp_diag.c:100 [inline]
       tcp_diag_get_aux+0x680/0x750 net/ipv4/tcp_diag.c:137
       inet_sk_diag_fill+0xd60/0x1818 net/ipv4/inet_diag.c:345
       inet_diag_dump_icsk+0x1040/0x1204 net/ipv4/inet_diag.c:1061
       tcp_diag_dump+0xac/0xc4 net/ipv4/tcp_diag.c:188
       __inet_diag_dump+0x1e8/0x33c net/ipv4/inet_diag.c:1179
       inet_diag_dump_compat+0x17c/0x288 net/ipv4/inet_diag.c:1287
       netlink_dump+0x46c/0xa78 net/netlink/af_netlink.c:2231
       __netlink_dump_start+0x484/0x698 net/netlink/af_netlink.c:2335
       netlink_dump_start include/linux/netlink.h:269 [inline]
       inet_diag_rcv_msg_compat+0x1c8/0x41c net/ipv4/inet_diag.c:1321
       sock_diag_rcv_msg+0x174/0x39c
       netlink_rcv_skb+0x20c/0x3b8 net/netlink/af_netlink.c:2508
       sock_diag_rcv+0x3c/0x54 net/core/sock_diag.c:277
       netlink_unicast_kernel net/netlink/af_netlink.c:1326 [inline]
       netlink_unicast+0x65c/0x898 net/netlink/af_netlink.c:1352
       netlink_sendmsg+0x834/0xb18 net/netlink/af_netlink.c:1874
       sock_sendmsg_nosec net/socket.c:718 [inline]
       __sock_sendmsg net/socket.c:730 [inline]
       ____sys_sendmsg+0x55c/0x848 net/socket.c:2514
       ___sys_sendmsg net/socket.c:2568 [inline]
       __sys_sendmsg+0x26c/0x33c net/socket.c:2597
       __do_sys_sendmsg net/socket.c:2606 [inline]
       __se_sys_sendmsg net/socket.c:2604 [inline]
       __arm64_sys_sendmsg+0x80/0x94 net/socket.c:2604
       __invoke_syscall arch/arm64/kernel/syscall.c:38 [inline]
       invoke_syscall+0x98/0x2c0 arch/arm64/kernel/syscall.c:52
       el0_svc_common+0x138/0x258 arch/arm64/kernel/syscall.c:142
       do_el0_svc+0x64/0x218 arch/arm64/kernel/syscall.c:206
       el0_svc+0x58/0x168 arch/arm64/kernel/entry-common.c:637
       el0t_64_sync_handler+0x84/0xf0 arch/arm64/kernel/entry-common.c:655
       el0t_64_sync+0x18c/0x190 arch/arm64/kernel/entry.S:585

other info that might help us debug this:

 Possible unsafe locking scenario:

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

 *** DEADLOCK ***

5 locks held by syz-executor166/4222:
 #0: ffff800017e05cc8 (sock_diag_mutex){+.+.}-{3:3}, at: sock_diag_rcv+0x2c/0x54 net/core/sock_diag.c:276
 #1: ffff800017e05b28 (sock_diag_table_mutex){+.+.}-{3:3}, at: sock_diag_rcv_msg+0x15c/0x39c net/core/sock_diag.c:256
 #2: ffff0000d3152690 (nlk_cb_mutex-SOCK_DIAG){+.+.}-{3:3}, at: netlink_dump+0xbc/0xa78 net/netlink/af_netlink.c:2178
 #3: ffff800017edd7e8 (inet_diag_table_mutex){+.+.}-{3:3}, at: inet_diag_lock_handler net/ipv4/inet_diag.c:63 [inline]
 #3: ffff800017edd7e8 (inet_diag_table_mutex){+.+.}-{3:3}, at: __inet_diag_dump+0x17c/0x33c net/ipv4/inet_diag.c:1177
 #4: ffff0000c4f993b0 (&h->lhash2[i].lock){+.+.}-{2:2}, at: spin_lock include/linux/spinlock.h:351 [inline]
 #4: ffff0000c4f993b0 (&h->lhash2[i].lock){+.+.}-{2:2}, at: inet_diag_dump_icsk+0xed8/0x1204 net/ipv4/inet_diag.c:1038

stack backtrace:
CPU: 1 PID: 4222 Comm: syz-executor166 Not tainted 6.1.80-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/25/2024
Call trace:
 dump_backtrace+0x1c8/0x1f4 arch/arm64/kernel/stacktrace.c:158
 show_stack+0x2c/0x3c arch/arm64/kernel/stacktrace.c:165
 __dump_stack lib/dump_stack.c:88 [inline]
 dump_stack_lvl+0x108/0x170 lib/dump_stack.c:106
 dump_stack+0x1c/0x58 lib/dump_stack.c:113
 print_circular_bug+0x150/0x1b8 kernel/locking/lockdep.c:2048
 check_noncircular+0x2cc/0x378 kernel/locking/lockdep.c:2170
 check_prev_add kernel/locking/lockdep.c:3090 [inline]
 check_prevs_add kernel/locking/lockdep.c:3209 [inline]
 validate_chain kernel/locking/lockdep.c:3825 [inline]
 __lock_acquire+0x3338/0x7680 kernel/locking/lockdep.c:5049
 lock_acquire+0x26c/0x7cc kernel/locking/lockdep.c:5662
 lock_sock_fast include/net/sock.h:1777 [inline]
 subflow_get_info+0x164/0xba8 net/mptcp/diag.c:28
 tcp_diag_put_ulp net/ipv4/tcp_diag.c:100 [inline]
 tcp_diag_get_aux+0x680/0x750 net/ipv4/tcp_diag.c:137
 inet_sk_diag_fill+0xd60/0x1818 net/ipv4/inet_diag.c:345
 inet_diag_dump_icsk+0x1040/0x1204 net/ipv4/inet_diag.c:1061
 tcp_diag_dump+0xac/0xc4 net/ipv4/tcp_diag.c:188
 __inet_diag_dump+0x1e8/0x33c net/ipv4/inet_diag.c:1179
 inet_diag_dump_compat+0x17c/0x288 net/ipv4/inet_diag.c:1287
 netlink_dump+0x46c/0xa78 net/netlink/af_netlink.c:2231
 __netlink_dump_start+0x484/0x698 net/netlink/af_netlink.c:2335
 netlink_dump_start include/linux/netlink.h:269 [inline]
 inet_diag_rcv_msg_compat+0x1c8/0x41c net/ipv4/inet_diag.c:1321
 sock_diag_rcv_msg+0x174/0x39c
 netlink_rcv_skb+0x20c/0x3b8 net/netlink/af_netlink.c:2508
 sock_diag_rcv+0x3c/0x54 net/core/sock_diag.c:277
 netlink_unicast_kernel net/netlink/af_netlink.c:1326 [inline]
 netlink_unicast+0x65c/0x898 net/netlink/af_netlink.c:1352
 netlink_sendmsg+0x834/0xb18 net/netlink/af_netlink.c:1874
 sock_sendmsg_nosec net/socket.c:718 [inline]
 __sock_sendmsg net/socket.c:730 [inline]
 ____sys_sendmsg+0x55c/0x848 net/socket.c:2514
 ___sys_sendmsg net/socket.c:2568 [inline]
 __sys_sendmsg+0x26c/0x33c net/socket.c:2597
 __do_sys_sendmsg net/socket.c:2606 [inline]
 __se_sys_sendmsg net/socket.c:2604 [inline]
 __arm64_sys_sendmsg+0x80/0x94 net/socket.c:2604
 __invoke_syscall arch/arm64/kernel/syscall.c:38 [inline]
 invoke_syscall+0x98/0x2c0 arch/arm64/kernel/syscall.c:52
 el0_svc_common+0x138/0x258 arch/arm64/kernel/syscall.c:142
 do_el0_svc+0x64/0x218 arch/arm64/kernel/syscall.c:206
 el0_svc+0x58/0x168 arch/arm64/kernel/entry-common.c:637
 el0t_64_sync_handler+0x84/0xf0 arch/arm64/kernel/entry-common.c:655
 el0t_64_sync+0x18c/0x190 arch/arm64/kernel/entry.S:585
BUG: sleeping function called from invalid context at net/core/sock.c:3516
in_atomic(): 1, irqs_disabled(): 0, non_block: 0, pid: 4222, name: syz-executor166
preempt_count: 1, expected: 0
RCU nest depth: 0, expected: 0
INFO: lockdep is turned off.
Preemption disabled at:
[<ffff800010de2a6c>] spin_lock include/linux/spinlock.h:351 [inline]
[<ffff800010de2a6c>] inet_diag_dump_icsk+0xed8/0x1204 net/ipv4/inet_diag.c:1038
CPU: 1 PID: 4222 Comm: syz-executor166 Not tainted 6.1.80-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/25/2024
Call trace:
 dump_backtrace+0x1c8/0x1f4 arch/arm64/kernel/stacktrace.c:158
 show_stack+0x2c/0x3c arch/arm64/kernel/stacktrace.c:165
 __dump_stack lib/dump_stack.c:88 [inline]
 dump_stack_lvl+0x108/0x170 lib/dump_stack.c:106
 dump_stack+0x1c/0x58 lib/dump_stack.c:113
 __might_resched+0x37c/0x4d8 kernel/sched/core.c:9942
 __might_sleep+0x90/0xe4 kernel/sched/core.c:9871
 __lock_sock_fast+0x38/0xec net/core/sock.c:3516
 lock_sock_fast include/net/sock.h:1779 [inline]
 subflow_get_info+0x16c/0xba8 net/mptcp/diag.c:28
 tcp_diag_put_ulp net/ipv4/tcp_diag.c:100 [inline]
 tcp_diag_get_aux+0x680/0x750 net/ipv4/tcp_diag.c:137
 inet_sk_diag_fill+0xd60/0x1818 net/ipv4/inet_diag.c:345
 inet_diag_dump_icsk+0x1040/0x1204 net/ipv4/inet_diag.c:1061
 tcp_diag_dump+0xac/0xc4 net/ipv4/tcp_diag.c:188
 __inet_diag_dump+0x1e8/0x33c net/ipv4/inet_diag.c:1179
 inet_diag_dump_compat+0x17c/0x288 net/ipv4/inet_diag.c:1287
 netlink_dump+0x46c/0xa78 net/netlink/af_netlink.c:2231
 __netlink_dump_start+0x484/0x698 net/netlink/af_netlink.c:2335
 netlink_dump_start include/linux/netlink.h:269 [inline]
 inet_diag_rcv_msg_compat+0x1c8/0x41c net/ipv4/inet_diag.c:1321
 sock_diag_rcv_msg+0x174/0x39c
 netlink_rcv_skb+0x20c/0x3b8 net/netlink/af_netlink.c:2508
 sock_diag_rcv+0x3c/0x54 net/core/sock_diag.c:277
 netlink_unicast_kernel net/netlink/af_netlink.c:1326 [inline]
 netlink_unicast+0x65c/0x898 net/netlink/af_netlink.c:1352
 netlink_sendmsg+0x834/0xb18 net/netlink/af_netlink.c:1874
 sock_sendmsg_nosec net/socket.c:718 [inline]
 __sock_sendmsg net/socket.c:730 [inline]
 ____sys_sendmsg+0x55c/0x848 net/socket.c:2514
 ___sys_sendmsg net/socket.c:2568 [inline]
 __sys_sendmsg+0x26c/0x33c net/socket.c:2597
 __do_sys_sendmsg net/socket.c:2606 [inline]
 __se_sys_sendmsg net/socket.c:2604 [inline]
 __arm64_sys_sendmsg+0x80/0x94 net/socket.c:2604
 __invoke_syscall arch/arm64/kernel/syscall.c:38 [inline]
 invoke_syscall+0x98/0x2c0 arch/arm64/kernel/syscall.c:52
 el0_svc_common+0x138/0x258 arch/arm64/kernel/syscall.c:142
 do_el0_svc+0x64/0x218 arch/arm64/kernel/syscall.c:206
 el0_svc+0x58/0x168 arch/arm64/kernel/entry-common.c:637
 el0t_64_sync_handler+0x84/0xf0 arch/arm64/kernel/entry-common.c:655
 el0t_64_sync+0x18c/0x190 arch/arm64/kernel/entry.S:585

Crashes (4):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2024/03/01 20:00 linux-6.1.y a3eb3a74aa8c 83acf9e0 .config console log report syz C [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan-arm64 possible deadlock in tcp_diag_get_aux
2024/03/04 20:44 linux-6.1.y a3eb3a74aa8c 3717835d .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan possible deadlock in tcp_diag_get_aux
2024/03/01 17:52 linux-6.1.y a3eb3a74aa8c 83acf9e0 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan-arm64 possible deadlock in tcp_diag_get_aux
2024/03/01 15:07 linux-6.1.y a3eb3a74aa8c 83acf9e0 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan-arm64 possible deadlock in tcp_diag_get_aux
* Struck through repros no longer work on HEAD.