====================================================== WARNING: possible circular locking dependency detected 5.15.157-syzkaller #0 Not tainted ------------------------------------------------------ syz-executor.4/4948 is trying to acquire lock: ffff8880244c6328 (&mm->mmap_lock){++++}-{3:3}, at: mmap_read_lock+0x1c/0x50 include/linux/mmap_lock.h:117 but task is already holding lock: ffff88807dc920b0 (&tree->tree_lock){+.+.}-{3:3}, at: hfsplus_find_init+0x146/0x1c0 which lock already depends on the new lock. the existing dependency chain (in reverse order) is: -> #3 (&tree->tree_lock){+.+.}-{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_file_truncate+0x78f/0xb80 fs/hfsplus/extents.c:609 hfsplus_file_release+0xf3/0x3e0 fs/hfsplus/inode.c:236 __fput+0x3bf/0x890 fs/file_table.c:280 task_work_run+0x129/0x1a0 kernel/task_work.c:164 exit_task_work include/linux/task_work.h:32 [inline] do_exit+0x6a3/0x2480 kernel/exit.c:872 do_group_exit+0x144/0x310 kernel/exit.c:994 get_signal+0xc66/0x14e0 kernel/signal.c:2889 arch_do_signal_or_restart+0xc3/0x1890 arch/x86/kernel/signal.c:867 handle_signal_work kernel/entry/common.c:154 [inline] exit_to_user_mode_loop+0x97/0x130 kernel/entry/common.c:178 exit_to_user_mode_prepare+0xb1/0x140 kernel/entry/common.c:214 __syscall_exit_to_user_mode_work kernel/entry/common.c:296 [inline] syscall_exit_to_user_mode+0x5d/0x240 kernel/entry/common.c:307 do_syscall_64+0x47/0xb0 arch/x86/entry/common.c:86 entry_SYSCALL_64_after_hwframe+0x66/0xd0 -> #2 (&hip->extents_lock){+.+.}-{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_get_block+0x37f/0x14e0 fs/hfsplus/extents.c:260 block_read_full_page+0x2f9/0xde0 fs/buffer.c:2290 read_pages+0x605/0x8e0 mm/readahead.c:145 page_cache_ra_unbounded+0x7b0/0x930 mm/readahead.c:239 do_sync_mmap_readahead+0x610/0x800 mm/filemap.c:2996 filemap_fault+0x77a/0x1470 mm/filemap.c:3089 __do_fault+0x139/0x340 mm/memory.c:3898 do_read_fault mm/memory.c:4234 [inline] do_fault mm/memory.c:4362 [inline] handle_pte_fault mm/memory.c:4621 [inline] __handle_mm_fault mm/memory.c:4756 [inline] handle_mm_fault+0x376f/0x5950 mm/memory.c:4854 faultin_page mm/gup.c:976 [inline] __get_user_pages+0x4ed/0x11d0 mm/gup.c:1197 __get_user_pages_locked mm/gup.c:1382 [inline] get_user_pages_unlocked+0x23b/0x8a0 mm/gup.c:2222 __gup_longterm_unlocked mm/gup.c:2823 [inline] internal_get_user_pages_fast+0x2306/0x2820 mm/gup.c:2911 iov_iter_get_pages+0x25a/0x570 lib/iov_iter.c:1544 dio_refill_pages fs/direct-io.c:173 [inline] dio_get_page fs/direct-io.c:217 [inline] do_direct_IO fs/direct-io.c:938 [inline] do_blockdev_direct_IO fs/direct-io.c:1276 [inline] __blockdev_direct_IO+0x1419/0x4f40 fs/direct-io.c:1368 blockdev_direct_IO include/linux/fs.h:3303 [inline] hfsplus_direct_IO+0xf6/0x1e0 fs/hfsplus/inode.c:135 generic_file_direct_write+0x204/0x460 mm/filemap.c:3687 __generic_file_write_iter+0x2a2/0x4f0 mm/filemap.c:3869 generic_file_write_iter+0xa7/0x1b0 mm/filemap.c:3944 call_write_iter include/linux/fs.h:2172 [inline] new_sync_write fs/read_write.c:507 [inline] vfs_write+0xacf/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 -> #1 (mapping.invalidate_lock#4){.+.+}-{3:3}: lock_acquire+0x1db/0x4f0 kernel/locking/lockdep.c:5623 down_read+0x45/0x2e0 kernel/locking/rwsem.c:1498 filemap_invalidate_lock_shared include/linux/fs.h:844 [inline] filemap_fault+0x708/0x1470 mm/filemap.c:3081 __do_fault+0x139/0x340 mm/memory.c:3898 do_read_fault mm/memory.c:4234 [inline] do_fault mm/memory.c:4362 [inline] handle_pte_fault mm/memory.c:4621 [inline] __handle_mm_fault mm/memory.c:4756 [inline] handle_mm_fault+0x376f/0x5950 mm/memory.c:4854 faultin_page mm/gup.c:976 [inline] __get_user_pages+0x4ed/0x11d0 mm/gup.c:1197 __get_user_pages_locked mm/gup.c:1382 [inline] get_user_pages_unlocked+0x568/0x8a0 mm/gup.c:2222 __gup_longterm_unlocked mm/gup.c:2823 [inline] internal_get_user_pages_fast+0x2306/0x2820 mm/gup.c:2911 iov_iter_get_pages+0x25a/0x570 lib/iov_iter.c:1544 dio_refill_pages fs/direct-io.c:173 [inline] dio_get_page fs/direct-io.c:217 [inline] do_direct_IO fs/direct-io.c:938 [inline] do_blockdev_direct_IO fs/direct-io.c:1276 [inline] __blockdev_direct_IO+0x1419/0x4f40 fs/direct-io.c:1368 blockdev_direct_IO include/linux/fs.h:3303 [inline] hfsplus_direct_IO+0xf6/0x1e0 fs/hfsplus/inode.c:135 generic_file_direct_write+0x204/0x460 mm/filemap.c:3687 __generic_file_write_iter+0x2a2/0x4f0 mm/filemap.c:3869 generic_file_write_iter+0xa7/0x1b0 mm/filemap.c:3944 call_write_iter include/linux/fs.h:2172 [inline] new_sync_write fs/read_write.c:507 [inline] vfs_write+0xacf/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 (&mm->mmap_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 down_read+0x45/0x2e0 kernel/locking/rwsem.c:1498 mmap_read_lock+0x1c/0x50 include/linux/mmap_lock.h:117 do_user_addr_fault arch/x86/mm/fault.c:1339 [inline] handle_page_fault arch/x86/mm/fault.c:1476 [inline] exc_page_fault+0x5ce/0x740 arch/x86/mm/fault.c:1532 asm_exc_page_fault+0x22/0x30 arch/x86/include/asm/idtentry.h:568 filldir64+0x34f/0x730 dir_emit include/linux/fs.h:3674 [inline] hfsplus_readdir+0xc41/0x12f0 fs/hfsplus/dir.c:221 iterate_dir+0x224/0x570 __do_sys_getdents64 fs/readdir.c:369 [inline] __se_sys_getdents64+0x209/0x4f0 fs/readdir.c:354 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: Chain exists of: &mm->mmap_lock --> &hip->extents_lock --> &tree->tree_lock Possible unsafe locking scenario: CPU0 CPU1 ---- ---- lock(&tree->tree_lock); lock(&hip->extents_lock); lock(&tree->tree_lock); lock(&mm->mmap_lock); *** DEADLOCK *** 3 locks held by syz-executor.4/4948: #0: ffff888058c3eff0 (&f->f_pos_lock){+.+.}-{3:3}, at: __fdget_pos+0x2cb/0x380 fs/file.c:1088 #1: ffff88805c531740 (&type->i_mutex_dir_key#8){++++}-{3:3}, at: iterate_dir+0x10a/0x570 fs/readdir.c:55 #2: ffff88807dc920b0 (&tree->tree_lock){+.+.}-{3:3}, at: hfsplus_find_init+0x146/0x1c0 stack backtrace: CPU: 1 PID: 4948 Comm: syz-executor.4 Not tainted 5.15.157-syzkaller #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 03/27/2024 Call Trace: __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 down_read+0x45/0x2e0 kernel/locking/rwsem.c:1498 mmap_read_lock+0x1c/0x50 include/linux/mmap_lock.h:117 do_user_addr_fault arch/x86/mm/fault.c:1339 [inline] handle_page_fault arch/x86/mm/fault.c:1476 [inline] exc_page_fault+0x5ce/0x740 arch/x86/mm/fault.c:1532 asm_exc_page_fault+0x22/0x30 arch/x86/include/asm/idtentry.h:568 RIP: 0010:filldir64+0x34f/0x730 fs/readdir.c:339 Code: 60 48 8b 4c 24 18 48 89 41 08 48 8b 44 24 10 48 8b 4c 24 58 48 89 08 48 8b 4c 24 20 66 89 48 10 8b 4c 24 34 88 48 12 49 63 ee 44 28 13 00 4c 8d 78 13 bf 07 00 00 00 44 89 f6 e8 cb 7b a5 ff RSP: 0018:ffffc90002f778a0 EFLAGS: 00050283 RAX: 0000000020000fe0 RBX: 0000000020001010 RCX: 0000000000000004 RDX: 0000000000000000 RSI: 0000000020001010 RDI: 00007ffffffff000 RBP: 0000000000000015 R08: ffffffff81dae40f R09: ffffed100ec293b9 R10: 0000000000000000 R11: dffffc0000000001 R12: ffff88801d48f000 R13: ffffc90002f77e70 R14: 0000000000000015 R15: 0000000020000fc0 dir_emit include/linux/fs.h:3674 [inline] hfsplus_readdir+0xc41/0x12f0 fs/hfsplus/dir.c:221 iterate_dir+0x224/0x570 __do_sys_getdents64 fs/readdir.c:369 [inline] __se_sys_getdents64+0x209/0x4f0 fs/readdir.c:354 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:0x7fa90af8cea9 Code: 28 00 00 00 75 05 48 83 c4 28 c3 e8 e1 20 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 b0 ff ff ff f7 d8 64 89 01 48 RSP: 002b:00007fa9094de0c8 EFLAGS: 00000246 ORIG_RAX: 00000000000000d9 RAX: ffffffffffffffda RBX: 00007fa90b0bb050 RCX: 00007fa90af8cea9 RDX: 0000000000001000 RSI: 0000000020000f80 RDI: 0000000000000005 RBP: 00007fa90afd94a4 R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000 R13: 000000000000000b R14: 00007fa90b0bb050 R15: 00007ffed1909b08 ---------------- Code disassembly (best guess), 1 bytes skipped: 0: 48 8b 4c 24 18 mov 0x18(%rsp),%rcx 5: 48 89 41 08 mov %rax,0x8(%rcx) 9: 48 8b 44 24 10 mov 0x10(%rsp),%rax e: 48 8b 4c 24 58 mov 0x58(%rsp),%rcx 13: 48 89 08 mov %rcx,(%rax) 16: 48 8b 4c 24 20 mov 0x20(%rsp),%rcx 1b: 66 89 48 10 mov %cx,0x10(%rax) 1f: 8b 4c 24 34 mov 0x34(%rsp),%ecx 23: 88 48 12 mov %cl,0x12(%rax) 26: 49 63 ee movslq %r14d,%rbp * 29: c6 44 28 13 00 movb $0x0,0x13(%rax,%rbp,1) <-- trapping instruction 2e: 4c 8d 78 13 lea 0x13(%rax),%r15 32: bf 07 00 00 00 mov $0x7,%edi 37: 44 89 f6 mov %r14d,%esi 3a: e8 cb 7b a5 ff call 0xffa57c0a