syzbot


possible deadlock in sk_diag_fill (3)
Status: upstream: reported on 2021/08/13 17:17
Reported-by: syzbot+00676df89338017efb46@syzkaller.appspotmail.com
First crash: 291d, last: 79d
similar bugs (2):
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
upstream possible deadlock in sk_diag_fill (2) 1 747d 746d 0/22 auto-closed as invalid on 2020/09/07 16:12
upstream possible deadlock in sk_diag_fill 30 1104d 1483d 0/22 auto-closed as invalid on 2019/10/25 08:39

Sample crash report:
======================================================
WARNING: possible circular locking dependency detected
5.16.0-rc6-syzkaller #0 Not tainted
------------------------------------------------------
syz-executor.2/9867 is trying to acquire lock:
ffff88802c9c8e78 (&u->lock/1){+.+.}-{2:2}, at: sk_diag_dump_icons net/unix/diag.c:86 [inline]
ffff88802c9c8e78 (&u->lock/1){+.+.}-{2:2}, at: sk_diag_fill+0xaa7/0x1100 net/unix/diag.c:154

but task is already holding lock:
ffff88807b8ec1d8 (rlock-AF_UNIX){+.+.}-{2:2}, at: spin_lock include/linux/spinlock.h:349 [inline]
ffff88807b8ec1d8 (rlock-AF_UNIX){+.+.}-{2:2}, at: sk_diag_dump_icons net/unix/diag.c:68 [inline]
ffff88807b8ec1d8 (rlock-AF_UNIX){+.+.}-{2:2}, at: sk_diag_fill+0x9bb/0x1100 net/unix/diag.c:154

which lock already depends on the new lock.


the existing dependency chain (in reverse order) is:

-> #1 (rlock-AF_UNIX){+.+.}-{2:2}:
       __raw_spin_lock_irqsave include/linux/spinlock_api_smp.h:110 [inline]
       _raw_spin_lock_irqsave+0x39/0x50 kernel/locking/spinlock.c:162
       skb_queue_tail+0x21/0x140 net/core/skbuff.c:3319
       unix_dgram_sendmsg+0xf60/0x1950 net/unix/af_unix.c:1939
       sock_sendmsg_nosec net/socket.c:704 [inline]
       sock_sendmsg+0xcf/0x120 net/socket.c:724
       io_send+0x349/0x4d0 fs/io_uring.c:4883
       io_issue_sqe+0x3814/0x7060 fs/io_uring.c:6694
       __io_queue_sqe fs/io_uring.c:7018 [inline]
       io_queue_sqe fs/io_uring.c:7060 [inline]
       io_submit_sqe fs/io_uring.c:7263 [inline]
       io_submit_sqes+0x1bca/0x8a20 fs/io_uring.c:7369
       __do_sys_io_uring_enter+0xf6e/0x1f50 fs/io_uring.c:10072
       do_syscall_x64 arch/x86/entry/common.c:50 [inline]
       do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80
       entry_SYSCALL_64_after_hwframe+0x44/0xae

-> #0 (&u->lock/1){+.+.}-{2:2}:
       check_prev_add kernel/locking/lockdep.c:3063 [inline]
       check_prevs_add kernel/locking/lockdep.c:3186 [inline]
       validate_chain kernel/locking/lockdep.c:3801 [inline]
       __lock_acquire+0x2a07/0x54a0 kernel/locking/lockdep.c:5027
       lock_acquire kernel/locking/lockdep.c:5637 [inline]
       lock_acquire+0x1ab/0x510 kernel/locking/lockdep.c:5602
       _raw_spin_lock_nested+0x30/0x40 kernel/locking/spinlock.c:368
       sk_diag_dump_icons net/unix/diag.c:86 [inline]
       sk_diag_fill+0xaa7/0x1100 net/unix/diag.c:154
       sk_diag_dump net/unix/diag.c:192 [inline]
       unix_diag_dump+0x399/0x590 net/unix/diag.c:220
       netlink_dump+0x4b0/0xb60 net/netlink/af_netlink.c:2270
       __netlink_dump_start+0x642/0x900 net/netlink/af_netlink.c:2375
       netlink_dump_start include/linux/netlink.h:254 [inline]
       unix_diag_handler_dump+0x411/0x7d0 net/unix/diag.c:319
       __sock_diag_cmd net/core/sock_diag.c:234 [inline]
       sock_diag_rcv_msg+0x31a/0x440 net/core/sock_diag.c:265
       netlink_rcv_skb+0x153/0x420 net/netlink/af_netlink.c:2496
       sock_diag_rcv+0x26/0x40 net/core/sock_diag.c:276
       netlink_unicast_kernel net/netlink/af_netlink.c:1319 [inline]
       netlink_unicast+0x533/0x7d0 net/netlink/af_netlink.c:1345
       netlink_sendmsg+0x904/0xdf0 net/netlink/af_netlink.c:1921
       sock_sendmsg_nosec net/socket.c:704 [inline]
       sock_sendmsg+0xcf/0x120 net/socket.c:724
       sock_write_iter+0x289/0x3c0 net/socket.c:1057
       call_write_iter include/linux/fs.h:2162 [inline]
       do_iter_readv_writev+0x472/0x750 fs/read_write.c:725
       do_iter_write+0x188/0x710 fs/read_write.c:851
       vfs_writev+0x1aa/0x630 fs/read_write.c:924
       do_writev+0x27f/0x300 fs/read_write.c:967
       do_syscall_x64 arch/x86/entry/common.c:50 [inline]
       do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80
       entry_SYSCALL_64_after_hwframe+0x44/0xae

other info that might help us debug this:

 Possible unsafe locking scenario:

       CPU0                    CPU1
       ----                    ----
  lock(rlock-AF_UNIX);
                               lock(&u->lock/1);
                               lock(rlock-AF_UNIX);
  lock(&u->lock/1);

 *** DEADLOCK ***

5 locks held by syz-executor.2/9867:
 #0: ffffffff8d317dc8 (sock_diag_mutex){+.+.}-{3:3}, at: sock_diag_rcv+0x17/0x40 net/core/sock_diag.c:275
 #1: ffffffff8d317f48 (sock_diag_table_mutex){+.+.}-{3:3}, at: __sock_diag_cmd net/core/sock_diag.c:229 [inline]
 #1: ffffffff8d317f48 (sock_diag_table_mutex){+.+.}-{3:3}, at: sock_diag_rcv_msg+0x19b/0x440 net/core/sock_diag.c:265
 #2: ffff88801eff8680 (nlk_cb_mutex-SOCK_DIAG){+.+.}-{3:3}, at: netlink_dump+0xb0/0xb60 net/netlink/af_netlink.c:2225
 #3: ffffffff8d4a7438 (unix_table_lock){+.+.}-{2:2}, at: spin_lock include/linux/spinlock.h:349 [inline]
 #3: ffffffff8d4a7438 (unix_table_lock){+.+.}-{2:2}, at: unix_diag_dump+0x119/0x590 net/unix/diag.c:206
 #4: ffff88807b8ec1d8 (rlock-AF_UNIX){+.+.}-{2:2}, at: spin_lock include/linux/spinlock.h:349 [inline]
 #4: ffff88807b8ec1d8 (rlock-AF_UNIX){+.+.}-{2:2}, at: sk_diag_dump_icons net/unix/diag.c:68 [inline]
 #4: ffff88807b8ec1d8 (rlock-AF_UNIX){+.+.}-{2:2}, at: sk_diag_fill+0x9bb/0x1100 net/unix/diag.c:154

stack backtrace:
CPU: 1 PID: 9867 Comm: syz-executor.2 Not tainted 5.16.0-rc6-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
Call Trace:
 <TASK>
 __dump_stack lib/dump_stack.c:88 [inline]
 dump_stack_lvl+0xcd/0x134 lib/dump_stack.c:106
 check_noncircular+0x25f/0x2e0 kernel/locking/lockdep.c:2143
 check_prev_add kernel/locking/lockdep.c:3063 [inline]
 check_prevs_add kernel/locking/lockdep.c:3186 [inline]
 validate_chain kernel/locking/lockdep.c:3801 [inline]
 __lock_acquire+0x2a07/0x54a0 kernel/locking/lockdep.c:5027
 lock_acquire kernel/locking/lockdep.c:5637 [inline]
 lock_acquire+0x1ab/0x510 kernel/locking/lockdep.c:5602
 _raw_spin_lock_nested+0x30/0x40 kernel/locking/spinlock.c:368
 sk_diag_dump_icons net/unix/diag.c:86 [inline]
 sk_diag_fill+0xaa7/0x1100 net/unix/diag.c:154
 sk_diag_dump net/unix/diag.c:192 [inline]
 unix_diag_dump+0x399/0x590 net/unix/diag.c:220
 netlink_dump+0x4b0/0xb60 net/netlink/af_netlink.c:2270
 __netlink_dump_start+0x642/0x900 net/netlink/af_netlink.c:2375
 netlink_dump_start include/linux/netlink.h:254 [inline]
 unix_diag_handler_dump+0x411/0x7d0 net/unix/diag.c:319
 __sock_diag_cmd net/core/sock_diag.c:234 [inline]
 sock_diag_rcv_msg+0x31a/0x440 net/core/sock_diag.c:265
 netlink_rcv_skb+0x153/0x420 net/netlink/af_netlink.c:2496
 sock_diag_rcv+0x26/0x40 net/core/sock_diag.c:276
 netlink_unicast_kernel net/netlink/af_netlink.c:1319 [inline]
 netlink_unicast+0x533/0x7d0 net/netlink/af_netlink.c:1345
 netlink_sendmsg+0x904/0xdf0 net/netlink/af_netlink.c:1921
 sock_sendmsg_nosec net/socket.c:704 [inline]
 sock_sendmsg+0xcf/0x120 net/socket.c:724
 sock_write_iter+0x289/0x3c0 net/socket.c:1057
 call_write_iter include/linux/fs.h:2162 [inline]
 do_iter_readv_writev+0x472/0x750 fs/read_write.c:725
 do_iter_write+0x188/0x710 fs/read_write.c:851
 vfs_writev+0x1aa/0x630 fs/read_write.c:924
 do_writev+0x27f/0x300 fs/read_write.c:967
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x44/0xae
RIP: 0033:0x7f39f05f5e99
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 bc ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007f39eef6b168 EFLAGS: 00000246 ORIG_RAX: 0000000000000014
RAX: ffffffffffffffda RBX: 00007f39f0708f60 RCX: 00007f39f05f5e99
RDX: 0000000000000001 RSI: 00000000200000c0 RDI: 0000000000000006
RBP: 00007f39f064fff1 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 00007ffe91f1e3ef R14: 00007f39eef6b300 R15: 0000000000022000
 </TASK>

Crashes (8):
Manager Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Title
ci-upstream-kasan-gce-selinux-root 2021/12/22 18:35 upstream 2f47a9a4dfa3 6caa12e4 .config log report info possible deadlock in sk_diag_fill
ci-upstream-kasan-gce 2021/11/02 18:38 upstream bfc484fe6abb 17f3edd2 .config log report info possible deadlock in sk_diag_fill
ci-upstream-kasan-gce-selinux-root 2021/09/24 21:10 upstream 4c4f0c2bf341 8cac236e .config log report info possible deadlock in sk_diag_fill
ci-upstream-kasan-gce-smack-root 2021/09/15 12:36 upstream 3ca706c189db 07e953c1 .config log report info possible deadlock in sk_diag_fill
ci-upstream-kasan-gce 2021/09/07 22:04 upstream a2b28235335f 064c9eb7 .config log report info possible deadlock in sk_diag_fill
ci-upstream-kasan-gce-smack-root 2021/08/09 17:09 upstream 36a21d51725a 6972b106 .config log report info possible deadlock in sk_diag_fill
ci-upstream-kasan-gce-386 2022/03/10 00:42 upstream e7e19defa575 9e8eaa75 .config log report info possible deadlock in sk_diag_fill
ci-upstream-kasan-gce-386 2021/12/02 01:06 upstream 58e1100fdc59 61f86278 .config log report info possible deadlock in sk_diag_fill