syzbot


possible deadlock in hfs_extend_file (2)

Status: auto-obsoleted due to no activity on 2024/01/31 18:25
Reported-by: syzbot+ae98efb2630f621f5a9a@syzkaller.appspotmail.com
First crash: 191d, last: 191d
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 491d 491d 0/1 upstream: reported on 2022/12/27 15:22
linux-6.1 possible deadlock in hfs_extend_file 7 229d 415d 0/3 auto-obsoleted due to no activity on 2023/12/24 21:20
upstream possible deadlock in hfs_extend_file hfs 46 252d 496d 0/26 auto-obsoleted due to no activity on 2023/11/06 09:48
linux-6.1 possible deadlock in hfs_extend_file (2) 1 27d 27d 0/3 upstream: reported on 2024/04/04 03:11
upstream possible deadlock in hfs_extend_file (3) hfs 27 1h55m 13d 0/26 upstream: reported on 2024/04/18 14:41
linux-5.15 possible deadlock in hfs_extend_file (3) 9 4d20h 49d 0/3 upstream: reported on 2024/03/13 05:11
upstream possible deadlock in hfs_extend_file (2) hfs C done done 4 120d 141d 0/26 auto-obsoleted due to no activity on 2024/04/11 05:11
linux-5.15 possible deadlock in hfs_extend_file 5 316d 380d 0/3 auto-obsoleted due to no activity on 2023/09/28 05:53

Sample crash report:
hfs: unable to locate alternate MDB
hfs: continuing without an alternate MDB
======================================================
WARNING: possible circular locking dependency detected
5.15.136-syzkaller #0 Not tainted
------------------------------------------------------
syz-executor.0/5608 is trying to acquire lock:
ffff0000dad60778 (&HFS_I(tree->inode)->extents_lock){+.+.}-{3:3}, at: hfs_extend_file+0xe4/0x10e4 fs/hfs/extent.c:397

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

which lock already depends on the new lock.


the existing dependency chain (in reverse order) is:

-> #1 (&tree->tree_lock/1){+.+.}-{3:3}:
       __mutex_lock_common+0x194/0x2154 kernel/locking/mutex.c:596
       __mutex_lock kernel/locking/mutex.c:729 [inline]
       mutex_lock_nested+0xa4/0xf8 kernel/locking/mutex.c:743
       hfs_find_init+0x148/0x1c8
       hfs_ext_read_extent fs/hfs/extent.c:200 [inline]
       hfs_get_block+0x290/0x9fc fs/hfs/extent.c:366
       block_read_full_page+0x2a0/0xc4c fs/buffer.c:2290
       hfs_readpage+0x28/0x38 fs/hfs/inode.c:39
       do_read_cache_page+0x60c/0x950
       read_cache_page+0x68/0x84 mm/filemap.c:3565
       read_mapping_page include/linux/pagemap.h:515 [inline]
       __hfs_bnode_create+0x3fc/0x880 fs/hfs/bnode.c:297
       hfs_bnode_find+0x200/0xc88 fs/hfs/bnode.c:346
       hfs_brec_find+0x130/0x498 fs/hfs/bfind.c:126
       hfs_brec_read+0x30/0x120 fs/hfs/bfind.c:165
       hfs_cat_find_brec+0x124/0x3cc fs/hfs/catalog.c:194
       hfs_fill_super+0xe00/0x13b4 fs/hfs/super.c:419
       mount_bdev+0x274/0x370 fs/super.c:1387
       hfs_mount+0x44/0x58 fs/hfs/super.c:456
       legacy_get_tree+0xd4/0x16c fs/fs_context.c:611
       vfs_get_tree+0x90/0x274 fs/super.c:1517
       do_new_mount+0x25c/0x8c4 fs/namespace.c:2994
       path_mount+0x594/0x101c fs/namespace.c:3324
       do_mount fs/namespace.c:3337 [inline]
       __do_sys_mount fs/namespace.c:3545 [inline]
       __se_sys_mount fs/namespace.c:3522 [inline]
       __arm64_sys_mount+0x510/0x5e0 fs/namespace.c:3522
       __invoke_syscall arch/arm64/kernel/syscall.c:38 [inline]
       invoke_syscall+0x98/0x2b8 arch/arm64/kernel/syscall.c:52
       el0_svc_common+0x138/0x258 arch/arm64/kernel/syscall.c:142
       do_el0_svc+0x58/0x14c arch/arm64/kernel/syscall.c:181
       el0_svc+0x7c/0x1f0 arch/arm64/kernel/entry-common.c:608
       el0t_64_sync_handler+0x84/0xe4 arch/arm64/kernel/entry-common.c:626
       el0t_64_sync+0x1a0/0x1a4 arch/arm64/kernel/entry.S:584

-> #0 (&HFS_I(tree->inode)->extents_lock){+.+.}-{3:3}:
       check_prev_add kernel/locking/lockdep.c:3053 [inline]
       check_prevs_add kernel/locking/lockdep.c:3172 [inline]
       validate_chain kernel/locking/lockdep.c:3787 [inline]
       __lock_acquire+0x32cc/0x7620 kernel/locking/lockdep.c:5011
       lock_acquire+0x240/0x77c kernel/locking/lockdep.c:5622
       __mutex_lock_common+0x194/0x2154 kernel/locking/mutex.c:596
       __mutex_lock kernel/locking/mutex.c:729 [inline]
       mutex_lock_nested+0xa4/0xf8 kernel/locking/mutex.c:743
       hfs_extend_file+0xe4/0x10e4 fs/hfs/extent.c:397
       hfs_bmap_reserve+0xd0/0x3b4 fs/hfs/btree.c:231
       __hfs_ext_write_extent+0x1a0/0x468 fs/hfs/extent.c:121
       __hfs_ext_cache_extent+0x84/0x754 fs/hfs/extent.c:174
       hfs_ext_read_extent fs/hfs/extent.c:202 [inline]
       hfs_extend_file+0x278/0x10e4 fs/hfs/extent.c:401
       hfs_get_block+0x3ac/0x9fc fs/hfs/extent.c:353
       __block_write_begin_int+0x3ec/0x1608 fs/buffer.c:2012
       __block_write_begin fs/buffer.c:2062 [inline]
       block_write_begin fs/buffer.c:2122 [inline]
       cont_write_begin+0x538/0x710 fs/buffer.c:2471
       hfs_write_begin+0xa8/0xf8 fs/hfs/inode.c:59
       pagecache_write_begin+0xa0/0xc0 mm/filemap.c:3599
       cont_expand_zero fs/buffer.c:2398 [inline]
       cont_write_begin+0x26c/0x710 fs/buffer.c:2461
       hfs_write_begin+0xa8/0xf8 fs/hfs/inode.c:59
       pagecache_write_begin+0xa0/0xc0 mm/filemap.c:3599
       hfs_file_truncate+0x1a4/0xea4 fs/hfs/extent.c:494
       hfs_inode_setattr+0x3a8/0x5c8 fs/hfs/inode.c:654
       notify_change+0xa34/0xcf8 fs/attr.c:505
       do_truncate+0x1c0/0x28c fs/open.c:65
       do_sys_ftruncate+0x288/0x31c fs/open.c:193
       __do_sys_ftruncate fs/open.c:204 [inline]
       __se_sys_ftruncate fs/open.c:202 [inline]
       __arm64_sys_ftruncate+0x60/0x74 fs/open.c:202
       __invoke_syscall arch/arm64/kernel/syscall.c:38 [inline]
       invoke_syscall+0x98/0x2b8 arch/arm64/kernel/syscall.c:52
       el0_svc_common+0x138/0x258 arch/arm64/kernel/syscall.c:142
       do_el0_svc+0x58/0x14c arch/arm64/kernel/syscall.c:181
       el0_svc+0x7c/0x1f0 arch/arm64/kernel/entry-common.c:608
       el0t_64_sync_handler+0x84/0xe4 arch/arm64/kernel/entry-common.c:626
       el0t_64_sync+0x1a0/0x1a4 arch/arm64/kernel/entry.S:584

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 ***

4 locks held by syz-executor.0/5608:
 #0: ffff0000da248460 (sb_writers#26){.+.+}-{0:0}, at: do_sys_ftruncate+0x214/0x31c fs/open.c:190
 #1: ffff0000dad61628 (&sb->s_type->i_mutex_key#32){+.+.}-{3:3}, at: inode_lock include/linux/fs.h:787 [inline]
 #1: ffff0000dad61628 (&sb->s_type->i_mutex_key#32){+.+.}-{3:3}, at: do_truncate+0x1ac/0x28c fs/open.c:63
 #2: ffff0000dad61478 (&HFS_I(inode)->extents_lock){+.+.}-{3:3}, at: hfs_extend_file+0xe4/0x10e4 fs/hfs/extent.c:397
 #3: ffff0000ced840b0 (&tree->tree_lock/1){+.+.}-{3:3}, at: hfs_find_init+0x148/0x1c8

stack backtrace:
CPU: 0 PID: 5608 Comm: syz-executor.0 Not tainted 5.15.136-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 09/06/2023
Call trace:
 dump_backtrace+0x0/0x530 arch/arm64/kernel/stacktrace.c:152
 show_stack+0x2c/0x3c arch/arm64/kernel/stacktrace.c:216
 __dump_stack lib/dump_stack.c:88 [inline]
 dump_stack_lvl+0x108/0x170 lib/dump_stack.c:106
 dump_stack+0x1c/0x58 lib/dump_stack.c:113
 print_circular_bug+0x150/0x1b8 kernel/locking/lockdep.c:2011
 check_noncircular+0x2cc/0x378 kernel/locking/lockdep.c:2133
 check_prev_add kernel/locking/lockdep.c:3053 [inline]
 check_prevs_add kernel/locking/lockdep.c:3172 [inline]
 validate_chain kernel/locking/lockdep.c:3787 [inline]
 __lock_acquire+0x32cc/0x7620 kernel/locking/lockdep.c:5011
 lock_acquire+0x240/0x77c kernel/locking/lockdep.c:5622
 __mutex_lock_common+0x194/0x2154 kernel/locking/mutex.c:596
 __mutex_lock kernel/locking/mutex.c:729 [inline]
 mutex_lock_nested+0xa4/0xf8 kernel/locking/mutex.c:743
 hfs_extend_file+0xe4/0x10e4 fs/hfs/extent.c:397
 hfs_bmap_reserve+0xd0/0x3b4 fs/hfs/btree.c:231
 __hfs_ext_write_extent+0x1a0/0x468 fs/hfs/extent.c:121
 __hfs_ext_cache_extent+0x84/0x754 fs/hfs/extent.c:174
 hfs_ext_read_extent fs/hfs/extent.c:202 [inline]
 hfs_extend_file+0x278/0x10e4 fs/hfs/extent.c:401
 hfs_get_block+0x3ac/0x9fc fs/hfs/extent.c:353
 __block_write_begin_int+0x3ec/0x1608 fs/buffer.c:2012
 __block_write_begin fs/buffer.c:2062 [inline]
 block_write_begin fs/buffer.c:2122 [inline]
 cont_write_begin+0x538/0x710 fs/buffer.c:2471
 hfs_write_begin+0xa8/0xf8 fs/hfs/inode.c:59
 pagecache_write_begin+0xa0/0xc0 mm/filemap.c:3599
 cont_expand_zero fs/buffer.c:2398 [inline]
 cont_write_begin+0x26c/0x710 fs/buffer.c:2461
 hfs_write_begin+0xa8/0xf8 fs/hfs/inode.c:59
 pagecache_write_begin+0xa0/0xc0 mm/filemap.c:3599
 hfs_file_truncate+0x1a4/0xea4 fs/hfs/extent.c:494
 hfs_inode_setattr+0x3a8/0x5c8 fs/hfs/inode.c:654
 notify_change+0xa34/0xcf8 fs/attr.c:505
 do_truncate+0x1c0/0x28c fs/open.c:65
 do_sys_ftruncate+0x288/0x31c fs/open.c:193
 __do_sys_ftruncate fs/open.c:204 [inline]
 __se_sys_ftruncate fs/open.c:202 [inline]
 __arm64_sys_ftruncate+0x60/0x74 fs/open.c:202
 __invoke_syscall arch/arm64/kernel/syscall.c:38 [inline]
 invoke_syscall+0x98/0x2b8 arch/arm64/kernel/syscall.c:52
 el0_svc_common+0x138/0x258 arch/arm64/kernel/syscall.c:142
 do_el0_svc+0x58/0x14c arch/arm64/kernel/syscall.c:181
 el0_svc+0x7c/0x1f0 arch/arm64/kernel/entry-common.c:608
 el0t_64_sync_handler+0x84/0xe4 arch/arm64/kernel/entry-common.c:626
 el0t_64_sync+0x1a0/0x1a4 arch/arm64/kernel/entry.S:584

Crashes (1):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2023/10/23 18:25 linux-5.15.y 00c03985402e 989a3687 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan-arm64 possible deadlock in hfs_extend_file
* Struck through repros no longer work on HEAD.