syzbot


possible deadlock in ext4_file_write_iter (3)

Status: upstream: reported syz repro on 2021/12/24 22:56
Reported-by: syzbot+d0bf53989411f8e4778f@syzkaller.appspotmail.com
First crash: 229d, last: 4d04h

Fix bisection: failed (bisect log)
similar bugs (4):
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
linux-4.14 possible deadlock in ext4_file_write_iter 3 816d 868d 0/1 auto-closed as invalid on 2020/09/14 06:49
linux-4.14 possible deadlock in ext4_file_write_iter (2) syz inconclusive 13 10d 655d 0/1 upstream: reported syz repro on 2020/10/24 08:36
linux-4.19 possible deadlock in ext4_file_write_iter (2) 1 377d 377d 0/1 auto-closed as invalid on 2021/11/26 16:39
linux-4.19 possible deadlock in ext4_file_write_iter 1 799d 799d 0/1 auto-closed as invalid on 2020/10/01 00:41

Sample crash report:
wlan1: Creating new IBSS network, BSSID 50:50:50:50:50:50
wlan1: Creating new IBSS network, BSSID 50:50:50:50:50:50
IPv6: ADDRCONF(NETDEV_CHANGE): wlan1: link becomes ready
IPv6: ADDRCONF(NETDEV_CHANGE): wlan1: link becomes ready
======================================================
WARNING: possible circular locking dependency detected
4.19.211-syzkaller #0 Not tainted
------------------------------------------------------
syz-executor.1/9542 is trying to acquire lock:
00000000958577b3 ((wq_completion)"dio/%s"sb->s_id){+.+.}, at: flush_workqueue+0xe8/0x13e0 kernel/workqueue.c:2658
ieee80211 phy6: Selected rate control algorithm 'minstrel_ht'

but task is already holding lock:
00000000c6d9c882 (&sb->s_type->i_mutex_key#10){+.+.}, at: inode_trylock include/linux/fs.h:768 [inline]
00000000c6d9c882 (&sb->s_type->i_mutex_key#10){+.+.}, at: ext4_file_write_iter+0x21f/0xf20 fs/ext4/file.c:238

which lock already depends on the new lock.


the existing dependency chain (in reverse order) is:

-> #2 (&sb->s_type->i_mutex_key#10){+.+.}:
       inode_lock include/linux/fs.h:748 [inline]
       __generic_file_fsync+0xb0/0x1f0 fs/libfs.c:989
       ext4_sync_file+0xa35/0x1420 fs/ext4/fsync.c:118
       vfs_fsync_range+0x13a/0x220 fs/sync.c:197
       generic_write_sync include/linux/fs.h:2750 [inline]
       dio_complete+0x763/0xac0 fs/direct-io.c:329
       process_one_work+0x864/0x1570 kernel/workqueue.c:2153
       worker_thread+0x64c/0x1130 kernel/workqueue.c:2296
       kthread+0x33f/0x460 kernel/kthread.c:259
       ret_from_fork+0x24/0x30 arch/x86/entry/entry_64.S:415

-> #1 ((work_completion)(&dio->complete_work)){+.+.}:
       worker_thread+0x64c/0x1130 kernel/workqueue.c:2296
       kthread+0x33f/0x460 kernel/kthread.c:259
       ret_from_fork+0x24/0x30 arch/x86/entry/entry_64.S:415

-> #0 ((wq_completion)"dio/%s"sb->s_id){+.+.}:
ieee80211 phy7: Selected rate control algorithm 'minstrel_ht'
       flush_workqueue+0x117/0x13e0 kernel/workqueue.c:2661
       drain_workqueue+0x1a5/0x460 kernel/workqueue.c:2826
       destroy_workqueue+0x75/0x790 kernel/workqueue.c:4183
       sb_init_dio_done_wq+0x72/0x90 fs/direct-io.c:634
       do_blockdev_direct_IO fs/direct-io.c:1285 [inline]
       __blockdev_direct_IO+0x5f55/0xef40 fs/direct-io.c:1419
       ext4_direct_IO_write fs/ext4/inode.c:3777 [inline]
       ext4_direct_IO+0xae4/0x1c50 fs/ext4/inode.c:3915
       generic_file_direct_write+0x208/0x4a0 mm/filemap.c:3073
       __generic_file_write_iter+0x2d0/0x610 mm/filemap.c:3252
IPv6: ADDRCONF(NETDEV_UP): wlan0: link is not ready
       ext4_file_write_iter+0x2fe/0xf20 fs/ext4/file.c:272
       call_write_iter include/linux/fs.h:1821 [inline]
       aio_write+0x37f/0x5c0 fs/aio.c:1574
       __io_submit_one fs/aio.c:1858 [inline]
       io_submit_one+0xecd/0x20c0 fs/aio.c:1909
       __do_sys_io_submit fs/aio.c:1953 [inline]
       __se_sys_io_submit+0x11b/0x4a0 fs/aio.c:1924
       do_syscall_64+0xf9/0x620 arch/x86/entry/common.c:293
       entry_SYSCALL_64_after_hwframe+0x49/0xbe

other info that might help us debug this:

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

 Possible unsafe locking scenario:

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

 *** DEADLOCK ***

1 lock held by syz-executor.1/9542:
 #0: 00000000c6d9c882 (&sb->s_type->i_mutex_key#10){+.+.}, at: inode_trylock include/linux/fs.h:768 [inline]
 #0: 00000000c6d9c882 (&sb->s_type->i_mutex_key#10){+.+.}, at: ext4_file_write_iter+0x21f/0xf20 fs/ext4/file.c:238

stack backtrace:
CPU: 1 PID: 9542 Comm: syz-executor.1 Not tainted 4.19.211-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
Call Trace:
 __dump_stack lib/dump_stack.c:77 [inline]
 dump_stack+0x1fc/0x2ef lib/dump_stack.c:118
 print_circular_bug.constprop.0.cold+0x2d7/0x41e kernel/locking/lockdep.c:1222
 check_prev_add kernel/locking/lockdep.c:1866 [inline]
 check_prevs_add kernel/locking/lockdep.c:1979 [inline]
 validate_chain kernel/locking/lockdep.c:2420 [inline]
 __lock_acquire+0x30c9/0x3ff0 kernel/locking/lockdep.c:3416
 lock_acquire+0x170/0x3c0 kernel/locking/lockdep.c:3908
 flush_workqueue+0x117/0x13e0 kernel/workqueue.c:2661
 drain_workqueue+0x1a5/0x460 kernel/workqueue.c:2826
 destroy_workqueue+0x75/0x790 kernel/workqueue.c:4183
 sb_init_dio_done_wq+0x72/0x90 fs/direct-io.c:634
 do_blockdev_direct_IO fs/direct-io.c:1285 [inline]
 __blockdev_direct_IO+0x5f55/0xef40 fs/direct-io.c:1419
 ext4_direct_IO_write fs/ext4/inode.c:3777 [inline]
 ext4_direct_IO+0xae4/0x1c50 fs/ext4/inode.c:3915
 generic_file_direct_write+0x208/0x4a0 mm/filemap.c:3073
 __generic_file_write_iter+0x2d0/0x610 mm/filemap.c:3252
 ext4_file_write_iter+0x2fe/0xf20 fs/ext4/file.c:272
 call_write_iter include/linux/fs.h:1821 [inline]
 aio_write+0x37f/0x5c0 fs/aio.c:1574
 __io_submit_one fs/aio.c:1858 [inline]
 io_submit_one+0xecd/0x20c0 fs/aio.c:1909
 __do_sys_io_submit fs/aio.c:1953 [inline]
 __se_sys_io_submit+0x11b/0x4a0 fs/aio.c:1924
 do_syscall_64+0xf9/0x620 arch/x86/entry/common.c:293
 entry_SYSCALL_64_after_hwframe+0x49/0xbe
RIP: 0033:0x7f06b1d82059
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 b8 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007ffed4e854f8 EFLAGS: 00000246 ORIG_RAX: 00000000000000d1
RAX: ffffffffffffffda RBX: 00007f06b1e94f60 RCX: 00007f06b1d82059
RDX: 0000000020000540 RSI: 0000000000000002 RDI: 00007f06b1e70000
RBP: 00007f06b1ddc08d R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 00007f06b1e99f00 R14: 00007f06b1e94f60 R15: 0000000000000000
IPv6: ADDRCONF(NETDEV_UP): wlan0: link is not ready
wlan0: Created IBSS using preconfigured BSSID 50:50:50:50:50:50
ieee80211 phy8: Selected rate control algorithm 'minstrel_ht'
wlan0: Creating new IBSS network, BSSID 50:50:50:50:50:50
IPv6: ADDRCONF(NETDEV_CHANGE): wlan0: link becomes ready
ieee80211 phy9: Selected rate control algorithm 'minstrel_ht'
wlan0: Created IBSS using preconfigured BSSID 50:50:50:50:50:50
ieee80211 phy10: Selected rate control algorithm 'minstrel_ht'
wlan0: Creating new IBSS network, BSSID 50:50:50:50:50:50
IPv6: ADDRCONF(NETDEV_CHANGE): wlan0: link becomes ready
IPv6: ADDRCONF(NETDEV_UP): wlan1: link is not ready
ieee80211 phy11: Selected rate control algorithm 'minstrel_ht'
IPv6: ADDRCONF(NETDEV_UP): wlan0: link is not ready
IPv6: ADDRCONF(NETDEV_UP): wlan1: link is not ready
wlan1: Created IBSS using preconfigured BSSID 50:50:50:50:50:50
wlan0: Created IBSS using preconfigured BSSID 50:50:50:50:50:50
wlan1: Creating new IBSS network, BSSID 50:50:50:50:50:50
IPv6: ADDRCONF(NETDEV_UP): wlan0: link is not ready
IPv6: ADDRCONF(NETDEV_CHANGE): wlan1: link becomes ready
wlan0: Creating new IBSS network, BSSID 50:50:50:50:50:50
ieee80211 phy12: Selected rate control algorithm 'minstrel_ht'
ieee80211 phy13: Selected rate control algorithm 'minstrel_ht'
wlan1: Created IBSS using preconfigured BSSID 50:50:50:50:50:50
wlan0: Created IBSS using preconfigured BSSID 50:50:50:50:50:50
wlan1: Creating new IBSS network, BSSID 50:50:50:50:50:50
IPv6: ADDRCONF(NETDEV_CHANGE): wlan0: link becomes ready
wlan0: Creating new IBSS network, BSSID 50:50:50:50:50:50
IPv6: ADDRCONF(NETDEV_CHANGE): wlan1: link becomes ready
IPv6: ADDRCONF(NETDEV_UP): wlan1: link is not ready
IPv6: ADDRCONF(NETDEV_UP): wlan1: link is not ready
IPv6: ADDRCONF(NETDEV_CHANGE): wlan0: link becomes ready
wlan1: Created IBSS using preconfigured BSSID 50:50:50:50:50:50
wlan1: Created IBSS using preconfigured BSSID 50:50:50:50:50:50
wlan1: Creating new IBSS network, BSSID 50:50:50:50:50:50
wlan1: Creating new IBSS network, BSSID 50:50:50:50:50:50
IPv6: ADDRCONF(NETDEV_CHANGE): wlan1: link becomes ready
IPv6: ADDRCONF(NETDEV_CHANGE): wlan1: link becomes ready
hrtimer: interrupt took 39247 ns

Crashes (8):
Manager Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Title
ci2-linux-4-19 2022/01/22 23:05 linux-4.19.y 3f8a27f9e27b 214351e1 .config log report syz possible deadlock in ext4_file_write_iter
ci2-linux-4-19 2022/01/20 09:06 linux-4.19.y 3f8a27f9e27b 5da9499f .config log report syz possible deadlock in ext4_file_write_iter
ci2-linux-4-19 2022/01/07 08:08 linux-4.19.y 3f8a27f9e27b 6acc789a .config log report syz possible deadlock in ext4_file_write_iter
ci2-linux-4-19 2022/08/07 03:37 linux-4.19.y 3f8a27f9e27b 88e3a122 .config log report info possible deadlock in ext4_file_write_iter
ci2-linux-4-19 2022/04/29 16:30 linux-4.19.y 3f8a27f9e27b 44a5ca63 .config log report info possible deadlock in ext4_file_write_iter
ci2-linux-4-19 2022/03/29 23:10 linux-4.19.y 3f8a27f9e27b 6bdac766 .config log report info possible deadlock in ext4_file_write_iter
ci2-linux-4-19 2022/01/27 23:29 linux-4.19.y 3f8a27f9e27b 64a8e201 .config log report info possible deadlock in ext4_file_write_iter
ci2-linux-4-19 2021/12/24 22:55 linux-4.19.y 3f8a27f9e27b 6caa12e4 .config log report info possible deadlock in ext4_file_write_iter