loop2: detected capacity change from 0 to 1024 ====================================================== WARNING: possible circular locking dependency detected 6.1.0-rc6-next-20221125-syzkaller #0 Not tainted ------------------------------------------------------ syz-executor.2/11465 is trying to acquire lock: ffff8880767828f8 (&sbi->alloc_mutex){+.+.}-{3:3}, at: hfsplus_block_free+0xdd/0x500 fs/hfsplus/bitmap.c:182 but task is already holding lock: ffff8880200d5208 (&HFSPLUS_I(inode)->extents_lock){+.+.}-{3:3}, at: hfsplus_file_truncate+0x205/0x10d0 fs/hfsplus/extents.c:576 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 kernel/locking/mutex.c:603 [inline] __mutex_lock+0x12f/0x1360 kernel/locking/mutex.c:747 hfsplus_get_block+0x27b/0x9b0 fs/hfsplus/extents.c:260 block_read_full_folio+0x35b/0x9d0 fs/buffer.c:2271 filemap_read_folio+0xdb/0x2c0 mm/filemap.c:2425 do_read_cache_folio+0x1df/0x510 mm/filemap.c:3552 do_read_cache_page mm/filemap.c:3594 [inline] read_cache_page+0x5d/0x160 mm/filemap.c:3603 read_mapping_page include/linux/pagemap.h:755 [inline] hfsplus_block_allocate+0x143/0x8c0 fs/hfsplus/bitmap.c:37 hfsplus_file_extend+0x43a/0xf60 fs/hfsplus/extents.c:468 hfsplus_get_block+0x1b3/0x9b0 fs/hfsplus/extents.c:245 __block_write_begin_int+0x3bd/0x14b0 fs/buffer.c:1991 __block_write_begin fs/buffer.c:2041 [inline] block_write_begin+0xb9/0x450 fs/buffer.c:2102 cont_write_begin+0x534/0x740 fs/buffer.c:2456 hfsplus_write_begin+0x87/0x150 fs/hfsplus/inode.c:52 generic_perform_write+0x256/0x570 mm/filemap.c:3771 __generic_file_write_iter+0x2ae/0x4d0 mm/filemap.c:3899 generic_file_write_iter+0xe3/0x350 mm/filemap.c:3931 call_write_iter include/linux/fs.h:2174 [inline] new_sync_write fs/read_write.c:491 [inline] vfs_write+0xa45/0xe40 fs/read_write.c:584 ksys_write+0x12b/0x250 fs/read_write.c:637 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x39/0xb0 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 kernel/locking/lockdep.c:3831 [inline] __lock_acquire+0x2a43/0x56d0 kernel/locking/lockdep.c:5055 lock_acquire kernel/locking/lockdep.c:5668 [inline] lock_acquire+0x1e3/0x630 kernel/locking/lockdep.c:5633 __mutex_lock_common kernel/locking/mutex.c:603 [inline] __mutex_lock+0x12f/0x1360 kernel/locking/mutex.c:747 hfsplus_block_free+0xdd/0x500 fs/hfsplus/bitmap.c:182 hfsplus_free_extents+0x1ff/0x4f0 fs/hfsplus/extents.c:363 hfsplus_file_truncate+0xe36/0x10d0 fs/hfsplus/extents.c:591 hfsplus_setattr+0x1f2/0x320 fs/hfsplus/inode.c:269 notify_change+0xca7/0x1420 fs/attr.c:482 do_truncate+0x143/0x200 fs/open.c:65 handle_truncate fs/namei.c:3216 [inline] do_open fs/namei.c:3561 [inline] path_openat+0x2157/0x2a50 fs/namei.c:3714 do_filp_open+0x1ba/0x410 fs/namei.c:3741 do_sys_openat2+0x16d/0x4c0 fs/open.c:1310 do_sys_open fs/open.c:1326 [inline] __do_sys_creat fs/open.c:1402 [inline] __se_sys_creat fs/open.c:1396 [inline] __x64_sys_creat+0xcd/0x120 fs/open.c:1396 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x39/0xb0 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 *** 3 locks held by syz-executor.2/11465: #0: ffff888075242460 (sb_writers#17){.+.+}-{0:0}, at: do_open fs/namei.c:3550 [inline] #0: ffff888075242460 (sb_writers#17){.+.+}-{0:0}, at: path_openat+0x19b3/0x2a50 fs/namei.c:3714 #1: ffff8880200d5400 (&sb->s_type->i_mutex_key#25){+.+.}-{3:3}, at: inode_lock include/linux/fs.h:756 [inline] #1: ffff8880200d5400 (&sb->s_type->i_mutex_key#25){+.+.}-{3:3}, at: do_truncate+0x131/0x200 fs/open.c:63 #2: ffff8880200d5208 (&HFSPLUS_I(inode)->extents_lock){+.+.}-{3:3}, at: hfsplus_file_truncate+0x205/0x10d0 fs/hfsplus/extents.c:576 stack backtrace: CPU: 1 PID: 11465 Comm: syz-executor.2 Not tainted 6.1.0-rc6-next-20221125-syzkaller #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 10/26/2022 Call Trace: __dump_stack lib/dump_stack.c:88 [inline] dump_stack_lvl+0xd1/0x138 lib/dump_stack.c:106 check_noncircular+0x25f/0x2e0 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 kernel/locking/lockdep.c:3831 [inline] __lock_acquire+0x2a43/0x56d0 kernel/locking/lockdep.c:5055 lock_acquire kernel/locking/lockdep.c:5668 [inline] lock_acquire+0x1e3/0x630 kernel/locking/lockdep.c:5633 __mutex_lock_common kernel/locking/mutex.c:603 [inline] __mutex_lock+0x12f/0x1360 kernel/locking/mutex.c:747 hfsplus_block_free+0xdd/0x500 fs/hfsplus/bitmap.c:182 hfsplus_free_extents+0x1ff/0x4f0 fs/hfsplus/extents.c:363 hfsplus_file_truncate+0xe36/0x10d0 fs/hfsplus/extents.c:591 hfsplus_setattr+0x1f2/0x320 fs/hfsplus/inode.c:269 notify_change+0xca7/0x1420 fs/attr.c:482 do_truncate+0x143/0x200 fs/open.c:65 handle_truncate fs/namei.c:3216 [inline] do_open fs/namei.c:3561 [inline] path_openat+0x2157/0x2a50 fs/namei.c:3714 do_filp_open+0x1ba/0x410 fs/namei.c:3741 do_sys_openat2+0x16d/0x4c0 fs/open.c:1310 do_sys_open fs/open.c:1326 [inline] __do_sys_creat fs/open.c:1402 [inline] __se_sys_creat fs/open.c:1396 [inline] __x64_sys_creat+0xcd/0x120 fs/open.c:1396 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x39/0xb0 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x63/0xcd RIP: 0033:0x7f318368c0d9 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:00007f318436b168 EFLAGS: 00000246 ORIG_RAX: 0000000000000055 RAX: ffffffffffffffda RBX: 00007f31837abf80 RCX: 00007f318368c0d9 RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000020000140 RBP: 00007f31836e7ae9 R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000 R13: 00007fff88e7b2bf R14: 00007f318436b300 R15: 0000000000022000