possible deadlock in generic_file_write_iter

12 views
Skip to first unread message

syzbot

unread,
Jun 1, 2020, 4:34:20 AM6/1/20
to syzkaller...@googlegroups.com
Hello,

syzbot found the following crash on:

HEAD commit: 2d16cf48 Linux 4.19.125
git tree: linux-4.19.y
console output: https://syzkaller.appspot.com/x/log.txt?x=143107d6100000
kernel config: https://syzkaller.appspot.com/x/.config?x=60c13d6e8857c508
dashboard link: https://syzkaller.appspot.com/bug?extid=1e6317a16c5ded6e76f5
compiler: gcc (GCC) 9.0.0 20181231 (experimental)

Unfortunately, I don't have any reproducer for this crash yet.

IMPORTANT: if you fix the bug, please add the following tag to the commit:
Reported-by: syzbot+1e6317...@syzkaller.appspotmail.com

R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000007
R13: 00000000000001fb R14: 00000000004c4486 R15: 00007f3bf1e636d4
net_ratelimit: 33 callbacks suppressed
openvswitch: netlink: Either Ethernet header or EtherType is required.
======================================================
WARNING: possible circular locking dependency detected
4.19.125-syzkaller #0 Not tainted
------------------------------------------------------
syz-executor.3/4901 is trying to acquire lock:
000000004da8d380 ((wq_completion)"dio/%s"sb->s_id){+.+.}, at: flush_workqueue+0xf7/0x1440 kernel/workqueue.c:2660

but task is already holding lock:
00000000d70f7932 (&sb->s_type->i_mutex_key#33){++++}, at: inode_lock include/linux/fs.h:748 [inline]
00000000d70f7932 (&sb->s_type->i_mutex_key#33){++++}, at: generic_file_write_iter+0x99/0x725 mm/filemap.c:3312

which lock already depends on the new lock.


the existing dependency chain (in reverse order) is:

-> #2 (&sb->s_type->i_mutex_key#33){++++}:
inode_lock include/linux/fs.h:748 [inline]
__generic_file_fsync+0xb0/0x1f0 fs/libfs.c:987
fat_file_fsync+0x73/0x200 fs/fat/file.c:198
vfs_fsync_range+0x138/0x220 fs/sync.c:197
generic_write_sync include/linux/fs.h:2747 [inline]
dio_complete+0x47c/0x9e0 fs/direct-io.c:329
process_one_work+0x892/0x1580 kernel/workqueue.c:2155
worker_thread+0x96/0xe20 kernel/workqueue.c:2298
kthread+0x30b/0x410 kernel/kthread.c:246
ret_from_fork+0x24/0x30 arch/x86/entry/entry_64.S:415

-> #1 ((work_completion)(&dio->complete_work)){+.+.}:
worker_thread+0x96/0xe20 kernel/workqueue.c:2298
kthread+0x30b/0x410 kernel/kthread.c:246
ret_from_fork+0x24/0x30 arch/x86/entry/entry_64.S:415

-> #0 ((wq_completion)"dio/%s"sb->s_id){+.+.}:
flush_workqueue+0x126/0x1440 kernel/workqueue.c:2663
drain_workqueue+0x1a7/0x460 kernel/workqueue.c:2828
destroy_workqueue+0x75/0x6f0 kernel/workqueue.c:4172
__alloc_workqueue_key+0xc09/0xe20 kernel/workqueue.c:4149
sb_init_dio_done_wq+0x34/0x90 fs/direct-io.c:623
do_blockdev_direct_IO fs/direct-io.c:1284 [inline]
__blockdev_direct_IO+0x6445/0xfe24 fs/direct-io.c:1418
blockdev_direct_IO include/linux/fs.h:3056 [inline]
fat_direct_IO+0x1cc/0x2f0 fs/fat/inode.c:282
generic_file_direct_write+0x207/0x490 mm/filemap.c:3065
__generic_file_write_iter+0x2d4/0x610 mm/filemap.c:3244
generic_file_write_iter+0x3f4/0x725 mm/filemap.c:3315
call_write_iter include/linux/fs.h:1821 [inline]
aio_write+0x346/0x530 fs/aio.c:1573
__io_submit_one fs/aio.c:1850 [inline]
io_submit_one+0x1005/0x20c0 fs/aio.c:1901
__do_sys_io_submit fs/aio.c:1945 [inline]
__se_sys_io_submit+0x142/0x4a0 fs/aio.c:1916
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#33

Possible unsafe locking scenario:

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

*** DEADLOCK ***

1 lock held by syz-executor.3/4901:
#0: 00000000d70f7932 (&sb->s_type->i_mutex_key#33){++++}, at: inode_lock include/linux/fs.h:748 [inline]
#0: 00000000d70f7932 (&sb->s_type->i_mutex_key#33){++++}, at: generic_file_write_iter+0x99/0x725 mm/filemap.c:3312

stack backtrace:
CPU: 0 PID: 4901 Comm: syz-executor.3 Not tainted 4.19.125-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/0x2fe lib/dump_stack.c:118
print_circular_bug.isra.0.cold+0x2dc/0x425 kernel/locking/lockdep.c:1221
check_prev_add kernel/locking/lockdep.c:1865 [inline]
check_prevs_add kernel/locking/lockdep.c:1978 [inline]
validate_chain kernel/locking/lockdep.c:2419 [inline]
__lock_acquire+0x3145/0x4380 kernel/locking/lockdep.c:3415
lock_acquire+0x170/0x3c0 kernel/locking/lockdep.c:3907
flush_workqueue+0x126/0x1440 kernel/workqueue.c:2663
drain_workqueue+0x1a7/0x460 kernel/workqueue.c:2828
destroy_workqueue+0x75/0x6f0 kernel/workqueue.c:4172
__alloc_workqueue_key+0xc09/0xe20 kernel/workqueue.c:4149
sb_init_dio_done_wq+0x34/0x90 fs/direct-io.c:623
do_blockdev_direct_IO fs/direct-io.c:1284 [inline]
__blockdev_direct_IO+0x6445/0xfe24 fs/direct-io.c:1418
blockdev_direct_IO include/linux/fs.h:3056 [inline]
fat_direct_IO+0x1cc/0x2f0 fs/fat/inode.c:282
generic_file_direct_write+0x207/0x490 mm/filemap.c:3065
__generic_file_write_iter+0x2d4/0x610 mm/filemap.c:3244
generic_file_write_iter+0x3f4/0x725 mm/filemap.c:3315
call_write_iter include/linux/fs.h:1821 [inline]
aio_write+0x346/0x530 fs/aio.c:1573
__io_submit_one fs/aio.c:1850 [inline]
io_submit_one+0x1005/0x20c0 fs/aio.c:1901
__do_sys_io_submit fs/aio.c:1945 [inline]
__se_sys_io_submit+0x142/0x4a0 fs/aio.c:1916
do_syscall_64+0xf9/0x620 arch/x86/entry/common.c:293
entry_SYSCALL_64_after_hwframe+0x49/0xbe
RIP: 0033:0x45ca69
Code: 0d b7 fb ff c3 66 2e 0f 1f 84 00 00 00 00 00 66 90 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 0f 83 db b6 fb ff c3 66 2e 0f 1f 84 00 00 00 00
RSP: 002b:00007f3bf1e62c78 EFLAGS: 00000246 ORIG_RAX: 00000000000000d1
RAX: ffffffffffffffda RBX: 00000000004e0d40 RCX: 000000000045ca69
RDX: 0000000020000540 RSI: 0000000000000006 RDI: 00007f3bf1e64000
RBP: 000000000078bfa0 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000007
R13: 00000000000001fb R14: 00000000004c4486 R15: 00007f3bf1e636d4
openvswitch: netlink: Message has 8 unknown bytes.
openvswitch: netlink: Either Ethernet header or EtherType is required.
FAT-fs (loop3): error, invalid access to FAT (entry 0x00000020)
FAT-fs (loop3): Filesystem has been set read-only
FAT-fs (loop3): error, invalid access to FAT (entry 0x00000020)
openvswitch: netlink: Message has 8 unknown bytes.
attempt to access beyond end of device
openvswitch: netlink: Either Ethernet header or EtherType is required.
loop3: rw=34817, want=157, limit=116
openvswitch: netlink: Message has 8 unknown bytes.
openvswitch: netlink: Either Ethernet header or EtherType is required.
openvswitch: netlink: Message has 8 unknown bytes.
openvswitch: netlink: Either Ethernet header or EtherType is required.
FAT-fs (loop3): error, invalid access to FAT (entry 0x00000020)
FAT-fs (loop3): Filesystem has been set read-only
FAT-fs (loop3): error, invalid access to FAT (entry 0x00000020)
openvswitch: netlink: Either Ethernet header or EtherType is required.
attempt to access beyond end of device
loop3: rw=34817, want=157, limit=116
FAT-fs (loop3): error, fat_get_cluster: invalid cluster chain (i_pos 16)
FAT-fs (loop3): Filesystem has been set read-only
FAT-fs (loop3): error, fat_get_cluster: invalid cluster chain (i_pos 16)
FAT-fs (loop3): error, fat_get_cluster: invalid cluster chain (i_pos 16)
FAT-fs (loop3): error, fat_get_cluster: invalid cluster chain (i_pos 16)
FAT-fs (loop3): error, fat_get_cluster: invalid cluster chain (i_pos 16)
FAT-fs (loop3): Filesystem has been set read-only
FAT-fs (loop3): error, fat_get_cluster: invalid cluster chain (i_pos 16)
FAT-fs (loop3): error, fat_get_cluster: invalid cluster chain (i_pos 16)
FAT-fs (loop3): error, fat_get_cluster: invalid cluster chain (i_pos 16)
FAT-fs (loop3): error, fat_get_cluster: invalid cluster chain (i_pos 16)
FAT-fs (loop3): Filesystem has been set read-only
FAT-fs (loop3): error, fat_get_cluster: invalid cluster chain (i_pos 16)
FAT-fs (loop3): error, fat_get_cluster: invalid cluster chain (i_pos 16)
FAT-fs (loop3): error, fat_get_cluster: invalid cluster chain (i_pos 16)
FAT-fs (loop3): error, fat_get_cluster: invalid cluster chain (i_pos 16)
FAT-fs (loop1): error, fat_get_cluster: invalid cluster chain (i_pos 16)
FAT-fs (loop3): Filesystem has been set read-only
FAT-fs (loop1): Filesystem has been set read-only
FAT-fs (loop3): error, fat_get_cluster: invalid cluster chain (i_pos 16)
FAT-fs (loop1): error, fat_get_cluster: invalid cluster chain (i_pos 16)
FAT-fs (loop3): error, fat_get_cluster: invalid cluster chain (i_pos 16)
FAT-fs (loop1): error, fat_get_cluster: invalid cluster chain (i_pos 16)
FAT-fs (loop3): error, fat_get_cluster: invalid cluster chain (i_pos 16)
FAT-fs (loop1): error, fat_get_cluster: invalid cluster chain (i_pos 16)
FAT-fs (loop3): error, fat_get_cluster: invalid cluster chain (i_pos 16)
FAT-fs (loop3): Filesystem has been set read-only
FAT-fs (loop3): error, fat_get_cluster: invalid cluster chain (i_pos 16)
FAT-fs (loop1): error, fat_get_cluster: invalid cluster chain (i_pos 16)
FAT-fs (loop3): error, fat_get_cluster: invalid cluster chain (i_pos 16)
FAT-fs (loop1): Filesystem has been set read-only
FAT-fs (loop1): error, fat_get_cluster: invalid cluster chain (i_pos 16)
FAT-fs (loop1): error, fat_get_cluster: invalid cluster chain (i_pos 16)
FAT-fs (loop3): error, invalid access to FAT (entry 0x00000100)
FAT-fs (loop1): error, invalid access to FAT (entry 0x00000100)
FAT-fs (loop3): error, invalid access to FAT (entry 0x00000020)
FAT-fs (loop3): Filesystem has been set read-only
FAT-fs (loop3): error, invalid access to FAT (entry 0x00000020)
FAT-fs (loop1): error, invalid access to FAT (entry 0x00000020)
FAT-fs (loop1): Filesystem has been set read-only
FAT-fs (loop1): error, invalid access to FAT (entry 0x00000020)
attempt to access beyond end of device
loop3: rw=34817, want=157, limit=116
attempt to access beyond end of device
loop1: rw=34817, want=157, limit=116
FAT-fs (loop3): error, invalid access to FAT (entry 0x00000020)
FAT-fs (loop3): Filesystem has been set read-only
FAT-fs (loop3): error, invalid access to FAT (entry 0x00000020)
attempt to access beyond end of device
loop3: rw=34817, want=157, limit=116
FAT-fs (loop1): error, invalid access to FAT (entry 0x00000020)
FAT-fs (loop1): Filesystem has been set read-only
FAT-fs (loop1): error, invalid access to FAT (entry 0x00000020)
net_ratelimit: 41 callbacks suppressed
openvswitch: netlink: Message has 8 unknown bytes.
openvswitch: netlink: Either Ethernet header or EtherType is required.
openvswitch: netlink: Message has 8 unknown bytes.
FAT-fs (loop3): error, invalid access to FAT (entry 0x00000020)
openvswitch: netlink: Either Ethernet header or EtherType is required.
FAT-fs (loop3): Filesystem has been set read-only
FAT-fs (loop1): error, invalid access to FAT (entry 0x00000020)
FAT-fs (loop1): Filesystem has been set read-only
FAT-fs (loop3): error, invalid access to FAT (entry 0x00000020)
FAT-fs (loop1): error, invalid access to FAT (entry 0x00000020)
attempt to access beyond end of device
loop3: rw=34817, want=157, limit=116
openvswitch: netlink: Message has 8 unknown bytes.
openvswitch: netlink: Either Ethernet header or EtherType is required.
openvswitch: netlink: Message has 8 unknown bytes.
FAT-fs (loop1): error, invalid access to FAT (entry 0x00000020)
openvswitch: netlink: Either Ethernet header or EtherType is required.
FAT-fs (loop3): error, invalid access to FAT (entry 0x00000020)
FAT-fs (loop3): Filesystem has been set read-only
FAT-fs (loop3): error, invalid access to FAT (entry 0x00000020)
FAT-fs (loop1): Filesystem has been set read-only
FAT-fs (loop1): error, invalid access to FAT (entry 0x00000020)
attempt to access beyond end of device
loop3: rw=34817, want=157, limit=116
openvswitch: netlink: Either Ethernet header or EtherType is required.
openvswitch: netlink: Message has 8 unknown bytes.
FAT-fs (loop3): error, invalid access to FAT (entry 0x00000020)
FAT-fs (loop3): Filesystem has been set read-only
FAT-fs (loop3): error, invalid access to FAT (entry 0x00000020)
attempt to access beyond end of device
loop3: rw=34817, want=157, limit=116
FAT-fs (loop3): error, invalid access to FAT (entry 0x00000020)
FAT-fs (loop3): Filesystem has been set read-only
FAT-fs (loop3): error, invalid access to FAT (entry 0x00000020)
attempt to access beyond end of device
loop3: rw=34817, want=157, limit=116
FAT-fs (loop3): error, invalid access to FAT (entry 0x00000020)
FAT-fs (loop3): Filesystem has been set read-only
FAT-fs (loop3): error, invalid access to FAT (entry 0x00000020)
attempt to access beyond end of device
loop3: rw=34817, want=157, limit=116
FAT-fs (loop3): error, invalid access to FAT (entry 0x00000020)
FAT-fs (loop3): Filesystem has been set read-only
FAT-fs (loop3): error, invalid access to FAT (entry 0x00000020)
attempt to access beyond end of device
loop3: rw=34817, want=157, limit=116
FAT-fs (loop3): error, invalid access to FAT (entry 0x00000020)
FAT-fs (loop3): Filesystem has been set read-only
FAT-fs (loop3): error, invalid access to FAT (entry 0x00000020)
attempt to access beyond end of device
loop3: rw=34817, want=157, limit=116
FAT-fs (loop3): error, invalid access to FAT (entry 0x00000020)
FAT-fs (loop3): Filesystem has been set read-only
FAT-fs (loop3): error, invalid access to FAT (entry 0x00000020)
attempt to access beyond end of device
loop3: rw=34817, want=157, limit=116
FAT-fs (loop3): error, invalid access to FAT (entry 0x00000020)
FAT-fs (loop3): Filesystem has been set read-only
FAT-fs (loop3): error, invalid access to FAT (entry 0x00000020)
FAT-fs (loop3): error, invalid access to FAT (entry 0x00000020)
FAT-fs (loop3): Filesystem has been set read-only
FAT-fs (loop3): error, invalid access to FAT (entry 0x00000020)
attempt to access beyond end of device
loop3: rw=34817, want=157, limit=116
FAT-fs (loop3): error, invalid access to FAT (entry 0x00000020)
FAT-fs (loop3): Filesystem has been set read-only
FAT-fs (loop3): error, invalid access to FAT (entry 0x00000020)
attempt to access beyond end of device
loop3: rw=34817, want=157, limit=116
FAT-fs (loop1): bogus number of reserved sectors
FAT-fs (loop1): Can't find a valid FAT filesystem
net_ratelimit: 51 callbacks suppressed
openvswitch: netlink: Message has 8 unknown bytes.
openvswitch: netlink: Either Ethernet header or EtherType is required.


---
This bug is generated by a bot. It may contain errors.
See https://goo.gl/tpsmEJ for more information about syzbot.
syzbot engineers can be reached at syzk...@googlegroups.com.

syzbot will keep track of this bug report. See:
https://goo.gl/tpsmEJ#status for how to communicate with syzbot.

syzbot

unread,
Oct 6, 2020, 11:19:12 AM10/6/20
to syzkaller...@googlegroups.com
Auto-closing this bug as obsolete.
Crashes did not happen for a while, no reproducer and no activity.
Reply all
Reply to author
Forward
0 new messages