syzbot


possible deadlock in hfs_extend_file

Status: upstream: reported on 2025/06/17 13:12
Reported-by: syzbot+c50f306994c052787c32@syzkaller.appspotmail.com
First crash: 19h10m, last: 9h05m
Similar bugs (9)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
linux-4.19 possible deadlock in hfs_extend_file hfs 1 903d 903d 0/1 upstream: reported on 2022/12/27 15:22
linux-5.15 possible deadlock in hfs_extend_file (2) 1 603d 603d 0/3 auto-obsoleted due to no activity on 2024/01/31 18:25
linux-6.1 possible deadlock in hfs_extend_file 7 641d 827d 0/3 auto-obsoleted due to no activity on 2023/12/24 21:20
upstream possible deadlock in hfs_extend_file hfs 46 664d 909d 0/28 auto-obsoleted due to no activity on 2023/11/06 09:48
linux-6.1 possible deadlock in hfs_extend_file (2) 91 23h25m 440d 0/3 upstream: reported on 2024/04/04 03:11
upstream possible deadlock in hfs_extend_file (3) hfs C unreliable 1665 1h43m 425d 0/28 upstream: reported C repro on 2024/04/18 14:41
linux-5.15 possible deadlock in hfs_extend_file (3) 140 7h57m 462d 0/3 upstream: reported on 2024/03/13 05:11
upstream possible deadlock in hfs_extend_file (2) hfs C done done 4 533d 553d 0/28 auto-obsoleted due to no activity on 2024/04/11 05:11
linux-5.15 possible deadlock in hfs_extend_file 5 729d 792d 0/3 auto-obsoleted due to no activity on 2023/09/28 05:53

Sample crash report:
loop8: detected capacity change from 0 to 64
======================================================
WARNING: possible circular locking dependency detected
6.6.93-syzkaller #0 Not tainted
------------------------------------------------------
syz.8.6444/31179 is trying to acquire lock:
ffff88804e74ef78 (&HFS_I(tree->inode)->extents_lock){+.+.}-{3:3}, at: hfs_extend_file+0xdb/0x1220 fs/hfs/extent.c:397

but task is already holding lock:
ffff88806ba420b0 (&tree->tree_lock#2/1){+.+.}-{3:3}, at: hfs_find_init+0x15f/0x1d0 fs/hfs/bfind.c:-1

which lock already depends on the new lock.


the existing dependency chain (in reverse order) is:

-> #1 (&tree->tree_lock#2/1){+.+.}-{3:3}:
       __mutex_lock_common kernel/locking/mutex.c:603 [inline]
       __mutex_lock+0x129/0xcc0 kernel/locking/mutex.c:747
       hfs_find_init+0x15f/0x1d0 fs/hfs/bfind.c:-1
       hfs_ext_read_extent fs/hfs/extent.c:200 [inline]
       hfs_extend_file+0x2ef/0x1220 fs/hfs/extent.c:401
       hfs_bmap_reserve+0x107/0x430 fs/hfs/btree.c:234
       hfs_cat_create+0x1b4/0x620 fs/hfs/catalog.c:104
       hfs_create+0x66/0xd0 fs/hfs/dir.c:202
       lookup_open fs/namei.c:3488 [inline]
       open_last_lookups fs/namei.c:3556 [inline]
       path_openat+0x1277/0x3190 fs/namei.c:3786
       do_filp_open+0x1c5/0x3d0 fs/namei.c:3816
       do_sys_openat2+0x12c/0x1c0 fs/open.c:1419
       do_sys_open fs/open.c:1434 [inline]
       __do_sys_openat fs/open.c:1450 [inline]
       __se_sys_openat fs/open.c:1445 [inline]
       __x64_sys_openat+0x139/0x160 fs/open.c:1445
       do_syscall_x64 arch/x86/entry/common.c:51 [inline]
       do_syscall_64+0x55/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:3134 [inline]
       check_prevs_add kernel/locking/lockdep.c:3253 [inline]
       validate_chain kernel/locking/lockdep.c:3869 [inline]
       __lock_acquire+0x2ddb/0x7c80 kernel/locking/lockdep.c:5137
       lock_acquire+0x197/0x410 kernel/locking/lockdep.c:5754
       __mutex_lock_common kernel/locking/mutex.c:603 [inline]
       __mutex_lock+0x129/0xcc0 kernel/locking/mutex.c:747
       hfs_extend_file+0xdb/0x1220 fs/hfs/extent.c:397
       hfs_bmap_reserve+0x107/0x430 fs/hfs/btree.c:234
       __hfs_ext_write_extent+0x1fa/0x470 fs/hfs/extent.c:121
       __hfs_ext_cache_extent+0x6b/0x9b0 fs/hfs/extent.c:174
       hfs_ext_read_extent fs/hfs/extent.c:202 [inline]
       hfs_extend_file+0x317/0x1220 fs/hfs/extent.c:401
       hfs_get_block+0x3d8/0xbd0 fs/hfs/extent.c:353
       __block_write_begin_int+0x566/0x1ad0 fs/buffer.c:2124
       __block_write_begin fs/buffer.c:2173 [inline]
       block_write_begin+0x9a/0x1e0 fs/buffer.c:2234
       cont_write_begin+0x5c8/0x7e0 fs/buffer.c:2591
       hfs_write_begin+0x8b/0xd0 fs/hfs/inode.c:58
       generic_perform_write+0x2fb/0x5b0 mm/filemap.c:4016
       generic_file_write_iter+0xaf/0x2e0 mm/filemap.c:4137
       call_write_iter include/linux/fs.h:2018 [inline]
       new_sync_write fs/read_write.c:491 [inline]
       vfs_write+0x43b/0x940 fs/read_write.c:584
       ksys_write+0x147/0x250 fs/read_write.c:637
       do_syscall_x64 arch/x86/entry/common.c:51 [inline]
       do_syscall_64+0x55/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#2/1);
                               lock(&HFS_I(tree->inode)->extents_lock);
                               lock(&tree->tree_lock#2/1);
  lock(&HFS_I(tree->inode)->extents_lock);

 *** DEADLOCK ***

5 locks held by syz.8.6444/31179:
 #0: ffff8880647054c8 (&f->f_pos_lock){+.+.}-{3:3}, at: __fdget_pos+0x2a3/0x330 fs/file.c:1042
 #1: ffff88801f300418 (sb_writers#29){.+.+}-{0:0}, at: vfs_write+0x20e/0x940 fs/read_write.c:580
 #2: ffff8880673db038 (&sb->s_type->i_mutex_key#37){+.+.}-{3:3}, at: inode_lock include/linux/fs.h:804 [inline]
 #2: ffff8880673db038 (&sb->s_type->i_mutex_key#37){+.+.}-{3:3}, at: generic_file_write_iter+0x83/0x2e0 mm/filemap.c:4134
 #3: ffff8880673dae78 (&HFS_I(inode)->extents_lock#2){+.+.}-{3:3}, at: hfs_extend_file+0xdb/0x1220 fs/hfs/extent.c:397
 #4: ffff88806ba420b0 (&tree->tree_lock#2/1){+.+.}-{3:3}, at: hfs_find_init+0x15f/0x1d0 fs/hfs/bfind.c:-1

stack backtrace:
CPU: 1 PID: 31179 Comm: syz.8.6444 Not tainted 6.6.93-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 05/07/2025
Call Trace:
 <TASK>
 dump_stack_lvl+0x16c/0x230 lib/dump_stack.c:106
 check_noncircular+0x2bd/0x3c0 kernel/locking/lockdep.c:2187
 check_prev_add kernel/locking/lockdep.c:3134 [inline]
 check_prevs_add kernel/locking/lockdep.c:3253 [inline]
 validate_chain kernel/locking/lockdep.c:3869 [inline]
 __lock_acquire+0x2ddb/0x7c80 kernel/locking/lockdep.c:5137
 lock_acquire+0x197/0x410 kernel/locking/lockdep.c:5754
 __mutex_lock_common kernel/locking/mutex.c:603 [inline]
 __mutex_lock+0x129/0xcc0 kernel/locking/mutex.c:747
 hfs_extend_file+0xdb/0x1220 fs/hfs/extent.c:397
 hfs_bmap_reserve+0x107/0x430 fs/hfs/btree.c:234
 __hfs_ext_write_extent+0x1fa/0x470 fs/hfs/extent.c:121
 __hfs_ext_cache_extent+0x6b/0x9b0 fs/hfs/extent.c:174
 hfs_ext_read_extent fs/hfs/extent.c:202 [inline]
 hfs_extend_file+0x317/0x1220 fs/hfs/extent.c:401
 hfs_get_block+0x3d8/0xbd0 fs/hfs/extent.c:353
 __block_write_begin_int+0x566/0x1ad0 fs/buffer.c:2124
 __block_write_begin fs/buffer.c:2173 [inline]
 block_write_begin+0x9a/0x1e0 fs/buffer.c:2234
 cont_write_begin+0x5c8/0x7e0 fs/buffer.c:2591
 hfs_write_begin+0x8b/0xd0 fs/hfs/inode.c:58
 generic_perform_write+0x2fb/0x5b0 mm/filemap.c:4016
 generic_file_write_iter+0xaf/0x2e0 mm/filemap.c:4137
 call_write_iter include/linux/fs.h:2018 [inline]
 new_sync_write fs/read_write.c:491 [inline]
 vfs_write+0x43b/0x940 fs/read_write.c:584
 ksys_write+0x147/0x250 fs/read_write.c:637
 do_syscall_x64 arch/x86/entry/common.c:51 [inline]
 do_syscall_64+0x55/0xb0 arch/x86/entry/common.c:81
 entry_SYSCALL_64_after_hwframe+0x68/0xd2
RIP: 0033:0x7f11a178e929
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:00007f11a2573038 EFLAGS: 00000246 ORIG_RAX: 0000000000000001
RAX: ffffffffffffffda RBX: 00007f11a19b5fa0 RCX: 00007f11a178e929
RDX: 00000000002a979d RSI: 0000200000000000 RDI: 0000000000000005
RBP: 00007f11a1810b39 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 0000000000000000 R14: 00007f11a19b5fa0 R15: 00007ffecab5a4e8
 </TASK>

Crashes (3):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2025/06/17 23:17 linux-6.6.y c2603c511feb e77fae15 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-6-kasan possible deadlock in hfs_extend_file
2025/06/17 13:11 linux-6.6.y c2603c511feb cfebc887 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-6-kasan possible deadlock in hfs_extend_file
2025/06/17 13:11 linux-6.6.y c2603c511feb cfebc887 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-6-kasan possible deadlock in hfs_extend_file
* Struck through repros no longer work on HEAD.