syzbot


possible deadlock in __loop_clr_fd (2)

Status: fixed on 2021/11/10 00:50
Reported-by: syzbot+f61766d5763f9e7a118f@syzkaller.appspotmail.com
Fix commit: 1c500ad70638 loop: reduce the loop_ctl_mutex scope
First crash: 574d, last: 445d

Cause bisection: introduced by (bisect log) [no-op commit]:
commit 86f0a011e548774fd8eb952f67bfeb19f3174dd0
Author: Julian Wiedmann <jwi@linux.ibm.com>
Date: Tue Mar 16 09:45:12 2021 +0000

  s390/dasd: remove dasd_fba_probe() wrapper

Crash: WARNING in kvm_wait (log)
Repro: C syz .config
similar bugs (2):
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
upstream possible deadlock in __loop_clr_fd 2 681d 677d 0/24 auto-closed as invalid on 2021/05/18 10:52
upstream possible deadlock in __loop_clr_fd (3) 2972 382d 445d 22/24 fixed on 2022/03/08 16:11
Last patch testing requests:
Created Duration User Patch Repo Result
2021/08/28 15:31 18m penguin-kernel@i-love.sakura.ne.jp patch upstream OK
2021/08/26 15:37 19m penguin-kernel@i-love.sakura.ne.jp patch upstream OK
2021/08/15 05:18 18m penguin-kernel@i-love.sakura.ne.jp patch upstream OK
2021/08/14 05:29 18m penguin-kernel@i-love.sakura.ne.jp patch upstream OK
2021/08/13 16:41 16m penguin-kernel@i-love.sakura.ne.jp patch upstream report log

Sample crash report:
loop0: detected capacity change from 0 to 4096
EXT4-fs error (device loop0): ext4_fill_super:4953: inode #2: comm syz-executor258: iget: root inode unallocated
EXT4-fs (loop0): get root inode failed
EXT4-fs (loop0): mount failed
======================================================
WARNING: possible circular locking dependency detected
5.14.0-rc3-next-20210729-syzkaller #0 Not tainted
------------------------------------------------------
syz-executor258/6697 is trying to acquire lock:
ffff88807dbec138 ((wq_completion)loop0){+.+.}-{0:0}, at: flush_workqueue+0xe1/0x1600 kernel/workqueue.c:2784

but task is already holding lock:
ffff88801d535468 (&lo->lo_mutex){+.+.}-{3:3}, at: __loop_clr_fd+0xaf/0x15e0 drivers/block/loop.c:1350

which lock already depends on the new lock.


the existing dependency chain (in reverse order) is:

-> #6 (&lo->lo_mutex){+.+.}-{3:3}:
       __mutex_lock_common kernel/locking/mutex.c:957 [inline]
       __mutex_lock+0x131/0x1300 kernel/locking/mutex.c:1096
       loop_control_remove drivers/block/loop.c:2449 [inline]
       loop_control_ioctl+0x22f/0x450 drivers/block/loop.c:2494
       vfs_ioctl fs/ioctl.c:51 [inline]
       __do_sys_ioctl fs/ioctl.c:866 [inline]
       __se_sys_ioctl fs/ioctl.c:852 [inline]
       __x64_sys_ioctl+0x193/0x200 fs/ioctl.c:852
       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

-> #5 (loop_ctl_mutex){+.+.}-{3:3}:
       __mutex_lock_common kernel/locking/mutex.c:957 [inline]
       __mutex_lock+0x131/0x1300 kernel/locking/mutex.c:1096
       loop_add+0x9c/0x940 drivers/block/loop.c:2314
       loop_probe+0x6a/0x80 drivers/block/loop.c:2426
       blk_request_module+0x111/0x1d0 block/genhd.c:673
       blkdev_get_no_open+0x178/0x1e0 fs/block_dev.c:1298
       blkdev_get_by_dev.part.0+0x23/0xd40 fs/block_dev.c:1362
       blkdev_get_by_dev fs/block_dev.c:1471 [inline]
       blkdev_open+0x295/0x300 fs/block_dev.c:1477
       do_dentry_open+0x4c8/0x11d0 fs/open.c:826
       do_open fs/namei.c:3374 [inline]
       path_openat+0x1c23/0x27f0 fs/namei.c:3507
       do_filp_open+0x1aa/0x400 fs/namei.c:3534
       do_sys_openat2+0x16d/0x420 fs/open.c:1204
       do_sys_open fs/open.c:1220 [inline]
       __do_sys_open fs/open.c:1228 [inline]
       __se_sys_open fs/open.c:1224 [inline]
       __x64_sys_open+0x119/0x1c0 fs/open.c:1224
       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

-> #4 (major_names_lock){+.+.}-{3:3}:
       __mutex_lock_common kernel/locking/mutex.c:957 [inline]
       __mutex_lock+0x131/0x1300 kernel/locking/mutex.c:1096
       blkdev_show+0x27/0x160 block/genhd.c:197
       devinfo_show+0xc1/0xf0 fs/proc/devices.c:22
       seq_read_iter+0xbb0/0x1240 fs/seq_file.c:272
       proc_reg_read_iter+0x1fb/0x2d0 fs/proc/inode.c:300
       call_read_iter include/linux/fs.h:2146 [inline]
       new_sync_read+0x41e/0x6e0 fs/read_write.c:415
       vfs_read+0x35c/0x570 fs/read_write.c:496
       ksys_read+0x12d/0x250 fs/read_write.c:634
       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

-> #3 (&p->lock){+.+.}-{3:3}:
       __mutex_lock_common kernel/locking/mutex.c:957 [inline]
       __mutex_lock+0x131/0x1300 kernel/locking/mutex.c:1096
       seq_read_iter+0xdf/0x1240 fs/seq_file.c:182
       call_read_iter include/linux/fs.h:2146 [inline]
       generic_file_splice_read+0x450/0x6c0 fs/splice.c:311
       do_splice_to+0x1bf/0x250 fs/splice.c:796
       splice_direct_to_actor+0x2c2/0x8c0 fs/splice.c:870
       do_splice_direct+0x1b3/0x280 fs/splice.c:979
       do_sendfile+0x9f0/0x1120 fs/read_write.c:1260
       __do_sys_sendfile64 fs/read_write.c:1325 [inline]
       __se_sys_sendfile64 fs/read_write.c:1311 [inline]
       __x64_sys_sendfile64+0x1cc/0x210 fs/read_write.c:1311
       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

-> #2 (sb_writers#3){.+.+}-{0:0}:
       percpu_down_read include/linux/percpu-rwsem.h:51 [inline]
       __sb_start_write include/linux/fs.h:1801 [inline]
       sb_start_write include/linux/fs.h:1871 [inline]
       file_start_write include/linux/fs.h:3080 [inline]
       lo_write_bvec+0x3b6/0x6d0 drivers/block/loop.c:327
       lo_write_simple drivers/block/loop.c:350 [inline]
       do_req_filebacked drivers/block/loop.c:668 [inline]
       loop_handle_cmd drivers/block/loop.c:2202 [inline]
       loop_process_work+0xc60/0x24e0 drivers/block/loop.c:2242
       process_one_work+0x98d/0x1630 kernel/workqueue.c:2276
       worker_thread+0x658/0x11f0 kernel/workqueue.c:2422
       kthread+0x3e5/0x4d0 kernel/kthread.c:319
       ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:295

-> #1 ((work_completion)(&lo->rootcg_work)){+.+.}-{0:0}:
       process_one_work+0x8fc/0x1630 kernel/workqueue.c:2252
       worker_thread+0x658/0x11f0 kernel/workqueue.c:2422
       kthread+0x3e5/0x4d0 kernel/kthread.c:319
       ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:295

-> #0 ((wq_completion)loop0){+.+.}-{0:0}:
       check_prev_add kernel/locking/lockdep.c:3051 [inline]
       check_prevs_add kernel/locking/lockdep.c:3174 [inline]
       validate_chain kernel/locking/lockdep.c:3789 [inline]
       __lock_acquire+0x2a07/0x54a0 kernel/locking/lockdep.c:5015
       lock_acquire kernel/locking/lockdep.c:5625 [inline]
       lock_acquire+0x1ab/0x510 kernel/locking/lockdep.c:5590
       flush_workqueue+0x110/0x1600 kernel/workqueue.c:2787
       drain_workqueue+0x1a5/0x3c0 kernel/workqueue.c:2952
       destroy_workqueue+0x71/0x800 kernel/workqueue.c:4389
       __loop_clr_fd+0x212/0x15e0 drivers/block/loop.c:1368
       loop_clr_fd drivers/block/loop.c:1494 [inline]
       lo_ioctl+0x3c3/0x1880 drivers/block/loop.c:1850
       blkdev_ioctl+0x2a1/0x6d0 block/ioctl.c:587
       block_ioctl+0xf9/0x140 fs/block_dev.c:1569
       vfs_ioctl fs/ioctl.c:51 [inline]
       __do_sys_ioctl fs/ioctl.c:866 [inline]
       __se_sys_ioctl fs/ioctl.c:852 [inline]
       __x64_sys_ioctl+0x193/0x200 fs/ioctl.c:852
       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:

Chain exists of:
  (wq_completion)loop0 --> loop_ctl_mutex --> &lo->lo_mutex

 Possible unsafe locking scenario:

       CPU0                    CPU1
       ----                    ----
  lock(&lo->lo_mutex);
                               lock(loop_ctl_mutex);
                               lock(&lo->lo_mutex);
  lock((wq_completion)loop0);

 *** DEADLOCK ***

1 lock held by syz-executor258/6697:
 #0: ffff88801d535468 (&lo->lo_mutex){+.+.}-{3:3}, at: __loop_clr_fd+0xaf/0x15e0 drivers/block/loop.c:1350

stack backtrace:
CPU: 1 PID: 6697 Comm: syz-executor258 Not tainted 5.14.0-rc3-next-20210729-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
Call Trace:
 __dump_stack lib/dump_stack.c:88 [inline]
 dump_stack_lvl+0xcd/0x134 lib/dump_stack.c:105
 check_noncircular+0x25f/0x2e0 kernel/locking/lockdep.c:2131
 check_prev_add kernel/locking/lockdep.c:3051 [inline]
 check_prevs_add kernel/locking/lockdep.c:3174 [inline]
 validate_chain kernel/locking/lockdep.c:3789 [inline]
 __lock_acquire+0x2a07/0x54a0 kernel/locking/lockdep.c:5015
 lock_acquire kernel/locking/lockdep.c:5625 [inline]
 lock_acquire+0x1ab/0x510 kernel/locking/lockdep.c:5590
 flush_workqueue+0x110/0x1600 kernel/workqueue.c:2787
 drain_workqueue+0x1a5/0x3c0 kernel/workqueue.c:2952
 destroy_workqueue+0x71/0x800 kernel/workqueue.c:4389
 __loop_clr_fd+0x212/0x15e0 drivers/block/loop.c:1368
 loop_clr_fd drivers/block/loop.c:1494 [inline]
 lo_ioctl+0x3c3/0x1880 drivers/block/loop.c:1850
 blkdev_ioctl+0x2a1/0x6d0 block/ioctl.c:587
 block_ioctl+0xf9/0x140 fs/block_dev.c:1569
 vfs_ioctl fs/ioctl.c:51 [inline]
 __do_sys_ioctl fs/ioctl.c:866 [inline]
 __se_sys_ioctl fs/ioctl.c:852 [inline]
 __x64_sys_ioctl+0x193/0x200 fs/ioctl.c:852
 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:0x444717
Code: 3c 1c 48 f7 d8 49 39 c4 72 b8 e8 44 3a 02 00 85 c0 78 bd 48 83 c4 08 4c 89 e0 5b 41 5c c3 0f 1f 44 00 00 b8 10 00 00 00 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 c0 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007fffab8ca568 EFLAGS: 00000246 ORIG_RAX: 0000000000000010
RAX: ffffffffffffffda RBX: 00000000016232c0 RCX: 0000000000444717
RDX: 0000000000000000 RSI: 0000000000004c01 RDI: 0000000000000007
RBP: 0000000000000075 R08: 00007fffab8ca5c0 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 00000000200002a8
R13: 0000000000000006 R14: 0000000000000007 R15: 0000000000000007

Crashes (6977):
Manager Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets Title
ci-upstream-linux-next-kasan-gce-root 2021/07/30 08:27 linux-next 4ccc9e2db7ac c585c7b0 .config console log report syz C possible deadlock in __loop_clr_fd
ci-upstream-kasan-gce 2021/11/10 00:00 upstream d2f38a3c6507 59bcaf9a .config console log report info possible deadlock in __loop_clr_fd
ci-upstream-kasan-gce 2021/11/09 22:26 upstream d2f38a3c6507 59bcaf9a .config console log report info possible deadlock in __loop_clr_fd
ci-upstream-kasan-gce 2021/11/09 20:56 upstream d2f38a3c6507 59bcaf9a .config console log report info possible deadlock in __loop_clr_fd
ci-upstream-kasan-gce-smack-root 2021/11/09 16:26 upstream d2f38a3c6507 59bcaf9a .config console log report info possible deadlock in __loop_clr_fd
ci-upstream-kasan-gce-smack-root 2021/11/09 14:49 upstream d2f38a3c6507 59bcaf9a .config console log report info possible deadlock in __loop_clr_fd
ci-upstream-kasan-gce 2021/11/09 13:46 upstream d2f38a3c6507 59bcaf9a .config console log report info possible deadlock in __loop_clr_fd
ci-upstream-kasan-gce 2021/11/09 11:43 upstream e851dfae4371 8ab17e57 .config console log report info possible deadlock in __loop_clr_fd
ci-upstream-kasan-gce 2021/11/09 10:35 upstream e851dfae4371 8ab17e57 .config console log report info possible deadlock in __loop_clr_fd
ci-upstream-kasan-gce 2021/11/09 09:33 upstream e851dfae4371 8ab17e57 .config console log report info possible deadlock in __loop_clr_fd
ci-upstream-kasan-gce 2021/11/09 08:12 upstream e851dfae4371 8ab17e57 .config console log report info possible deadlock in __loop_clr_fd
ci-upstream-kasan-gce 2021/11/09 07:20 upstream e851dfae4371 8ab17e57 .config console log report info possible deadlock in __loop_clr_fd
ci-upstream-kasan-gce 2021/11/09 06:19 upstream e851dfae4371 8ab17e57 .config console log report info possible deadlock in __loop_clr_fd
ci-upstream-kasan-gce 2021/11/09 01:11 upstream e851dfae4371 8ab17e57 .config console log report info possible deadlock in __loop_clr_fd
ci-upstream-kasan-gce 2021/11/08 19:40 upstream e851dfae4371 d29682f1 .config console log report info possible deadlock in __loop_clr_fd
ci-upstream-kasan-gce 2021/11/08 18:35 upstream e851dfae4371 d29682f1 .config console log report info possible deadlock in __loop_clr_fd
ci-upstream-kasan-gce 2021/11/08 18:20 upstream e851dfae4371 d29682f1 .config console log report info possible deadlock in __loop_clr_fd
ci-upstream-kasan-gce 2021/11/08 17:18 upstream 6b75d88fa81b d29682f1 .config console log report info possible deadlock in __loop_clr_fd
ci-upstream-kasan-gce-smack-root 2021/11/08 13:09 upstream 6b75d88fa81b d29682f1 .config console log report info possible deadlock in __loop_clr_fd
ci-upstream-kasan-gce 2021/11/08 12:08 upstream 6b75d88fa81b d29682f1 .config console log report info possible deadlock in __loop_clr_fd
ci-upstream-kasan-gce 2021/11/08 11:05 upstream 6b75d88fa81b 4c1be0be .config console log report info possible deadlock in __loop_clr_fd
ci-upstream-kasan-gce 2021/11/08 10:31 upstream 6b75d88fa81b 4c1be0be .config console log report info possible deadlock in __loop_clr_fd
ci-upstream-kasan-gce 2021/11/08 09:03 upstream 6b75d88fa81b 4c1be0be .config console log report info possible deadlock in __loop_clr_fd
ci-upstream-kasan-gce 2021/11/08 07:55 upstream 6b75d88fa81b 4c1be0be .config console log report info possible deadlock in __loop_clr_fd
ci-upstream-kasan-gce 2021/11/08 06:48 upstream 6b75d88fa81b 4c1be0be .config console log report info possible deadlock in __loop_clr_fd
ci-qemu-upstream 2021/11/08 04:18 upstream 6b75d88fa81b 4c1be0be .config console log report info possible deadlock in __loop_clr_fd
ci-upstream-kasan-gce 2021/11/08 01:00 upstream 6b75d88fa81b 4c1be0be .config console log report info possible deadlock in __loop_clr_fd
ci-upstream-kasan-gce 2021/11/08 00:06 upstream b5013d084e03 4c1be0be .config console log report info possible deadlock in __loop_clr_fd
ci-upstream-kasan-gce-root 2021/11/07 23:05 upstream b5013d084e03 4c1be0be .config console log report info possible deadlock in __loop_clr_fd
ci-upstream-kasan-gce 2021/11/07 21:47 upstream b5013d084e03 4c1be0be .config console log report info possible deadlock in __loop_clr_fd
ci-upstream-kasan-gce 2021/11/07 21:26 upstream b5013d084e03 4c1be0be .config console log report info possible deadlock in __loop_clr_fd
ci-upstream-kasan-gce 2021/11/07 20:24 upstream b5013d084e03 4c1be0be .config console log report info possible deadlock in __loop_clr_fd
ci-upstream-kasan-gce 2021/11/07 18:17 upstream b5013d084e03 4c1be0be .config console log report info possible deadlock in __loop_clr_fd
ci-upstream-kasan-gce-selinux-root 2021/11/07 13:11 upstream b5013d084e03 4c1be0be .config console log report info possible deadlock in __loop_clr_fd
ci-upstream-kasan-gce 2021/11/07 13:00 upstream b5013d084e03 4c1be0be .config console log report info possible deadlock in __loop_clr_fd
ci-upstream-kasan-gce-root 2021/11/07 11:55 upstream b5013d084e03 4c1be0be .config console log report info possible deadlock in __loop_clr_fd
ci-upstream-kasan-gce 2021/07/06 03:59 upstream 3dbdb38e2869 55aa55c2 .config console log report info possible deadlock in __loop_clr_fd
ci-upstream-kasan-gce 2021/07/04 01:17 upstream 3dbdb38e2869 55aa55c2 .config console log report info possible deadlock in __loop_clr_fd
ci-upstream-kasan-gce-386 2021/11/09 02:16 upstream e851dfae4371 8ab17e57 .config console log report info possible deadlock in __loop_clr_fd
ci-upstream-kasan-gce-386 2021/11/09 00:40 upstream e851dfae4371 8ab17e57 .config console log report info possible deadlock in __loop_clr_fd
ci-upstream-kasan-gce-386 2021/11/08 22:11 upstream e851dfae4371 d29682f1 .config console log report info possible deadlock in __loop_clr_fd
ci-upstream-kasan-gce-386 2021/11/08 21:09 upstream e851dfae4371 d29682f1 .config console log report info possible deadlock in __loop_clr_fd
ci-qemu-upstream-386 2021/11/08 20:42 upstream e851dfae4371 d29682f1 .config console log report info possible deadlock in __loop_clr_fd
ci-upstream-kasan-gce-386 2021/11/08 14:11 upstream 6b75d88fa81b d29682f1 .config console log report info possible deadlock in __loop_clr_fd
ci-upstream-kasan-gce-386 2021/11/08 02:59 upstream 6b75d88fa81b 4c1be0be .config console log report info possible deadlock in __loop_clr_fd
ci-upstream-kasan-gce-386 2021/11/07 15:20 upstream b5013d084e03 4c1be0be .config console log report info possible deadlock in __loop_clr_fd
ci-upstream-kasan-gce-386 2021/11/07 14:20 upstream b5013d084e03 4c1be0be .config console log report info possible deadlock in __loop_clr_fd
ci-upstream-linux-next-kasan-gce-root 2021/11/09 14:46 linux-next c8109c2ba35e 59bcaf9a .config console log report info possible deadlock in __loop_clr_fd
ci-upstream-linux-next-kasan-gce-root 2021/11/09 04:11 linux-next c8109c2ba35e 8ab17e57 .config console log report info possible deadlock in __loop_clr_fd
ci-upstream-linux-next-kasan-gce-root 2021/11/08 23:39 linux-next e844ee04dee0 8ab17e57 .config console log report info possible deadlock in __loop_clr_fd
ci-upstream-linux-next-kasan-gce-root 2021/11/08 02:04 linux-next 6a37ebbe07bf 4c1be0be .config console log report info possible deadlock in __loop_clr_fd
ci-upstream-linux-next-kasan-gce-root 2021/11/07 19:20 linux-next 6a37ebbe07bf 4c1be0be .config console log report info possible deadlock in __loop_clr_fd
ci-upstream-linux-next-kasan-gce-root 2021/11/07 16:58 linux-next 6a37ebbe07bf 4c1be0be .config console log report info possible deadlock in __loop_clr_fd
ci-upstream-linux-next-kasan-gce-root 2021/11/07 11:25 linux-next 6a37ebbe07bf 4c1be0be .config console log report info possible deadlock in __loop_clr_fd
* Struck through repros no longer work on HEAD.