syzbot


possible deadlock in xfs_buffered_write_iomap_end

Status: upstream: reported on 2024/10/09 05:12
Subsystems: xfs
[Documentation on labels]
Reported-by: syzbot+3d96bb110d05e208ae9e@syzkaller.appspotmail.com
First crash: 10d, last: 10d
Discussions (1)
Title Replies (including bot) Last reply
[syzbot] [xfs?] possible deadlock in xfs_buffered_write_iomap_end 1 (2) 2024/10/09 08:08

Sample crash report:
loop0: detected capacity change from 32768 to 0
syz.0.409: attempt to access beyond end of device
loop0: rw=2048, sector=18728, nr_sectors = 4 limit=0
============================================
WARNING: possible recursive locking detected
6.12.0-rc1-next-20241003-syzkaller #0 Not tainted
--------------------------------------------
syz.0.409/9596 is trying to acquire lock:
ffff88805e4b0c90 (mapping.invalidate_lock#6){++++}-{3:3}, at: filemap_invalidate_lock include/linux/fs.h:860 [inline]
ffff88805e4b0c90 (mapping.invalidate_lock#6){++++}-{3:3}, at: xfs_buffered_write_iomap_end+0x20c/0x490 fs/xfs/xfs_iomap.c:1246

but task is already holding lock:
ffff88805e4b0c90 (mapping.invalidate_lock#6){++++}-{3:3}, at: xfs_ilock+0x193/0x3d0 fs/xfs/xfs_inode.c:156

other info that might help us debug this:
 Possible unsafe locking scenario:

       CPU0
       ----
  lock(mapping.invalidate_lock#6);
  lock(mapping.invalidate_lock#6);

 *** DEADLOCK ***

 May be due to missing lock nesting notation

3 locks held by syz.0.409/9596:
 #0: ffff888077bc0420 (sb_writers#19){++++}-{0:0}, at: file_start_write include/linux/fs.h:2950 [inline]
 #0: ffff888077bc0420 (sb_writers#19){++++}-{0:0}, at: vfs_fallocate+0x4fe/0x6e0 fs/open.c:332
 #1: ffff88805e4b0af0 (&sb->s_type->i_mutex_key#27){++++}-{3:3}, at: xfs_ilock+0x102/0x3d0 fs/xfs/xfs_inode.c:148
 #2: ffff88805e4b0c90 (mapping.invalidate_lock#6){++++}-{3:3}, at: xfs_ilock+0x193/0x3d0 fs/xfs/xfs_inode.c:156

stack backtrace:
CPU: 1 UID: 0 PID: 9596 Comm: syz.0.409 Not tainted 6.12.0-rc1-next-20241003-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 09/13/2024
Call Trace:
 <TASK>
 __dump_stack lib/dump_stack.c:94 [inline]
 dump_stack_lvl+0x241/0x360 lib/dump_stack.c:120
 print_deadlock_bug+0x483/0x620 kernel/locking/lockdep.c:3037
 check_deadlock kernel/locking/lockdep.c:3089 [inline]
 validate_chain+0x15e2/0x5920 kernel/locking/lockdep.c:3891
 __lock_acquire+0x1384/0x2050 kernel/locking/lockdep.c:5202
 lock_acquire+0x1ed/0x550 kernel/locking/lockdep.c:5825
 down_write+0x99/0x220 kernel/locking/rwsem.c:1577
 filemap_invalidate_lock include/linux/fs.h:860 [inline]
 xfs_buffered_write_iomap_end+0x20c/0x490 fs/xfs/xfs_iomap.c:1246
 iomap_iter+0x220/0xf60 fs/iomap/iter.c:79
 iomap_file_unshare+0x380/0x6d0 fs/iomap/buffered-io.c:1343
 xfs_reflink_unshare+0x173/0x5f0 fs/xfs/xfs_reflink.c:1681
 xfs_falloc_unshare_range+0x164/0x390 fs/xfs/xfs_file.c:1033
 xfs_file_fallocate+0x289/0x3d0 fs/xfs/xfs_file.c:1125
 vfs_fallocate+0x569/0x6e0 fs/open.c:333
 ksys_fallocate fs/open.c:356 [inline]
 __do_sys_fallocate fs/open.c:364 [inline]
 __se_sys_fallocate fs/open.c:362 [inline]
 __x64_sys_fallocate+0xbd/0x110 fs/open.c:362
 do_syscall_x64 arch/x86/entry/common.c:52 [inline]
 do_syscall_64+0xf3/0x230 arch/x86/entry/common.c:83
 entry_SYSCALL_64_after_hwframe+0x77/0x7f
RIP: 0033:0x7f3f1df7dff9
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 a8 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007f3f1ee0b038 EFLAGS: 00000246 ORIG_RAX: 000000000000011d
RAX: ffffffffffffffda RBX: 00007f3f1e135f80 RCX: 00007f3f1df7dff9
RDX: 000000000000000a RSI: 0000000000000040 RDI: 0000000000000004
RBP: 00007f3f1dff0296 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000005 R11: 0000000000000246 R12: 0000000000000000
R13: 0000000000000000 R14: 00007f3f1e135f80 R15: 00007fffd33b9598
 </TASK>

Crashes (3):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2024/10/05 05:08 linux-next c02d24a5af66 d7906eff .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-linux-next-kasan-gce-root possible deadlock in xfs_buffered_write_iomap_end
2024/10/05 05:08 linux-next c02d24a5af66 d7906eff .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-linux-next-kasan-gce-root possible deadlock in xfs_buffered_write_iomap_end
2024/10/05 05:06 linux-next c02d24a5af66 d7906eff .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-linux-next-kasan-gce-root possible deadlock in xfs_buffered_write_iomap_end
* Struck through repros no longer work on HEAD.