syzbot


possible deadlock in generic_file_write_iter

Status: auto-closed as invalid on 2020/10/01 23:22
Reported-by: syzbot+09f6e253ac5990621a05@syzkaller.appspotmail.com
First crash: 1707d, last: 1633d
Similar bugs (5)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
upstream possible deadlock in generic_file_write_iter (2) fs 182 2534d 2546d 0/28 closed as invalid on 2018/02/13 19:29
linux-4.19 possible deadlock in generic_file_write_iter 4 1628d 1636d 0/1 auto-closed as invalid on 2020/10/06 15:19
linux-4.19 possible deadlock in generic_file_write_iter (2) C error 453 667d 1236d 0/1 upstream: reported C repro on 2021/07/06 07:41
linux-4.14 possible deadlock in generic_file_write_iter (2) C 20 634d 1066d 0/1 upstream: reported C repro on 2021/12/23 04:07
upstream possible deadlock in generic_file_write_iter C 61506 2552d 2575d 3/28 fixed on 2017/11/28 03:36

Sample crash report:
R13: 00000000000001fb R14: 00000000004c4486 R15: 00007f1d048ea6d4
base_sock_release(ffff88804b783a40) sk=ffff888092888c80
kvm: emulating exchange as write
Dev loop5: unable to read RDB block 1
======================================================
WARNING: possible circular locking dependency detected
4.14.183-syzkaller #0 Not tainted
------------------------------------------------------
syz-executor.2/17437 is trying to acquire lock:
 ("dio/%s"sb->s_id){+.+.}, at: [<ffffffff813a9d7a>] flush_workqueue+0xda/0x1380 kernel/workqueue.c:2621
 loop5: unable to read partition table

but task is already holding lock:
 (&sb->s_type->i_mutex_key#26){++++}, at: [<ffffffff816e3239>] inode_lock include/linux/fs.h:719 [inline]
 (&sb->s_type->i_mutex_key#26){++++}, at: [<ffffffff816e3239>] generic_file_write_iter+0x99/0x650 mm/filemap.c:3197

which lock already depends on the new lock.

loop5: partition table beyond EOD, 

the existing dependency chain (in reverse order) is:

-> #2 (&sb->s_type->i_mutex_key#26){++++}:
       down_write+0x34/0x90 kernel/locking/rwsem.c:54
       inode_lock include/linux/fs.h:719 [inline]
       __generic_file_fsync+0x9e/0x190 fs/libfs.c:987
       fat_file_fsync+0x73/0x1f0 fs/fat/file.c:165
truncated
       vfs_fsync_range+0x103/0x250 fs/sync.c:196
       generic_write_sync include/linux/fs.h:2678 [inline]
       dio_complete+0x3ae/0x840 fs/direct-io.c:330
       process_one_work+0x7c0/0x14c0 kernel/workqueue.c:2116
       worker_thread+0x5d7/0x1080 kernel/workqueue.c:2250
       kthread+0x30d/0x420 kernel/kthread.c:232
       ret_from_fork+0x24/0x30 arch/x86/entry/entry_64.S:404

-> #1
loop_reread_partitions: partition scan of loop5 () failed (rc=-5)
 ((&dio->complete_work)){+.+.}:
       process_one_work+0x762/0x14c0 kernel/workqueue.c:2092
       worker_thread+0x5d7/0x1080 kernel/workqueue.c:2250
       kthread+0x30d/0x420 kernel/kthread.c:232
       ret_from_fork+0x24/0x30 arch/x86/entry/entry_64.S:404

-> #0 ("dio/%s"sb->s_id){+.+.}:
       lock_acquire+0x170/0x3f0 kernel/locking/lockdep.c:3998
       flush_workqueue+0x109/0x1380 kernel/workqueue.c:2624
       drain_workqueue+0x177/0x3e0 kernel/workqueue.c:2789
       destroy_workqueue+0x71/0x660 kernel/workqueue.c:4102
       __alloc_workqueue_key+0xb65/0xdc0 kernel/workqueue.c:4079
       sb_init_dio_done_wq+0x34/0x80 fs/direct-io.c:624
       do_blockdev_direct_IO fs/direct-io.c:1286 [inline]
       __blockdev_direct_IO+0x2f6f/0xe97c fs/direct-io.c:1422
       blockdev_direct_IO include/linux/fs.h:2988 [inline]
       fat_direct_IO+0x19b/0x2b0 fs/fat/inode.c:275
       generic_file_direct_write+0x1df/0x420 mm/filemap.c:2950
       __generic_file_write_iter+0x2a5/0x590 mm/filemap.c:3129
       generic_file_write_iter+0x36f/0x650 mm/filemap.c:3200
       call_write_iter include/linux/fs.h:1778 [inline]
       aio_write+0x2ba/0x4f0 fs/aio.c:1553
       io_submit_one fs/aio.c:1641 [inline]
       do_io_submit+0x930/0x1400 fs/aio.c:1709
       do_syscall_64+0x1d5/0x640 arch/x86/entry/common.c:292
       entry_SYSCALL_64_after_hwframe+0x46/0xbb

other info that might help us debug this:

Chain exists of:
  "dio/%s"sb->s_id --> (&dio->complete_work) --> &sb->s_type->i_mutex_key#26

 Possible unsafe locking scenario:

       CPU0                    CPU1
       ----                    ----
  lock(&sb->s_type->i_mutex_key#26);
                               lock((&dio->complete_work));
                               lock(&sb->s_type->i_mutex_key#26);
  lock("dio/%s"sb->s_id);

 *** DEADLOCK ***

2 locks held by syz-executor.2/17437:
 #0:  (sb_writers#22){.+.+}, at: [<ffffffff819c1d9c>] file_start_write include/linux/fs.h:2708 [inline]
 #0:  (sb_writers#22){.+.+}, at: [<ffffffff819c1d9c>] aio_write+0x3dc/0x4f0 fs/aio.c:1552
 #1:  (&sb->s_type->i_mutex_key#26){++++}, at: [<ffffffff816e3239>] inode_lock include/linux/fs.h:719 [inline]
 #1:  (&sb->s_type->i_mutex_key#26){++++}, at: [<ffffffff816e3239>] generic_file_write_iter+0x99/0x650 mm/filemap.c:3197

stack backtrace:
CPU: 1 PID: 17437 Comm: syz-executor.2 Not tainted 4.14.183-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
Call Trace:
 __dump_stack lib/dump_stack.c:17 [inline]
 dump_stack+0x1b2/0x283 lib/dump_stack.c:58
 print_circular_bug.isra.0.cold+0x2dc/0x425 kernel/locking/lockdep.c:1258
 check_prev_add kernel/locking/lockdep.c:1905 [inline]
 check_prevs_add kernel/locking/lockdep.c:2022 [inline]
 validate_chain kernel/locking/lockdep.c:2464 [inline]
 __lock_acquire+0x3057/0x42a0 kernel/locking/lockdep.c:3491
 lock_acquire+0x170/0x3f0 kernel/locking/lockdep.c:3998
 flush_workqueue+0x109/0x1380 kernel/workqueue.c:2624
 drain_workqueue+0x177/0x3e0 kernel/workqueue.c:2789
 destroy_workqueue+0x71/0x660 kernel/workqueue.c:4102
 __alloc_workqueue_key+0xb65/0xdc0 kernel/workqueue.c:4079
 sb_init_dio_done_wq+0x34/0x80 fs/direct-io.c:624
 do_blockdev_direct_IO fs/direct-io.c:1286 [inline]
 __blockdev_direct_IO+0x2f6f/0xe97c fs/direct-io.c:1422
 blockdev_direct_IO include/linux/fs.h:2988 [inline]
 fat_direct_IO+0x19b/0x2b0 fs/fat/inode.c:275
 generic_file_direct_write+0x1df/0x420 mm/filemap.c:2950
 __generic_file_write_iter+0x2a5/0x590 mm/filemap.c:3129
 generic_file_write_iter+0x36f/0x650 mm/filemap.c:3200
 call_write_iter include/linux/fs.h:1778 [inline]
 aio_write+0x2ba/0x4f0 fs/aio.c:1553
 io_submit_one fs/aio.c:1641 [inline]
 do_io_submit+0x930/0x1400 fs/aio.c:1709
 do_syscall_64+0x1d5/0x640 arch/x86/entry/common.c:292
 entry_SYSCALL_64_after_hwframe+0x46/0xbb
RIP: 0033:0x45ca69
RSP: 002b:00007f1d048e9c78 EFLAGS: 00000246 ORIG_RAX: 00000000000000d1
RAX: ffffffffffffffda RBX: 00000000004e0d40 RCX: 000000000045ca69
RDX: 0000000020000540 RSI: 0000000000000006 RDI: 00007f1d048c7000
RBP: 000000000078bf00 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000007
R13: 00000000000001fb R14: 00000000004c4486 R15: 00007f1d048ea6d4
Dev loop5: unable to read RDB block 1
 loop5: unable to read partition table
base_sock_release(ffff88804b68a600) sk=ffff888051008a80
loop5: partition table beyond EOD, truncated
loop_reread_partitions: partition scan of loop5 () failed (rc=-5)
base_sock_release(ffff8880563f24c0) sk=ffff888058cba540
FAT-fs (loop2): invalid media value (0x75)
FAT-fs (loop2): Can't find a valid FAT filesystem
ceph: device name is missing path (no : separator in /dev/loop2)
Dev loop5: unable to read RDB block 1
 loop5: unable to read partition table
loop5: partition table beyond EOD, truncated
loop_reread_partitions: partition scan of loop5 () failed (rc=-5)
FAT-fs (loop2): error, invalid access to FAT (entry 0x00000020)
FAT-fs (loop2): Filesystem has been set read-only
FAT-fs (loop2): error, invalid access to FAT (entry 0x00000020)
Dev loop5: unable to read RDB block 1
 loop5: unable to read partition table
attempt to access beyond end of device
loop5: partition table beyond EOD, truncated
loop2: rw=34817, want=157, limit=116
loop_reread_partitions: partition scan of loop5 () failed (rc=-5)
Dev loop5: unable to read RDB block 1
 loop5: unable to read partition table
loop5: partition table beyond EOD, truncated
loop_reread_partitions: partition scan of loop5 () failed (rc=-5)
Dev loop5: unable to read RDB block 1
 loop5: unable to read partition table
loop5: partition table beyond EOD, truncated
loop_reread_partitions: partition scan of loop5 () failed (rc=-5)
FAT-fs (loop2): error, invalid access to FAT (entry 0x00000020)
FAT-fs (loop2): Filesystem has been set read-only
Dev loop5: unable to read RDB block 1
 loop5: unable to read partition table
FAT-fs (loop2): error, invalid access to FAT (entry 0x00000020)
loop5: partition table beyond EOD, truncated
loop_reread_partitions: partition scan of loop5 () failed (rc=-5)
Dev loop5: unable to read RDB block 1
 loop5: unable to read partition table
loop5: partition table beyond EOD, truncated
loop_reread_partitions: partition scan of loop5 () failed (rc=-5)
FAT-fs (loop2): error, invalid access to FAT (entry 0x00000020)
Dev loop5: unable to read RDB block 1
 loop5: unable to read partition table
FAT-fs (loop2): Filesystem has been set read-only
loop5: partition table beyond EOD, truncated
loop_reread_partitions: partition scan of loop5 () failed (rc=-5)
Dev loop5: unable to read RDB block 1
 loop5: unable to read partition table
loop5: partition table beyond EOD, truncated
loop_reread_partitions: partition scan of loop5 () failed (rc=-5)
Dev loop5: unable to read RDB block 1
 loop5: unable to read partition table
FAT-fs (loop2): error, invalid access to FAT (entry 0x00000020)
loop5: partition table beyond EOD, truncated
FAT-fs (loop2): Filesystem has been set read-only
FAT-fs (loop2): error, invalid access to FAT (entry 0x00000020)
loop_reread_partitions: partition scan of loop5 () failed (rc=-5)
attempt to access beyond end of device
loop2: rw=34817, want=157, limit=116
Dev loop5: unable to read RDB block 1
 loop5: unable to read partition table
loop5: partition table beyond EOD, truncated
loop_reread_partitions: partition scan of loop5 () failed (rc=-5)
FAT-fs (loop2): error, invalid access to FAT (entry 0x00000020)
FAT-fs (loop2): Filesystem has been set read-only
Dev loop5: unable to read RDB block 1
FAT-fs (loop2): error, invalid access to FAT (entry 0x00000020)
 loop5: unable to read partition table
loop5: partition table beyond EOD, truncated
attempt to access beyond end of device
loop2: rw=34817, want=157, limit=116
loop_reread_partitions: partition scan of loop5 () failed (rc=-5)
Dev loop5: unable to read RDB block 1
 loop5: unable to read partition table
loop5: partition table beyond EOD, truncated
FAT-fs (loop2): error, invalid access to FAT (entry 0x00000020)
loop_reread_partitions: partition scan of loop5 () failed (rc=-5)
FAT-fs (loop2): Filesystem has been set read-only
FAT-fs (loop2): error, invalid access to FAT (entry 0x00000020)
attempt to access beyond end of device
loop2: rw=34817, want=157, limit=116
Dev loop5: unable to read RDB block 1
 loop5: unable to read partition table
loop5: partition table beyond EOD, truncated
loop_reread_partitions: partition scan of loop5 () failed (rc=-5)
Dev loop5: unable to read RDB block 1
 loop5: unable to read partition table
loop5: partition table beyond EOD, truncated
loop_reread_partitions: partition scan of loop5 () failed (rc=-5)
FAT-fs (loop2): error, invalid access to FAT (entry 0x00000020)
FAT-fs (loop2): Filesystem has been set read-only
FAT-fs (loop2): error, invalid access to FAT (entry 0x00000020)
attempt to access beyond end of device
loop2: rw=34817, want=157, limit=116
Dev loop5: unable to read RDB block 1
 loop5: unable to read partition table
loop5: partition table beyond EOD, truncated
loop_reread_partitions: partition scan of loop5 () failed (rc=-5)
9pnet: Insufficient options for proto=fd
9pnet: Insufficient options for proto=fd
Dev loop5: unable to read RDB block 1
 loop5: unable to read partition table
loop5: partition table beyond EOD, truncated
loop_reread_partitions: partition scan of loop5 () failed (rc=-5)
9pnet: Insufficient options for proto=fd
FAT-fs (loop2): error, invalid access to FAT (entry 0x00000020)
FAT-fs (loop2): Filesystem has been set read-only
FAT-fs (loop2): error, invalid access to FAT (entry 0x00000020)
attempt to access beyond end of device
loop2: rw=34817, want=157, limit=116
Dev loop5: unable to read RDB block 1
 loop5: unable to read partition table
loop5: partition table beyond EOD, truncated
FAT-fs (loop2): error, invalid access to FAT (entry 0x00000020)
loop_reread_partitions: partition scan of loop5 () failed (rc=-5)
FAT-fs (loop2): Filesystem has been set read-only
FAT-fs (loop2): error, invalid access to FAT (entry 0x00000020)
attempt to access beyond end of device
loop2: rw=34817, want=157, limit=116
Dev loop5: unable to read RDB block 1
 loop5: unable to read partition table
loop5: partition table beyond EOD, truncated
loop_reread_partitions: partition scan of loop5 () failed (rc=-5)
Dev loop5: unable to read RDB block 1
 loop5: unable to read partition table
loop5: partition table beyond EOD, truncated
loop_reread_partitions: partition scan of loop5 () failed (rc=-5)
9pnet: Insufficient options for proto=fd
9pnet: Insufficient options for proto=fd
FAT-fs (loop2): error, invalid access to FAT (entry 0x00000020)
FAT-fs (loop2): Filesystem has been set read-only
FAT-fs (loop2): error, invalid access to FAT (entry 0x00000020)
9pnet: Insufficient options for proto=fd
9pnet: Insufficient options for proto=fd
9pnet: Insufficient options for proto=fd
9pnet: Insufficient options for proto=fd
FAT-fs (loop2): error, invalid access to FAT (entry 0x00000020)
FAT-fs (loop2): Filesystem has been set read-only
FAT-fs (loop2): error, invalid access to FAT (entry 0x00000020)
attempt to access beyond end of device
loop2: rw=34817, want=157, limit=116
 loop5: p1 < > p2 p3 < p5 p6 > p4
loop5: partition table partially beyond EOD, truncated
loop5: p1 start 201 is beyond EOD, truncated
loop5: p2 size 1073741824 extends beyond EOD, truncated
loop5: p3 size 2 extends beyond EOD, truncated
loop5: p4 size 32768 extends beyond EOD, truncated
loop5: p5 size 1073741824 extends beyond EOD, truncated
loop5: p6 size 32768 extends beyond EOD, truncated
 loop5: p1 < > p2 p3 < p5 p6 > p4
loop5: partition table partially beyond EOD, truncated
loop5: p1 start 201 is beyond EOD, truncated
FAT-fs (loop2): error, invalid access to FAT (entry 0x00000020)
loop5: p2 size 1073741824 extends beyond EOD, truncated
FAT-fs (loop2): Filesystem has been set read-only
loop5: p3 size 2 extends beyond EOD, truncated
loop5: p4 size 32768 extends beyond EOD, truncated
FAT-fs (loop2): error, invalid access to FAT (entry 0x00000020)
loop5: p5 size 1073741824 extends beyond EOD, truncated
attempt to access beyond end of device
loop2: rw=34817, want=157, limit=116
loop5: p6 size 32768 extends beyond EOD, truncated
FAT-fs (loop2): invalid media value (0x02)
sctp: [Deprecated]: syz-executor.1 (pid 18380) Use of int in maxseg socket option.
Use struct sctp_assoc_value instead
 loop5: p1 < > p2 p3 < p5 p6 > p4
loop5: partition table partially beyond EOD, truncated
FAT-fs (loop2): Can't find a valid FAT filesystem
loop5: p1 start 201 is beyond EOD, truncated
loop5: p2 size 1073741824 extends beyond EOD, truncated
loop5: p3 size 2 extends beyond EOD, truncated
loop5: p4 size 32768 extends beyond EOD, truncated
loop5: p5 size 1073741824 extends beyond EOD, truncated
FAT-fs (loop2): invalid media value (0x02)
FAT-fs (loop2): Can't find a valid FAT filesystem
loop5: p6 size 32768 extends beyond EOD, truncated
FAT-fs (loop2): error, invalid access to FAT (entry 0x00000020)
FAT-fs (loop2): Filesystem has been set read-only
 loop5: p1 < > p2 p3 < p5 p6 > p4
loop5: partition table partially beyond EOD, truncated
FAT-fs (loop2): error, invalid access to FAT (entry 0x00000020)
loop5: p1 start 201 is beyond EOD, truncated
loop5: p2 size 1073741824 extends beyond EOD, truncated

Crashes (3):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2020/06/03 23:21 linux-4.14.y c6db52a88798 a5ce5de0 .config console log report ci2-linux-4-14
2020/05/31 12:21 linux-4.14.y 4f68020fef1c a0331e89 .config console log report ci2-linux-4-14
2020/03/22 04:18 linux-4.14.y 01364dad1d45 78267cec .config console log report ci2-linux-4-14
* Struck through repros no longer work on HEAD.