syzbot


possible deadlock in hfs_extend_file (2)

Status: upstream: reported on 2024/04/04 03:11
Reported-by: syzbot+02dc5e479349289abab4@syzkaller.appspotmail.com
First crash: 114d, last: 9d05h
Similar bugs (8)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
linux-4.19 possible deadlock in hfs_extend_file hfs 1 577d 577d 0/1 upstream: reported on 2022/12/27 15:22
linux-5.15 possible deadlock in hfs_extend_file (2) 1 277d 277d 0/3 auto-obsoleted due to no activity on 2024/01/31 18:25
linux-6.1 possible deadlock in hfs_extend_file 7 315d 501d 0/3 auto-obsoleted due to no activity on 2023/12/24 21:20
upstream possible deadlock in hfs_extend_file hfs 46 338d 582d 0/27 auto-obsoleted due to no activity on 2023/11/06 09:48
upstream possible deadlock in hfs_extend_file (3) hfs C unreliable 197 2h39m 99d 0/27 upstream: reported C repro on 2024/04/18 14:41
linux-5.15 possible deadlock in hfs_extend_file (3) 29 1d08h 136d 0/3 upstream: reported on 2024/03/13 05:11
upstream possible deadlock in hfs_extend_file (2) hfs C done done 4 207d 227d 0/27 auto-obsoleted due to no activity on 2024/04/11 05:11
linux-5.15 possible deadlock in hfs_extend_file 5 403d 466d 0/3 auto-obsoleted due to no activity on 2023/09/28 05:53

Sample crash report:
loop3: detected capacity change from 0 to 64
======================================================
WARNING: possible circular locking dependency detected
6.1.99-syzkaller #0 Not tainted
------------------------------------------------------
syz.3.663/6126 is trying to acquire lock:
ffff8880182ae278 (&HFS_I(tree->inode)->extents_lock){+.+.}-{3:3}, at: hfs_extend_file+0xfb/0x1440 fs/hfs/extent.c:397

but task is already holding lock:
ffff88807c15e0b0 (&tree->tree_lock/1){+.+.}-{3:3}, at: hfs_find_init+0x16a/0x1e0

which lock already depends on the new lock.


the existing dependency chain (in reverse order) is:

-> #1 (&tree->tree_lock/1){+.+.}-{3:3}:
       lock_acquire+0x1f8/0x5a0 kernel/locking/lockdep.c:5662
       __mutex_lock_common kernel/locking/mutex.c:603 [inline]
       __mutex_lock+0x132/0xd80 kernel/locking/mutex.c:747
       hfs_find_init+0x16a/0x1e0
       hfs_ext_read_extent fs/hfs/extent.c:200 [inline]
       hfs_extend_file+0x317/0x1440 fs/hfs/extent.c:401
       hfs_bmap_reserve+0xd5/0x3f0 fs/hfs/btree.c:234
       hfs_cat_create+0x1e7/0xa60 fs/hfs/catalog.c:104
       hfs_create+0x62/0xd0 fs/hfs/dir.c:202
       lookup_open fs/namei.c:3484 [inline]
       open_last_lookups fs/namei.c:3552 [inline]
       path_openat+0x12f1/0x2e60 fs/namei.c:3782
       do_filp_open+0x230/0x480 fs/namei.c:3812
       do_sys_openat2+0x13b/0x4f0 fs/open.c:1318
       do_sys_open fs/open.c:1334 [inline]
       __do_sys_open fs/open.c:1342 [inline]
       __se_sys_open fs/open.c:1338 [inline]
       __x64_sys_open+0x221/0x270 fs/open.c:1338
       do_syscall_x64 arch/x86/entry/common.c:51 [inline]
       do_syscall_64+0x3b/0xb0 arch/x86/entry/common.c:81
       entry_SYSCALL_64_after_hwframe+0x68/0xd2

-> #0 (&HFS_I(tree->inode)->extents_lock){+.+.}-{3:3}:
       check_prev_add kernel/locking/lockdep.c:3090 [inline]
       check_prevs_add kernel/locking/lockdep.c:3209 [inline]
       validate_chain+0x1661/0x5950 kernel/locking/lockdep.c:3825
       __lock_acquire+0x125b/0x1f80 kernel/locking/lockdep.c:5049
       lock_acquire+0x1f8/0x5a0 kernel/locking/lockdep.c:5662
       __mutex_lock_common kernel/locking/mutex.c:603 [inline]
       __mutex_lock+0x132/0xd80 kernel/locking/mutex.c:747
       hfs_extend_file+0xfb/0x1440 fs/hfs/extent.c:397
       hfs_bmap_reserve+0xd5/0x3f0 fs/hfs/btree.c:234
       __hfs_ext_write_extent+0x22e/0x4f0 fs/hfs/extent.c:121
       __hfs_ext_cache_extent+0x6a/0x990 fs/hfs/extent.c:174
       hfs_ext_read_extent fs/hfs/extent.c:202 [inline]
       hfs_extend_file+0x340/0x1440 fs/hfs/extent.c:401
       hfs_get_block+0x3e0/0xb60 fs/hfs/extent.c:353
       __block_write_begin_int+0x544/0x1a30 fs/buffer.c:1991
       __block_write_begin fs/buffer.c:2041 [inline]
       block_write_begin+0x98/0x1f0 fs/buffer.c:2102
       cont_write_begin+0x63f/0x880 fs/buffer.c:2456
       hfs_write_begin+0x86/0xd0 fs/hfs/inode.c:58
       generic_perform_write+0x2fc/0x5e0 mm/filemap.c:3817
       __generic_file_write_iter+0x176/0x400 mm/filemap.c:3945
       generic_file_write_iter+0xab/0x310 mm/filemap.c:3977
       call_write_iter include/linux/fs.h:2265 [inline]
       new_sync_write fs/read_write.c:491 [inline]
       vfs_write+0x857/0xbc0 fs/read_write.c:584
       ksys_write+0x19c/0x2c0 fs/read_write.c:637
       do_syscall_x64 arch/x86/entry/common.c:51 [inline]
       do_syscall_64+0x3b/0xb0 arch/x86/entry/common.c:81
       entry_SYSCALL_64_after_hwframe+0x68/0xd2

other info that might help us debug this:

 Possible unsafe locking scenario:

       CPU0                    CPU1
       ----                    ----
  lock(&tree->tree_lock/1);
                               lock(&HFS_I(tree->inode)->extents_lock);
                               lock(&tree->tree_lock/1);
  lock(&HFS_I(tree->inode)->extents_lock);

 *** DEADLOCK ***

5 locks held by syz.3.663/6126:
 #0: ffff888078c400e8 (&f->f_pos_lock){+.+.}-{3:3}, at: __fdget_pos+0x2ba/0x360 fs/file.c:1062
 #1: ffff888062f74460 (sb_writers#20){.+.+}-{0:0}, at: vfs_write+0x269/0xbc0 fs/read_write.c:580
 #2: ffff8880287e0928 (&sb->s_type->i_mutex_key#28){+.+.}-{3:3}, at: inode_lock include/linux/fs.h:758 [inline]
 #2: ffff8880287e0928 (&sb->s_type->i_mutex_key#28){+.+.}-{3:3}, at: generic_file_write_iter+0x7f/0x310 mm/filemap.c:3974
 #3: ffff8880287e0778 (&HFS_I(inode)->extents_lock){+.+.}-{3:3}, at: hfs_extend_file+0xfb/0x1440 fs/hfs/extent.c:397
 #4: ffff88807c15e0b0 (&tree->tree_lock/1){+.+.}-{3:3}, at: hfs_find_init+0x16a/0x1e0

stack backtrace:
CPU: 0 PID: 6126 Comm: syz.3.663 Not tainted 6.1.99-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 06/07/2024
Call Trace:
 <TASK>
 __dump_stack lib/dump_stack.c:88 [inline]
 dump_stack_lvl+0x1e3/0x2cb lib/dump_stack.c:106
 check_noncircular+0x2fa/0x3b0 kernel/locking/lockdep.c:2170
 check_prev_add kernel/locking/lockdep.c:3090 [inline]
 check_prevs_add kernel/locking/lockdep.c:3209 [inline]
 validate_chain+0x1661/0x5950 kernel/locking/lockdep.c:3825
 __lock_acquire+0x125b/0x1f80 kernel/locking/lockdep.c:5049
 lock_acquire+0x1f8/0x5a0 kernel/locking/lockdep.c:5662
 __mutex_lock_common kernel/locking/mutex.c:603 [inline]
 __mutex_lock+0x132/0xd80 kernel/locking/mutex.c:747
 hfs_extend_file+0xfb/0x1440 fs/hfs/extent.c:397
 hfs_bmap_reserve+0xd5/0x3f0 fs/hfs/btree.c:234
 __hfs_ext_write_extent+0x22e/0x4f0 fs/hfs/extent.c:121
 __hfs_ext_cache_extent+0x6a/0x990 fs/hfs/extent.c:174
 hfs_ext_read_extent fs/hfs/extent.c:202 [inline]
 hfs_extend_file+0x340/0x1440 fs/hfs/extent.c:401
 hfs_get_block+0x3e0/0xb60 fs/hfs/extent.c:353
 __block_write_begin_int+0x544/0x1a30 fs/buffer.c:1991
 __block_write_begin fs/buffer.c:2041 [inline]
 block_write_begin+0x98/0x1f0 fs/buffer.c:2102
 cont_write_begin+0x63f/0x880 fs/buffer.c:2456
 hfs_write_begin+0x86/0xd0 fs/hfs/inode.c:58
 generic_perform_write+0x2fc/0x5e0 mm/filemap.c:3817
 __generic_file_write_iter+0x176/0x400 mm/filemap.c:3945
 generic_file_write_iter+0xab/0x310 mm/filemap.c:3977
 call_write_iter include/linux/fs.h:2265 [inline]
 new_sync_write fs/read_write.c:491 [inline]
 vfs_write+0x857/0xbc0 fs/read_write.c:584
 ksys_write+0x19c/0x2c0 fs/read_write.c:637
 do_syscall_x64 arch/x86/entry/common.c:51 [inline]
 do_syscall_64+0x3b/0xb0 arch/x86/entry/common.c:81
 entry_SYSCALL_64_after_hwframe+0x68/0xd2
RIP: 0033:0x7f6e9f775ad9
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:00007f6ea05b8048 EFLAGS: 00000246 ORIG_RAX: 0000000000000001
RAX: ffffffffffffffda RBX: 00007f6e9f903f60 RCX: 00007f6e9f775ad9
RDX: 000000000000fea7 RSI: 0000000020000000 RDI: 0000000000000004
RBP: 00007f6e9f7e4e5d R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 000000000000000b R14: 00007f6e9f903f60 R15: 00007ffe4de88d88
 </TASK>

Crashes (10):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2024/07/18 01:20 linux-6.1.y cac15753b8ce 0f902625 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan possible deadlock in hfs_extend_file
2024/07/16 03:10 linux-6.1.y cac15753b8ce e8709b21 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan possible deadlock in hfs_extend_file
2024/06/17 19:30 linux-6.1.y eb44d83053d6 1f11cfd7 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan possible deadlock in hfs_extend_file
2024/05/15 10:54 linux-6.1.y 909ba1f1b414 94b087b1 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan possible deadlock in hfs_extend_file
2024/05/14 08:15 linux-6.1.y 909ba1f1b414 fdb4c10c .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan possible deadlock in hfs_extend_file
2024/05/14 07:43 linux-6.1.y 909ba1f1b414 fdb4c10c .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan possible deadlock in hfs_extend_file
2024/05/08 18:09 linux-6.1.y 909ba1f1b414 20bf80e1 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan possible deadlock in hfs_extend_file
2024/06/27 15:26 linux-6.1.y 99e6a620de00 6ef39602 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan-arm64 possible deadlock in hfs_extend_file
2024/06/25 12:49 linux-6.1.y eb44d83053d6 04bd2a30 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan-arm64 possible deadlock in hfs_extend_file
2024/04/04 03:10 linux-6.1.y 347385861c50 51c4dcff .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan-arm64 possible deadlock in hfs_extend_file
* Struck through repros no longer work on HEAD.