syzbot


possible deadlock in hfsplus_block_free (3)

Status: upstream: reported on 2025/03/03 05:44
Reported-by: syzbot+ea75b2989fe7c5235f45@syzkaller.appspotmail.com
First crash: 9d05h, last: 7d09h
Similar bugs (8)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
linux-6.1 possible deadlock in hfsplus_block_free (2) 4 277d 277d 0/3 auto-obsoleted due to no activity on 2024/09/15 13:42
linux-4.14 possible deadlock in hfsplus_block_free hfsplus 10 746d 831d 0/1 upstream: reported on 2022/12/01 19:36
linux-4.19 possible deadlock in hfsplus_block_free hfsplus 20 737d 828d 0/1 upstream: reported on 2022/12/04 19:32
upstream possible deadlock in hfsplus_block_free hfs C inconclusive error 275 3d21h 834d 0/28 upstream: reported C repro on 2022/11/29 08:32
linux-5.15 possible deadlock in hfsplus_block_free 20 505d 709d 0/3 auto-obsoleted due to no activity on 2024/01/31 18:41
linux-6.1 possible deadlock in hfsplus_block_free (3) 3 15d 23d 0/3 upstream: reported on 2025/02/16 19:51
linux-5.15 possible deadlock in hfsplus_block_free (2) 1 277d 277d 0/3 auto-obsoleted due to no activity on 2024/09/15 11:28
linux-6.1 possible deadlock in hfsplus_block_free 27 431d 695d 0/3 auto-obsoleted due to no activity on 2024/04/14 19:02

Sample crash report:
======================================================
WARNING: possible circular locking dependency detected
5.15.178-syzkaller #0 Not tainted
------------------------------------------------------
syz.8.335/6827 is trying to acquire lock:
ffff0000d37b20f8 (&sbi->alloc_mutex){+.+.}-{3:3}, at: hfsplus_block_free+0xcc/0x514 fs/hfsplus/bitmap.c:182

but task is already holding lock:
ffff0000eb20b048 (&HFSPLUS_I(inode)->extents_lock){+.+.}-{3:3}, at: hfsplus_file_truncate+0x250/0xa2c fs/hfsplus/extents.c:577

which lock already depends on the new lock.


the existing dependency chain (in reverse order) is:

-> #1 (&HFSPLUS_I(inode)->extents_lock){+.+.}-{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
       hfsplus_get_block+0x2c4/0x1194 fs/hfsplus/extents.c:260
       block_read_full_page+0x2a0/0xc4c fs/buffer.c:2290
       hfsplus_readpage+0x28/0x38 fs/hfsplus/inode.c:28
       do_read_cache_page+0x60c/0x950
       read_cache_page+0x68/0x84 mm/filemap.c:3574
       read_mapping_page include/linux/pagemap.h:515 [inline]
       hfsplus_block_allocate+0xe0/0x800 fs/hfsplus/bitmap.c:37
       hfsplus_file_extend+0x770/0x14e0 fs/hfsplus/extents.c:469
       hfsplus_get_block+0x398/0x1194 fs/hfsplus/extents.c:245
       __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
       hfsplus_write_begin+0xa8/0xf8 fs/hfsplus/inode.c:53
       pagecache_write_begin+0xa0/0xc0 mm/filemap.c:3608
       cont_expand_zero fs/buffer.c:2398 [inline]
       cont_write_begin+0x26c/0x710 fs/buffer.c:2461
       hfsplus_write_begin+0xa8/0xf8 fs/hfsplus/inode.c:53
       pagecache_write_begin+0xa0/0xc0 mm/filemap.c:3608
       generic_cont_expand_simple+0x12c/0x208 fs/buffer.c:2362
       hfsplus_setattr+0x148/0x25c fs/hfsplus/inode.c:261
       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

-> #0 (&sbi->alloc_mutex){+.+.}-{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:3788 [inline]
       __lock_acquire+0x32d4/0x7638 kernel/locking/lockdep.c:5012
       lock_acquire+0x240/0x77c kernel/locking/lockdep.c:5623
       __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
       hfsplus_block_free+0xcc/0x514 fs/hfsplus/bitmap.c:182
       hfsplus_free_extents+0x148/0x8d4 fs/hfsplus/extents.c:363
       hfsplus_file_truncate+0x678/0xa2c fs/hfsplus/extents.c:592
       hfsplus_delete_inode+0x154/0x200
       hfsplus_unlink+0x414/0x6a0 fs/hfsplus/dir.c:405
       vfs_unlink+0x2f0/0x508 fs/namei.c:4280
       do_unlinkat+0x4cc/0x830 fs/namei.c:4348
       __do_sys_unlinkat fs/namei.c:4391 [inline]
       __se_sys_unlinkat fs/namei.c:4384 [inline]
       __arm64_sys_unlinkat+0xcc/0xfc fs/namei.c:4384
       __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(&HFSPLUS_I(inode)->extents_lock);
                               lock(&sbi->alloc_mutex);
                               lock(&HFSPLUS_I(inode)->extents_lock);
  lock(&sbi->alloc_mutex);

 *** DEADLOCK ***

5 locks held by syz.8.335/6827:
 #0: ffff0000dad28460 (sb_writers#14){.+.+}-{0:0}, at: mnt_want_write+0x44/0x9c fs/namespace.c:377
 #1: ffff0000eb20e840 (&type->i_mutex_dir_key#13/1){+.+.}-{3:3}, at: inode_lock_nested include/linux/fs.h:824 [inline]
 #1: ffff0000eb20e840 (&type->i_mutex_dir_key#13/1){+.+.}-{3:3}, at: do_unlinkat+0x2d0/0x830 fs/namei.c:4331
 #2: ffff0000eb20b240 (&sb->s_type->i_mutex_key#22){++++}-{3:3}, at: inode_lock include/linux/fs.h:789 [inline]
 #2: ffff0000eb20b240 (&sb->s_type->i_mutex_key#22){++++}-{3:3}, at: vfs_unlink+0xd8/0x508 fs/namei.c:4269
 #3: ffff0000d37b2198 (&sbi->vh_mutex){+.+.}-{3:3}, at: hfsplus_unlink+0x144/0x6a0 fs/hfsplus/dir.c:370
 #4: ffff0000eb20b048 (&HFSPLUS_I(inode)->extents_lock){+.+.}-{3:3}, at: hfsplus_file_truncate+0x250/0xa2c fs/hfsplus/extents.c:577

stack backtrace:
CPU: 0 PID: 6827 Comm: syz.8.335 Not tainted 5.15.178-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 02/12/2025
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:3788 [inline]
 __lock_acquire+0x32d4/0x7638 kernel/locking/lockdep.c:5012
 lock_acquire+0x240/0x77c kernel/locking/lockdep.c:5623
 __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
 hfsplus_block_free+0xcc/0x514 fs/hfsplus/bitmap.c:182
 hfsplus_free_extents+0x148/0x8d4 fs/hfsplus/extents.c:363
 hfsplus_file_truncate+0x678/0xa2c fs/hfsplus/extents.c:592
 hfsplus_delete_inode+0x154/0x200
 hfsplus_unlink+0x414/0x6a0 fs/hfsplus/dir.c:405
 vfs_unlink+0x2f0/0x508 fs/namei.c:4280
 do_unlinkat+0x4cc/0x830 fs/namei.c:4348
 __do_sys_unlinkat fs/namei.c:4391 [inline]
 __se_sys_unlinkat fs/namei.c:4384 [inline]
 __arm64_sys_unlinkat+0xcc/0xfc fs/namei.c:4384
 __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 (2):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2025/03/05 01:34 linux-5.15.y c16c81c81336 c3901742 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan-arm64 possible deadlock in hfsplus_block_free
2025/03/03 05:43 linux-5.15.y c16c81c81336 c3901742 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan-arm64 possible deadlock in hfsplus_block_free
* Struck through repros no longer work on HEAD.