syzbot


possible deadlock in sctp_sock_migrate

Status: upstream: reported on 2024/12/14 15:03
Subsystems: sctp
[Documentation on labels]
Reported-by: syzbot+95ba71e75926e4a97806@syzkaller.appspotmail.com
First crash: 10d, last: 10d
Discussions (1)
Title Replies (including bot) Last reply
[syzbot] [sctp?] possible deadlock in sctp_sock_migrate 0 (1) 2024/12/14 15:03

Sample crash report:
======================================================
WARNING: possible circular locking dependency detected
6.13.0-rc2-syzkaller-00018-g7cb1b4663150 #0 Not tainted
------------------------------------------------------
syz.5.1757/14440 is trying to acquire lock:
ffff88807f80c658 (sk_lock-AF_INET/1){+.+.}-{0:0}, at: sctp_sock_migrate+0x987/0x1270 net/sctp/socket.c:9655

but task is already holding lock:
ffff88807f80dfd8 (sk_lock-AF_INET){+.+.}-{0:0}, at: lock_sock include/net/sock.h:1617 [inline]
ffff88807f80dfd8 (sk_lock-AF_INET){+.+.}-{0:0}, at: sctp_accept+0x90/0x800 net/sctp/socket.c:4863

which lock already depends on the new lock.


the existing dependency chain (in reverse order) is:

-> #3 (sk_lock-AF_INET){+.+.}-{0:0}:
       lock_sock_nested+0x3a/0xf0 net/core/sock.c:3622
       lock_sock include/net/sock.h:1617 [inline]
       sockopt_lock_sock net/core/sock.c:1126 [inline]
       sockopt_lock_sock+0x54/0x70 net/core/sock.c:1117
       do_ip_getsockopt+0x115c/0x2bf0 net/ipv4/ip_sockglue.c:1703
       ip_getsockopt+0x9c/0x1e0 net/ipv4/ip_sockglue.c:1765
       raw_getsockopt+0x4d/0x1e0 net/ipv4/raw.c:865
       do_sock_getsockopt+0x3fe/0x870 net/socket.c:2374
       __sys_getsockopt+0x12f/0x260 net/socket.c:2403
       __do_sys_getsockopt net/socket.c:2410 [inline]
       __se_sys_getsockopt net/socket.c:2407 [inline]
       __x64_sys_getsockopt+0xbd/0x160 net/socket.c:2407
       do_syscall_x64 arch/x86/entry/common.c:52 [inline]
       do_syscall_64+0xcd/0x250 arch/x86/entry/common.c:83
       entry_SYSCALL_64_after_hwframe+0x77/0x7f

-> #2 (rtnl_mutex){+.+.}-{4:4}:
       __mutex_lock_common kernel/locking/mutex.c:585 [inline]
       __mutex_lock+0x19b/0xa60 kernel/locking/mutex.c:735
       smc_vlan_by_tcpsk+0x251/0x620 net/smc/smc_core.c:1898
       __smc_connect+0x466/0x4890 net/smc/af_smc.c:1517
       smc_connect+0x2fc/0x760 net/smc/af_smc.c:1693
       __sys_connect_file+0x13e/0x1a0 net/socket.c:2055
       __sys_connect+0x14f/0x170 net/socket.c:2074
       __do_sys_connect net/socket.c:2080 [inline]
       __se_sys_connect net/socket.c:2077 [inline]
       __x64_sys_connect+0x72/0xb0 net/socket.c:2077
       do_syscall_x64 arch/x86/entry/common.c:52 [inline]
       do_syscall_64+0xcd/0x250 arch/x86/entry/common.c:83
       entry_SYSCALL_64_after_hwframe+0x77/0x7f

-> #1 (sk_lock-AF_SMC){+.+.}-{0:0}:
       lock_sock_nested+0x3a/0xf0 net/core/sock.c:3622
       lock_sock include/net/sock.h:1617 [inline]
       smc_close_non_accepted+0x80/0x200 net/smc/af_smc.c:1832
       smc_close_cleanup_listen net/smc/smc_close.c:45 [inline]
       smc_close_active+0xc3c/0x1070 net/smc/smc_close.c:225
       __smc_release+0x634/0x880 net/smc/af_smc.c:277
       smc_release+0x1fc/0x5f0 net/smc/af_smc.c:344
       __sock_release+0xb0/0x270 net/socket.c:640
       sock_close+0x1c/0x30 net/socket.c:1408
       __fput+0x3f8/0xb60 fs/file_table.c:450
       task_work_run+0x14e/0x250 kernel/task_work.c:239
       exit_task_work include/linux/task_work.h:43 [inline]
       do_exit+0xadd/0x2d70 kernel/exit.c:938
       do_group_exit+0xd3/0x2a0 kernel/exit.c:1087
       get_signal+0x2576/0x2610 kernel/signal.c:3017
       arch_do_signal_or_restart+0x90/0x7e0 arch/x86/kernel/signal.c:337
       exit_to_user_mode_loop kernel/entry/common.c:111 [inline]
       exit_to_user_mode_prepare include/linux/entry-common.h:329 [inline]
       __syscall_exit_to_user_mode_work kernel/entry/common.c:207 [inline]
       syscall_exit_to_user_mode+0x150/0x2a0 kernel/entry/common.c:218
       do_syscall_64+0xda/0x250 arch/x86/entry/common.c:89
       entry_SYSCALL_64_after_hwframe+0x77/0x7f

-> #0 (sk_lock-AF_INET/1){+.+.}-{0:0}:
       check_prev_add kernel/locking/lockdep.c:3161 [inline]
       check_prevs_add kernel/locking/lockdep.c:3280 [inline]
       validate_chain kernel/locking/lockdep.c:3904 [inline]
       __lock_acquire+0x249e/0x3c40 kernel/locking/lockdep.c:5226
       lock_acquire.part.0+0x11b/0x380 kernel/locking/lockdep.c:5849
       lock_sock_nested+0x3a/0xf0 net/core/sock.c:3622
       sctp_sock_migrate+0x987/0x1270 net/sctp/socket.c:9655
       sctp_accept+0x654/0x800 net/sctp/socket.c:4899
       inet_accept+0xc4/0x180 net/ipv4/af_inet.c:781
       do_accept+0x337/0x530 net/socket.c:1941
       __sys_accept4_file net/socket.c:1981 [inline]
       __sys_accept4+0xfe/0x1b0 net/socket.c:2010
       __do_sys_accept net/socket.c:2023 [inline]
       __se_sys_accept net/socket.c:2020 [inline]
       __x64_sys_accept+0x74/0xb0 net/socket.c:2020
       do_syscall_x64 arch/x86/entry/common.c:52 [inline]
       do_syscall_64+0xcd/0x250 arch/x86/entry/common.c:83
       entry_SYSCALL_64_after_hwframe+0x77/0x7f

other info that might help us debug this:

Chain exists of:
  sk_lock-AF_INET/1 --> rtnl_mutex --> sk_lock-AF_INET

 Possible unsafe locking scenario:

       CPU0                    CPU1
       ----                    ----
  lock(sk_lock-AF_INET);
                               lock(rtnl_mutex);
                               lock(sk_lock-AF_INET);
  lock(sk_lock-AF_INET/1);

 *** DEADLOCK ***

1 lock held by syz.5.1757/14440:
 #0: ffff88807f80dfd8 (sk_lock-AF_INET){+.+.}-{0:0}, at: lock_sock include/net/sock.h:1617 [inline]
 #0: ffff88807f80dfd8 (sk_lock-AF_INET){+.+.}-{0:0}, at: sctp_accept+0x90/0x800 net/sctp/socket.c:4863

stack backtrace:
CPU: 1 UID: 0 PID: 14440 Comm: syz.5.1757 Not tainted 6.13.0-rc2-syzkaller-00018-g7cb1b4663150 #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 09/13/2024
Call Trace:
 <TASK>
 __dump_stack lib/dump_stack.c:94 [inline]
 dump_stack_lvl+0x116/0x1f0 lib/dump_stack.c:120
 print_circular_bug+0x41c/0x610 kernel/locking/lockdep.c:2074
 check_noncircular+0x31a/0x400 kernel/locking/lockdep.c:2206
 check_prev_add kernel/locking/lockdep.c:3161 [inline]
 check_prevs_add kernel/locking/lockdep.c:3280 [inline]
 validate_chain kernel/locking/lockdep.c:3904 [inline]
 __lock_acquire+0x249e/0x3c40 kernel/locking/lockdep.c:5226
 lock_acquire.part.0+0x11b/0x380 kernel/locking/lockdep.c:5849
 lock_sock_nested+0x3a/0xf0 net/core/sock.c:3622
 sctp_sock_migrate+0x987/0x1270 net/sctp/socket.c:9655
 sctp_accept+0x654/0x800 net/sctp/socket.c:4899
 inet_accept+0xc4/0x180 net/ipv4/af_inet.c:781
 do_accept+0x337/0x530 net/socket.c:1941
 __sys_accept4_file net/socket.c:1981 [inline]
 __sys_accept4+0xfe/0x1b0 net/socket.c:2010
 __do_sys_accept net/socket.c:2023 [inline]
 __se_sys_accept net/socket.c:2020 [inline]
 __x64_sys_accept+0x74/0xb0 net/socket.c:2020
 do_syscall_x64 arch/x86/entry/common.c:52 [inline]
 do_syscall_64+0xcd/0x250 arch/x86/entry/common.c:83
 entry_SYSCALL_64_after_hwframe+0x77/0x7f
RIP: 0033:0x7f530297ff19
Code: ff ff c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 40 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 a8 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007f530381f058 EFLAGS: 00000246 ORIG_RAX: 000000000000002b
RAX: ffffffffffffffda RBX: 00007f5302b46080 RCX: 00007f530297ff19
RDX: 0000000020000140 RSI: 0000000020000100 RDI: 0000000000000003
RBP: 00007f53029f3cc8 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 0000000000000000 R14: 00007f5302b46080 R15: 00007fff22fccd28
 </TASK>
can: request_module (can-proto-4) failed.

Crashes (1):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2024/12/10 15:01 upstream 7cb1b4663150 cfc402b4 .config console log report info [disk image] [vmlinux] [kernel image] ci-qemu-gce-upstream-auto possible deadlock in sctp_sock_migrate
* Struck through repros no longer work on HEAD.