syzbot


possible deadlock in hfsplus_block_allocate

Status: upstream: reported on 2022/11/29 13:38
Reported-by: syzbot+b6ccd31787585244a855@syzkaller.appspotmail.com
First crash: 67d, last: 12d
similar bugs (2):
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
linux-4.14 possible deadlock in hfsplus_block_allocate hfsplus 2 17d 34d 0/1 upstream: reported on 2023/01/02 02:59
linux-4.19 possible deadlock in hfsplus_block_allocate hfsplus 2 37d 44d 0/1 upstream: reported on 2022/12/22 13:15

Sample crash report:
======================================================
WARNING: possible circular locking dependency detected
6.2.0-rc4-syzkaller-00067-g7287904c8771 #0 Not tainted
------------------------------------------------------
syz-executor.2/25306 is trying to acquire lock:
ffff88807a73c8f8 (&sbi->alloc_mutex){+.+.}-{3:3}, at: hfsplus_block_allocate+0x96/0x910 fs/hfsplus/bitmap.c:35

but task is already holding lock:
ffff88807c7f1c08 (&HFSPLUS_I(inode)->extents_lock){+.+.}-{3:3}, at: hfsplus_file_extend+0x1dd/0x1940 fs/hfsplus/extents.c:457

which lock already depends on the new lock.


the existing dependency chain (in reverse order) is:

-> #1 (&HFSPLUS_I(inode)->extents_lock){+.+.}-{3:3}:
       lock_acquire+0x1a7/0x400 kernel/locking/lockdep.c:5668
       __mutex_lock_common+0x1de/0x26c0 kernel/locking/mutex.c:603
       __mutex_lock kernel/locking/mutex.c:747 [inline]
       mutex_lock_nested+0x17/0x20 kernel/locking/mutex.c:799
       hfsplus_get_block+0x3a3/0x1580 fs/hfsplus/extents.c:260
       block_read_full_folio+0x39d/0xef0 fs/buffer.c:2271
       filemap_read_folio+0x1ba/0x7f0 mm/filemap.c:2426
       do_read_cache_folio+0x2d3/0x790 mm/filemap.c:3553
       do_read_cache_page mm/filemap.c:3595 [inline]
       read_cache_page+0x56/0x270 mm/filemap.c:3604
       read_mapping_page include/linux/pagemap.h:755 [inline]
       hfsplus_block_allocate+0xfc/0x910 fs/hfsplus/bitmap.c:37
       hfsplus_file_extend+0x944/0x1940 fs/hfsplus/extents.c:468
       hfsplus_get_block+0x429/0x1580 fs/hfsplus/extents.c:245
       __block_write_begin_int+0x57c/0x1ae0 fs/buffer.c:1991
       __block_write_begin fs/buffer.c:2041 [inline]
       block_write_begin+0x93/0x1e0 fs/buffer.c:2102
       hfsplus_write_begin+0x86/0xd0 fs/hfsplus/inode.c:52
       cont_expand_zero+0xc0e/0x13f0 fs/buffer.c:2416
       cont_write_begin+0xac/0x1f0 fs/buffer.c:2446
       hfsplus_write_begin+0x86/0xd0 fs/hfsplus/inode.c:52
       generic_cont_expand_simple+0x187/0x2a0 fs/buffer.c:2347
       hfsplus_setattr+0x168/0x280 fs/hfsplus/inode.c:263
       notify_change+0xe50/0x1100 fs/attr.c:482
       do_truncate+0x219/0x300 fs/open.c:65
       do_sys_ftruncate+0x2b0/0x350 fs/open.c:193
       do_syscall_x64 arch/x86/entry/common.c:50 [inline]
       do_syscall_64+0x2b/0x70 arch/x86/entry/common.c:80
       entry_SYSCALL_64_after_hwframe+0x63/0xcd

-> #0 (&sbi->alloc_mutex){+.+.}-{3:3}:
       check_prev_add kernel/locking/lockdep.c:3097 [inline]
       check_prevs_add kernel/locking/lockdep.c:3216 [inline]
       validate_chain+0x184a/0x6470 kernel/locking/lockdep.c:3831
       __lock_acquire+0x1292/0x1f60 kernel/locking/lockdep.c:5055
       lock_acquire+0x1a7/0x400 kernel/locking/lockdep.c:5668
       __mutex_lock_common+0x1de/0x26c0 kernel/locking/mutex.c:603
       __mutex_lock kernel/locking/mutex.c:747 [inline]
       mutex_lock_nested+0x17/0x20 kernel/locking/mutex.c:799
       hfsplus_block_allocate+0x96/0x910 fs/hfsplus/bitmap.c:35
       hfsplus_file_extend+0x944/0x1940 fs/hfsplus/extents.c:468
       hfsplus_get_block+0x429/0x1580 fs/hfsplus/extents.c:245
       __block_write_begin_int+0x57c/0x1ae0 fs/buffer.c:1991
       __block_write_begin fs/buffer.c:2041 [inline]
       block_write_begin+0x93/0x1e0 fs/buffer.c:2102
       hfsplus_write_begin+0x86/0xd0 fs/hfsplus/inode.c:52
       generic_perform_write+0x314/0x610 mm/filemap.c:3772
       __generic_file_write_iter+0x176/0x400 mm/filemap.c:3900
       generic_file_write_iter+0xab/0x310 mm/filemap.c:3932
       call_write_iter include/linux/fs.h:2189 [inline]
       new_sync_write fs/read_write.c:491 [inline]
       vfs_write+0x7b5/0xbb0 fs/read_write.c:584
       ksys_write+0x19b/0x2c0 fs/read_write.c:637
       do_syscall_x64 arch/x86/entry/common.c:50 [inline]
       do_syscall_64+0x2b/0x70 arch/x86/entry/common.c:80
       entry_SYSCALL_64_after_hwframe+0x63/0xcd

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

4 locks held by syz-executor.2/25306:
 #0: ffff888079ec1268 (&f->f_pos_lock){+.+.}-{3:3}, at: __fdget_pos+0x242/0x2e0 fs/file.c:1046
 #1: ffff888085af4460 (sb_writers#16){.+.+}-{0:0}, at: vfs_write+0x275/0xbb0 fs/read_write.c:580
 #2: ffff88807c7f1e00 (&sb->s_type->i_mutex_key#22){+.+.}-{3:3}, at: inode_lock include/linux/fs.h:756 [inline]
 #2: ffff88807c7f1e00 (&sb->s_type->i_mutex_key#22){+.+.}-{3:3}, at: generic_file_write_iter+0x7f/0x310 mm/filemap.c:3929
 #3: ffff88807c7f1c08 (&HFSPLUS_I(inode)->extents_lock){+.+.}-{3:3}, at: hfsplus_file_extend+0x1dd/0x1940 fs/hfsplus/extents.c:457

stack backtrace:
CPU: 0 PID: 25306 Comm: syz-executor.2 Not tainted 6.2.0-rc4-syzkaller-00067-g7287904c8771 #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/12/2023
Call Trace:
 <TASK>
 __dump_stack lib/dump_stack.c:88 [inline]
 dump_stack_lvl+0x1e3/0x2d0 lib/dump_stack.c:106
 check_noncircular+0x2f9/0x3b0 kernel/locking/lockdep.c:2177
 check_prev_add kernel/locking/lockdep.c:3097 [inline]
 check_prevs_add kernel/locking/lockdep.c:3216 [inline]
 validate_chain+0x184a/0x6470 kernel/locking/lockdep.c:3831
 __lock_acquire+0x1292/0x1f60 kernel/locking/lockdep.c:5055
 lock_acquire+0x1a7/0x400 kernel/locking/lockdep.c:5668
 __mutex_lock_common+0x1de/0x26c0 kernel/locking/mutex.c:603
 __mutex_lock kernel/locking/mutex.c:747 [inline]
 mutex_lock_nested+0x17/0x20 kernel/locking/mutex.c:799
 hfsplus_block_allocate+0x96/0x910 fs/hfsplus/bitmap.c:35
 hfsplus_file_extend+0x944/0x1940 fs/hfsplus/extents.c:468
 hfsplus_get_block+0x429/0x1580 fs/hfsplus/extents.c:245
 __block_write_begin_int+0x57c/0x1ae0 fs/buffer.c:1991
 __block_write_begin fs/buffer.c:2041 [inline]
 block_write_begin+0x93/0x1e0 fs/buffer.c:2102
 hfsplus_write_begin+0x86/0xd0 fs/hfsplus/inode.c:52
 generic_perform_write+0x314/0x610 mm/filemap.c:3772
 __generic_file_write_iter+0x176/0x400 mm/filemap.c:3900
 generic_file_write_iter+0xab/0x310 mm/filemap.c:3932
 call_write_iter include/linux/fs.h:2189 [inline]
 new_sync_write fs/read_write.c:491 [inline]
 vfs_write+0x7b5/0xbb0 fs/read_write.c:584
 ksys_write+0x19b/0x2c0 fs/read_write.c:637
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x2b/0x70 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x63/0xcd
RIP: 0033:0x7f07d648c0c9
Code: 28 00 00 00 75 05 48 83 c4 28 c3 e8 f1 19 00 00 90 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 b8 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007f07d728c168 EFLAGS: 00000246 ORIG_RAX: 0000000000000001
RAX: ffffffffffffffda RBX: 00007f07d65abf80 RCX: 00007f07d648c0c9
RDX: 00000000000ffe00 RSI: 0000000020004200 RDI: 0000000000000005
RBP: 00007f07d64e7ae9 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 00007ffe7b23ab3f R14: 00007f07d728c300 R15: 0000000000022000
 </TASK>
hfsplus: inconsistency in B*Tree (2,0,1,0,1)
hfsplus: inconsistency in B*Tree (2,0,1,0,1)

Crashes (40):
Manager Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets Title
ci-upstream-kasan-gce-smack-root 2023/01/19 10:21 upstream 7287904c8771 42660d9e .config console log report info [disk image] [vmlinux] [kernel image] possible deadlock in hfsplus_block_allocate
ci-upstream-kasan-gce-root 2023/01/14 13:30 upstream 97ec4d559d93 a63719e7 .config console log report info [disk image] [vmlinux] [kernel image] possible deadlock in hfsplus_block_allocate
ci2-upstream-fs 2023/01/12 05:04 upstream 7dd4b804e080 96166539 .config console log report info [disk image] [vmlinux] [kernel image] possible deadlock in hfsplus_block_allocate
ci-upstream-kasan-gce-smack-root 2023/01/09 15:24 upstream 1fe4fd6f5cad 1dac8c7a .config console log report info [disk image] [vmlinux] [kernel image] possible deadlock in hfsplus_block_allocate
ci2-upstream-fs 2022/12/25 17:47 upstream 72a85e2b0a1e 9da18ae8 .config console log report info [disk image] [vmlinux] [kernel image] possible deadlock in hfsplus_block_allocate
ci-upstream-kasan-gce-root 2022/12/22 14:33 upstream 9d2f6060fe4c c692fab1 .config console log report info [disk image] [vmlinux] [kernel image] possible deadlock in hfsplus_block_allocate
ci2-upstream-fs 2022/12/22 09:42 upstream b6bb9676f216 4067838e .config console log report info [disk image] [vmlinux] [kernel image] possible deadlock in hfsplus_block_allocate
ci-upstream-kasan-gce-selinux-root 2022/12/21 23:36 upstream 7a693ea78e3c 4067838e .config console log report info [disk image] [vmlinux] [kernel image] possible deadlock in hfsplus_block_allocate
ci-upstream-kasan-gce-root 2022/12/21 20:50 upstream ec34c2b4ec38 4067838e .config console log report info [disk image] [vmlinux] [kernel image] possible deadlock in hfsplus_block_allocate
ci-qemu-upstream 2022/12/21 19:37 upstream 7c0846125358 4067838e .config console log report info possible deadlock in hfsplus_block_allocate
ci-upstream-kasan-gce-root 2022/12/20 09:44 upstream 6feb57c2fd7c d3e76707 .config console log report info [disk image] [vmlinux] [kernel image] possible deadlock in hfsplus_block_allocate
ci-upstream-kasan-gce-root 2022/12/17 20:14 upstream ed56954cf5a8 05494336 .config console log report info [disk image] [vmlinux] [kernel image] possible deadlock in hfsplus_block_allocate
ci2-upstream-fs 2022/12/10 22:59 upstream 3ecc37918c80 67be1ae7 .config console log report info [disk image] [vmlinux] [kernel image] possible deadlock in hfsplus_block_allocate
ci-upstream-kasan-gce-selinux-root 2022/12/06 22:26 upstream 8ed710da2873 d88f3abb .config console log report info [disk image] [vmlinux] [kernel image] possible deadlock in hfsplus_block_allocate
ci-upstream-kasan-gce-root 2022/12/04 23:25 upstream c2bf05db6c78 e080de16 .config console log report info [disk image] [vmlinux] [kernel image] possible deadlock in hfsplus_block_allocate
ci2-upstream-fs 2022/12/04 20:06 upstream c2bf05db6c78 e080de16 .config console log report info [disk image] [vmlinux] [kernel image] possible deadlock in hfsplus_block_allocate
ci-upstream-kasan-gce-selinux-root 2022/11/29 23:20 upstream 01f856ae6d0c 05dc7993 .config console log report info [disk image] [vmlinux] [kernel image] possible deadlock in hfsplus_block_allocate
ci-upstream-kasan-gce-selinux-root 2022/11/29 16:54 upstream ca57f02295f1 05dc7993 .config console log report info [disk image] [vmlinux] [kernel image] possible deadlock in hfsplus_block_allocate
ci-qemu-upstream-386 2022/12/15 12:23 upstream 041fae9c105a 6f9c033e .config console log report info possible deadlock in hfsplus_block_allocate
ci-qemu-upstream-386 2022/12/15 08:22 upstream 041fae9c105a 6f9c033e .config console log report info possible deadlock in hfsplus_block_allocate
ci-qemu-upstream-386 2022/11/29 23:32 upstream 01f856ae6d0c 579a3740 .config console log report info possible deadlock in hfsplus_block_allocate
ci-upstream-gce-arm64 2023/01/23 13:58 git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git for-kernelci edb2f0dc90f2 9dfcf09c .config console log report info [disk image] [vmlinux] [kernel image] possible deadlock in hfsplus_block_allocate
ci-upstream-gce-arm64 2023/01/22 17:05 git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git for-kernelci edb2f0dc90f2 559a440a .config console log report info [disk image] [vmlinux] [kernel image] possible deadlock in hfsplus_block_allocate
ci-upstream-gce-arm64 2023/01/20 19:24 git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git for-kernelci de8041bf6ca8 559a440a .config console log report info [disk image] [vmlinux] [kernel image] possible deadlock in hfsplus_block_allocate
ci-upstream-gce-arm64 2023/01/19 13:01 git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git for-kernelci 9598c377d828 1b826a2f .config console log report info [disk image] [vmlinux] [kernel image] possible deadlock in hfsplus_block_allocate
ci-upstream-gce-arm64 2023/01/18 06:41 git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git for-kernelci 9598c377d828 42660d9e .config console log report info [disk image] [vmlinux] [kernel image] possible deadlock in hfsplus_block_allocate
ci-upstream-gce-arm64 2023/01/03 08:30 git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git for-kernelci a5541c0811a0 ab32d508 .config console log report info [disk image] [vmlinux] [kernel image] possible deadlock in hfsplus_block_allocate
ci-upstream-gce-arm64 2023/01/02 14:50 git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git for-kernelci a5541c0811a0 ab32d508 .config console log report info [disk image] [vmlinux] [kernel image] possible deadlock in hfsplus_block_allocate
ci-upstream-gce-arm64 2022/12/27 16:17 git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git for-kernelci a5541c0811a0 9da18ae8 .config console log report info [disk image] [vmlinux] [kernel image] possible deadlock in hfsplus_block_allocate
ci-upstream-gce-arm64 2022/12/24 20:41 git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git for-kernelci a5541c0811a0 9da18ae8 .config console log report info [disk image] [vmlinux] [kernel image] possible deadlock in hfsplus_block_allocate
ci-upstream-gce-arm64 2022/12/24 00:15 git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git for-kernelci a5541c0811a0 9da18ae8 .config console log report info [disk image] [vmlinux] [kernel image] possible deadlock in hfsplus_block_allocate
ci-upstream-gce-arm64 2022/12/14 21:59 git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git for-kernelci a5541c0811a0 b18f0a64 .config console log report info [disk image] [vmlinux] [kernel image] possible deadlock in hfsplus_block_allocate
ci-upstream-gce-arm64 2022/12/13 16:12 git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git for-kernelci a5541c0811a0 e660de91 .config console log report info [disk image] [vmlinux] [kernel image] possible deadlock in hfsplus_block_allocate
ci-upstream-gce-arm64 2022/12/12 08:36 git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git for-kernelci a5541c0811a0 67be1ae7 .config console log report info [disk image] [vmlinux] [kernel image] possible deadlock in hfsplus_block_allocate
ci-upstream-gce-arm64 2022/12/05 10:55 git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git for-kernelci e3cb714fb489 e080de16 .config console log report info [disk image] [vmlinux] [kernel image] possible deadlock in hfsplus_block_allocate
ci-upstream-gce-arm64 2022/12/03 22:39 git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git for-kernelci e3cb714fb489 e080de16 .config console log report info [disk image] [vmlinux] [kernel image] possible deadlock in hfsplus_block_allocate
ci-upstream-gce-arm64 2022/12/02 14:57 git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git for-kernelci e3cb714fb489 e080de16 .config console log report info [disk image] [vmlinux] [kernel image] possible deadlock in hfsplus_block_allocate
ci-upstream-gce-arm64 2022/12/02 11:42 git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git for-kernelci cdb931b58ff5 e080de16 .config console log report info [disk image] [vmlinux] [kernel image] possible deadlock in hfsplus_block_allocate
ci-upstream-gce-arm64 2022/11/30 01:10 git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git for-kernelci cdb931b58ff5 05dc7993 .config console log report info [disk image] [vmlinux] [kernel image] possible deadlock in hfsplus_block_allocate
ci-upstream-gce-arm64 2022/11/29 13:13 git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git for-kernelci 6d464646530f 05dc7993 .config console log report info [disk image] [vmlinux] [kernel image] possible deadlock in hfsplus_block_allocate
* Struck through repros no longer work on HEAD.