syzbot


possible deadlock in unix_gc

Status: auto-obsoleted due to no activity on 2024/08/08 16:50
Reported-by: syzbot+b08b278d99eaf14f330d@syzkaller.appspotmail.com
First crash: 204d, last: 204d

Sample crash report:
======================================================
WARNING: possible circular locking dependency detected
6.1.89-syzkaller #0 Not tainted
------------------------------------------------------
syz-executor.4/10657 is trying to acquire lock:
ffff88807bd31e80 (&u->lock){+.+.}-{2:2}, at: spin_lock include/linux/spinlock.h:351 [inline]
ffff88807bd31e80 (&u->lock){+.+.}-{2:2}, at: unix_gc+0x441/0x13d0 net/unix/garbage.c:263

but task is already holding lock:
ffffffff8e397ab8 (unix_gc_lock){+.+.}-{2:2}, at: spin_lock include/linux/spinlock.h:351 [inline]
ffffffff8e397ab8 (unix_gc_lock){+.+.}-{2:2}, at: unix_gc+0x115/0x13d0 net/unix/garbage.c:215

which lock already depends on the new lock.


the existing dependency chain (in reverse order) is:

-> #1 (unix_gc_lock){+.+.}-{2:2}:
       lock_acquire+0x1f8/0x5a0 kernel/locking/lockdep.c:5662
       __raw_spin_lock include/linux/spinlock_api_smp.h:133 [inline]
       _raw_spin_lock+0x2a/0x40 kernel/locking/spinlock.c:154
       spin_lock include/linux/spinlock.h:351 [inline]
       unix_notinflight+0x20a/0x380 net/unix/scm.c:73
       unix_detach_fds net/unix/scm.c:136 [inline]
       unix_destruct_scm+0x21d/0x350 net/unix/scm.c:147
       skb_release_head_state+0xf9/0x230 net/core/skbuff.c:843
       skb_release_all net/core/skbuff.c:854 [inline]
       __kfree_skb net/core/skbuff.c:870 [inline]
       kfree_skb_reason+0x13d/0x390 net/core/skbuff.c:893
       kfree_skb include/linux/skbuff.h:1220 [inline]
       manage_oob net/unix/af_unix.c:2684 [inline]
       unix_stream_read_generic+0xf91/0x2250 net/unix/af_unix.c:2761
       unix_stream_recvmsg+0x222/0x2b0 net/unix/af_unix.c:2956
       ____sys_recvmsg+0x285/0x530
       ___sys_recvmsg net/socket.c:2775 [inline]
       __sys_recvmsg+0x2e9/0x3d0 net/socket.c:2805
       do_syscall_x64 arch/x86/entry/common.c:51 [inline]
       do_syscall_64+0x3b/0xb0 arch/x86/entry/common.c:81
       entry_SYSCALL_64_after_hwframe+0x68/0xd2

-> #0 (&u->lock){+.+.}-{2:2}:
       check_prev_add kernel/locking/lockdep.c:3090 [inline]
       check_prevs_add kernel/locking/lockdep.c:3209 [inline]
       validate_chain+0x1661/0x5950 kernel/locking/lockdep.c:3825
       __lock_acquire+0x125b/0x1f80 kernel/locking/lockdep.c:5049
       lock_acquire+0x1f8/0x5a0 kernel/locking/lockdep.c:5662
       __raw_spin_lock include/linux/spinlock_api_smp.h:133 [inline]
       _raw_spin_lock+0x2a/0x40 kernel/locking/spinlock.c:154
       spin_lock include/linux/spinlock.h:351 [inline]
       unix_gc+0x441/0x13d0 net/unix/garbage.c:263
       unix_release_sock+0xab8/0xcf0 net/unix/af_unix.c:669
       unix_release+0x88/0xc0 net/unix/af_unix.c:1039
       __sock_release net/socket.c:654 [inline]
       sock_close+0xcd/0x230 net/socket.c:1400
       __fput+0x3b7/0x890 fs/file_table.c:320
       task_work_run+0x246/0x300 kernel/task_work.c:179
       resume_user_mode_work include/linux/resume_user_mode.h:49 [inline]
       exit_to_user_mode_loop+0xde/0x100 kernel/entry/common.c:177
       exit_to_user_mode_prepare+0xb1/0x140 kernel/entry/common.c:210
       __syscall_exit_to_user_mode_work kernel/entry/common.c:292 [inline]
       syscall_exit_to_user_mode+0x60/0x270 kernel/entry/common.c:303
       do_syscall_64+0x47/0xb0 arch/x86/entry/common.c:87
       entry_SYSCALL_64_after_hwframe+0x68/0xd2

other info that might help us debug this:

 Possible unsafe locking scenario:

       CPU0                    CPU1
       ----                    ----
  lock(unix_gc_lock);
                               lock(&u->lock);
                               lock(unix_gc_lock);
  lock(&u->lock);

 *** DEADLOCK ***

2 locks held by syz-executor.4/10657:
 #0: ffff888058bc6210 (&sb->s_type->i_mutex_key#10){+.+.}-{3:3}, at: inode_lock include/linux/fs.h:758 [inline]
 #0: ffff888058bc6210 (&sb->s_type->i_mutex_key#10){+.+.}-{3:3}, at: __sock_release net/socket.c:653 [inline]
 #0: ffff888058bc6210 (&sb->s_type->i_mutex_key#10){+.+.}-{3:3}, at: sock_close+0x98/0x230 net/socket.c:1400
 #1: ffffffff8e397ab8 (unix_gc_lock){+.+.}-{2:2}, at: spin_lock include/linux/spinlock.h:351 [inline]
 #1: ffffffff8e397ab8 (unix_gc_lock){+.+.}-{2:2}, at: unix_gc+0x115/0x13d0 net/unix/garbage.c:215

stack backtrace:
CPU: 0 PID: 10657 Comm: syz-executor.4 Not tainted 6.1.89-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 03/27/2024
Call Trace:
 <TASK>
 __dump_stack lib/dump_stack.c:88 [inline]
 dump_stack_lvl+0x1e3/0x2cb lib/dump_stack.c:106
 check_noncircular+0x2fa/0x3b0 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+0x1661/0x5950 kernel/locking/lockdep.c:3825
 __lock_acquire+0x125b/0x1f80 kernel/locking/lockdep.c:5049
 lock_acquire+0x1f8/0x5a0 kernel/locking/lockdep.c:5662
 __raw_spin_lock include/linux/spinlock_api_smp.h:133 [inline]
 _raw_spin_lock+0x2a/0x40 kernel/locking/spinlock.c:154
 spin_lock include/linux/spinlock.h:351 [inline]
 unix_gc+0x441/0x13d0 net/unix/garbage.c:263
 unix_release_sock+0xab8/0xcf0 net/unix/af_unix.c:669
 unix_release+0x88/0xc0 net/unix/af_unix.c:1039
 __sock_release net/socket.c:654 [inline]
 sock_close+0xcd/0x230 net/socket.c:1400
 __fput+0x3b7/0x890 fs/file_table.c:320
 task_work_run+0x246/0x300 kernel/task_work.c:179
 resume_user_mode_work include/linux/resume_user_mode.h:49 [inline]
 exit_to_user_mode_loop+0xde/0x100 kernel/entry/common.c:177
 exit_to_user_mode_prepare+0xb1/0x140 kernel/entry/common.c:210
 __syscall_exit_to_user_mode_work kernel/entry/common.c:292 [inline]
 syscall_exit_to_user_mode+0x60/0x270 kernel/entry/common.c:303
 do_syscall_64+0x47/0xb0 arch/x86/entry/common.c:87
 entry_SYSCALL_64_after_hwframe+0x68/0xd2
RIP: 0033:0x7f8c2967dea9
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:00007f8c2a47c0c8 EFLAGS: 00000246 ORIG_RAX: 00000000000001b4
RAX: 0000000000000000 RBX: 00007f8c297abf80 RCX: 00007f8c2967dea9
RDX: 0000000000000000 RSI: ffffffffffffffff RDI: 000000000000000a
RBP: 00007f8c296ca4a4 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 000000000000000b R14: 00007f8c297abf80 R15: 00007ffe0ac61468
 </TASK>

Crashes (1):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2024/04/30 16:49 linux-6.1.y dcbc050cb0d3 3ce4924c .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan possible deadlock in unix_gc
* Struck through repros no longer work on HEAD.