syzbot


possible deadlock in hfsplus_file_extend (2)

Status: upstream: reported on 2024/10/13 10:23
Reported-by: syzbot+2603b448a5ecd6d26356@syzkaller.appspotmail.com
First crash: 51d, last: 11h27m
Similar bugs (6)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
linux-6.1 possible deadlock in hfsplus_file_extend origin:upstream missing-backport C done 2760 122d 631d 3/3 fixed on 2024/09/08 06:54
upstream possible deadlock in hfsplus_file_extend (2) hfs C 21 10h58m 22d 0/28 upstream: reported C repro on 2024/11/11 11:50
linux-4.14 possible deadlock in hfsplus_file_extend hfsplus C 3 639d 705d 0/1 upstream: reported C repro on 2022/12/29 06:07
linux-5.15 possible deadlock in hfsplus_file_extend missing-backport origin:lts-only C done 3439 106d 632d 3/3 fixed on 2024/09/23 09:27
linux-4.19 possible deadlock in hfsplus_file_extend hfsplus C 258 638d 738d 0/1 upstream: reported C repro on 2022/11/26 10:00
upstream possible deadlock in hfsplus_file_extend hfs C error done 31659 49d 738d 28/28 fixed on 2024/10/21 12:45

Sample crash report:
loop6: detected capacity change from 0 to 1024
======================================================
WARNING: possible circular locking dependency detected
5.15.173-syzkaller #0 Not tainted
------------------------------------------------------
syz.6.1863/10211 is trying to acquire lock:
ffff88805a1a1548 (&HFSPLUS_I(inode)->extents_lock){+.+.}-{3:3}, at: hfsplus_file_extend+0x1d2/0x1b10 fs/hfsplus/extents.c:458

but task is already holding lock:
ffff88807a8ca0b0 (&tree->tree_lock/1){+.+.}-{3:3}, at: hfsplus_find_init+0x146/0x1c0 fs/hfsplus/bfind.c:28

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+0x1db/0x4f0 kernel/locking/lockdep.c:5623
       __mutex_lock_common+0x1da/0x25a0 kernel/locking/mutex.c:596
       __mutex_lock kernel/locking/mutex.c:729 [inline]
       mutex_lock_nested+0x17/0x20 kernel/locking/mutex.c:743
       hfsplus_find_init+0x146/0x1c0 fs/hfsplus/bfind.c:28
       hfsplus_ext_read_extent fs/hfsplus/extents.c:216 [inline]
       hfsplus_get_block+0x5c0/0x14e0 fs/hfsplus/extents.c:268
       __block_write_begin_int+0x60b/0x1650 fs/buffer.c:2012
       __block_write_begin fs/buffer.c:2062 [inline]
       block_write_begin fs/buffer.c:2122 [inline]
       cont_write_begin+0x5d6/0x840 fs/buffer.c:2471
       hfsplus_write_begin+0x92/0xd0 fs/hfsplus/inode.c:53
       generic_perform_write+0x2bf/0x5b0 mm/filemap.c:3785
       __generic_file_write_iter+0x243/0x4f0 mm/filemap.c:3912
       generic_file_write_iter+0xa7/0x1b0 mm/filemap.c:3944
       call_write_iter include/linux/fs.h:2174 [inline]
       new_sync_write fs/read_write.c:507 [inline]
       vfs_write+0xacd/0xe50 fs/read_write.c:594
       ksys_write+0x1a2/0x2c0 fs/read_write.c:647
       do_syscall_x64 arch/x86/entry/common.c:50 [inline]
       do_syscall_64+0x3b/0xb0 arch/x86/entry/common.c:80
       entry_SYSCALL_64_after_hwframe+0x66/0xd0

-> #0 (&HFSPLUS_I(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+0x1649/0x5930 kernel/locking/lockdep.c:3788
       __lock_acquire+0x1295/0x1ff0 kernel/locking/lockdep.c:5012
       lock_acquire+0x1db/0x4f0 kernel/locking/lockdep.c:5623
       __mutex_lock_common+0x1da/0x25a0 kernel/locking/mutex.c:596
       __mutex_lock kernel/locking/mutex.c:729 [inline]
       mutex_lock_nested+0x17/0x20 kernel/locking/mutex.c:743
       hfsplus_file_extend+0x1d2/0x1b10 fs/hfsplus/extents.c:458
       hfsplus_bmap_reserve+0x101/0x4e0 fs/hfsplus/btree.c:357
       __hfsplus_ext_write_extent+0x2a4/0x5b0 fs/hfsplus/extents.c:104
       __hfsplus_ext_cache_extent+0x84/0xe00 fs/hfsplus/extents.c:186
       hfsplus_ext_read_extent fs/hfsplus/extents.c:218 [inline]
       hfsplus_file_extend+0x435/0x1b10 fs/hfsplus/extents.c:462
       hfsplus_get_block+0x402/0x14e0 fs/hfsplus/extents.c:245
       __block_write_begin_int+0x60b/0x1650 fs/buffer.c:2012
       __block_write_begin fs/buffer.c:2062 [inline]
       block_write_begin fs/buffer.c:2122 [inline]
       cont_write_begin+0x5d6/0x840 fs/buffer.c:2471
       hfsplus_write_begin+0x92/0xd0 fs/hfsplus/inode.c:53
       generic_perform_write+0x2bf/0x5b0 mm/filemap.c:3785
       __generic_file_write_iter+0x243/0x4f0 mm/filemap.c:3912
       generic_file_write_iter+0xa7/0x1b0 mm/filemap.c:3944
       call_write_iter include/linux/fs.h:2174 [inline]
       aio_write+0x566/0x780 fs/aio.c:1594
       io_submit_one+0x768/0x18d0 fs/aio.c:2013
       __do_sys_io_submit fs/aio.c:2072 [inline]
       __se_sys_io_submit+0x17b/0x2f0 fs/aio.c:2042
       do_syscall_x64 arch/x86/entry/common.c:50 [inline]
       do_syscall_64+0x3b/0xb0 arch/x86/entry/common.c:80
       entry_SYSCALL_64_after_hwframe+0x66/0xd0

other info that might help us debug this:

 Possible unsafe locking scenario:

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

 *** DEADLOCK ***

3 locks held by syz.6.1863/10211:
 #0: ffff88805a1a4680 (&sb->s_type->i_mutex_key#32){+.+.}-{3:3}, at: inode_lock include/linux/fs.h:789 [inline]
 #0: ffff88805a1a4680 (&sb->s_type->i_mutex_key#32){+.+.}-{3:3}, at: generic_file_write_iter+0x7c/0x1b0 mm/filemap.c:3941
 #1: ffff88805a1a4488 (&hip->extents_lock){+.+.}-{3:3}, at: hfsplus_file_extend+0x1d2/0x1b10 fs/hfsplus/extents.c:458
 #2: ffff88807a8ca0b0 (&tree->tree_lock/1){+.+.}-{3:3}, at: hfsplus_find_init+0x146/0x1c0 fs/hfsplus/bfind.c:28

stack backtrace:
CPU: 0 PID: 10211 Comm: syz.6.1863 Not tainted 5.15.173-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:88 [inline]
 dump_stack_lvl+0x1e3/0x2d0 lib/dump_stack.c:106
 check_noncircular+0x2f8/0x3b0 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+0x1649/0x5930 kernel/locking/lockdep.c:3788
 __lock_acquire+0x1295/0x1ff0 kernel/locking/lockdep.c:5012
 lock_acquire+0x1db/0x4f0 kernel/locking/lockdep.c:5623
 __mutex_lock_common+0x1da/0x25a0 kernel/locking/mutex.c:596
 __mutex_lock kernel/locking/mutex.c:729 [inline]
 mutex_lock_nested+0x17/0x20 kernel/locking/mutex.c:743
 hfsplus_file_extend+0x1d2/0x1b10 fs/hfsplus/extents.c:458
 hfsplus_bmap_reserve+0x101/0x4e0 fs/hfsplus/btree.c:357
 __hfsplus_ext_write_extent+0x2a4/0x5b0 fs/hfsplus/extents.c:104
 __hfsplus_ext_cache_extent+0x84/0xe00 fs/hfsplus/extents.c:186
 hfsplus_ext_read_extent fs/hfsplus/extents.c:218 [inline]
 hfsplus_file_extend+0x435/0x1b10 fs/hfsplus/extents.c:462
 hfsplus_get_block+0x402/0x14e0 fs/hfsplus/extents.c:245
 __block_write_begin_int+0x60b/0x1650 fs/buffer.c:2012
 __block_write_begin fs/buffer.c:2062 [inline]
 block_write_begin fs/buffer.c:2122 [inline]
 cont_write_begin+0x5d6/0x840 fs/buffer.c:2471
 hfsplus_write_begin+0x92/0xd0 fs/hfsplus/inode.c:53
 generic_perform_write+0x2bf/0x5b0 mm/filemap.c:3785
 __generic_file_write_iter+0x243/0x4f0 mm/filemap.c:3912
 generic_file_write_iter+0xa7/0x1b0 mm/filemap.c:3944
 call_write_iter include/linux/fs.h:2174 [inline]
 aio_write+0x566/0x780 fs/aio.c:1594
 io_submit_one+0x768/0x18d0 fs/aio.c:2013
 __do_sys_io_submit fs/aio.c:2072 [inline]
 __se_sys_io_submit+0x17b/0x2f0 fs/aio.c:2042
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x3b/0xb0 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x66/0xd0
RIP: 0033:0x7f0b72632f19
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:00007f0b704a9058 EFLAGS: 00000246 ORIG_RAX: 00000000000000d1
RAX: ffffffffffffffda RBX: 00007f0b727f8fa0 RCX: 00007f0b72632f19
RDX: 0000000020000540 RSI: 000000000000003b RDI: 00007f0b727ca000
RBP: 00007f0b726a6986 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 0000000000000000 R14: 00007f0b727f8fa0 R15: 00007ffd2520eb58
 </TASK>

Crashes (7):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2024/12/03 03:31 linux-5.15.y 0a51d2d4527b 578925bc .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan possible deadlock in hfsplus_file_extend
2024/12/03 03:31 linux-5.15.y 0a51d2d4527b 578925bc .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan possible deadlock in hfsplus_file_extend
2024/12/02 17:30 linux-5.15.y 0a51d2d4527b b499ea68 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan possible deadlock in hfsplus_file_extend
2024/12/02 13:40 linux-5.15.y 0a51d2d4527b b499ea68 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan possible deadlock in hfsplus_file_extend
2024/12/02 13:40 linux-5.15.y 0a51d2d4527b b499ea68 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan possible deadlock in hfsplus_file_extend
2024/10/13 10:22 linux-5.15.y 3a5928702e71 084d8178 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan possible deadlock in hfsplus_file_extend
2024/10/13 10:22 linux-5.15.y 3a5928702e71 084d8178 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan possible deadlock in hfsplus_file_extend
* Struck through repros no longer work on HEAD.