syzbot


possible deadlock in unix_notinflight

Status: fixed on 2024/05/09 08:21
Reported-by: syzbot+639d2cc188ba16f9f7f2@syzkaller.appspotmail.com
Fix commit: 84a352b7eba1 af_unix: Clear stale u->oob_skb.
First crash: 67d, last: 67d
Fix bisection: fixed by (bisect log) :
commit 84a352b7eba1142a95441380058985ff19f25ec9
Author: Kuniyuki Iwashima <kuniyu@amazon.com>
Date: Fri Apr 5 22:10:57 2024 +0000

  af_unix: Clear stale u->oob_skb.

  
Bug presence (1)
Date Name Commit Repro Result
2024/04/24 upstream (ToT) 9d1ddab261f3 C Didn't crash
Similar bugs (2)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
upstream possible deadlock in unix_notinflight net C 7 49d 64d 26/28 fixed on 2024/05/22 23:16
linux-5.15 possible deadlock in unix_notinflight C unreliable 3 48d 67d 0/3 upstream: reported C repro on 2024/04/07 16:29

Sample crash report:
============================================
WARNING: possible recursive locking detected
6.1.84-syzkaller #0 Not tainted
--------------------------------------------
dhcpcd/3216 is trying to acquire lock:
ffffffff8e396738 (unix_gc_lock){+.+.}-{2:2}, at: spin_lock include/linux/spinlock.h:351 [inline]
ffffffff8e396738 (unix_gc_lock){+.+.}-{2:2}, at: unix_notinflight+0x297/0x390 net/unix/scm.c:72

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

other info that might help us debug this:
 Possible unsafe locking scenario:

       CPU0
       ----
  lock(unix_gc_lock);
  lock(unix_gc_lock);

 *** DEADLOCK ***

 May be due to missing lock nesting notation

2 locks held by dhcpcd/3216:
 #0: ffff888073a56210 (&sb->s_type->i_mutex_key#10){+.+.}-{3:3}, at: inode_lock include/linux/fs.h:758 [inline]
 #0: ffff888073a56210 (&sb->s_type->i_mutex_key#10){+.+.}-{3:3}, at: __sock_release net/socket.c:653 [inline]
 #0: ffff888073a56210 (&sb->s_type->i_mutex_key#10){+.+.}-{3:3}, at: sock_close+0x98/0x230 net/socket.c:1400
 #1: ffffffff8e396738 (unix_gc_lock){+.+.}-{2:2}, at: spin_lock include/linux/spinlock.h:351 [inline]
 #1: ffffffff8e396738 (unix_gc_lock){+.+.}-{2:2}, at: unix_gc+0x115/0x1380 net/unix/garbage.c:214

stack backtrace:
CPU: 0 PID: 3216 Comm: dhcpcd Not tainted 6.1.84-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
 print_deadlock_bug kernel/locking/lockdep.c:2983 [inline]
 check_deadlock kernel/locking/lockdep.c:3026 [inline]
 validate_chain+0x4711/0x5950 kernel/locking/lockdep.c:3812
 __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_notinflight+0x297/0x390 net/unix/scm.c:72
 unix_detach_fds net/unix/scm.c:134 [inline]
 unix_destruct_scm+0x21d/0x350 net/unix/scm.c:145
 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:1225 [inline]
 unix_gc+0xb2e/0x1380 net/unix/garbage.c:292
 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+0x49/0xb0 arch/x86/entry/common.c:87
 entry_SYSCALL_64_after_hwframe+0x63/0xcd
RIP: 0033:0x7f480d0dd0a8
Code: 48 8b 05 83 9d 0d 00 64 c7 00 16 00 00 00 83 c8 ff 48 83 c4 20 5b c3 64 8b 04 25 18 00 00 00 85 c0 75 20 b8 03 00 00 00 0f 05 <48> 3d 00 f0 ff ff 76 5b 48 8b 15 51 9d 0d 00 f7 d8 64 89 02 48 83
RSP: 002b:00007ffe4d7a18b8 EFLAGS: 00000246 ORIG_RAX: 0000000000000003
RAX: 0000000000000000 RBX: 0000000000000004 RCX: 00007f480d0dd0a8
RDX: 0000000000000000 RSI: 0000000000000002 RDI: 0000000000000010
RBP: 00007ffe4d7c1c68 R08: 0000000000000007 R09: 96d59ce5aedcbe24
R10: 0000000000004000 R11: 0000000000000246 R12: 0000558f584c1ad0
R13: 00007ffe4d7b1aa8 R14: 0000000000000148 R15: 0000000000000004
 </TASK>

Crashes (1):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2024/04/08 06:44 linux-6.1.y 347385861c50 ca620dd8 .config console log report syz C [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan-perf possible deadlock in unix_notinflight
* Struck through repros no longer work on HEAD.