====================================================== WARNING: possible circular locking dependency detected 6.3.0-rc3-next-20230324-syzkaller #0 Not tainted ------------------------------------------------------ syz-executor.4/28256 is trying to acquire lock: ffff88807d8cd4d8 (&mm->mmap_lock){++++}-{3:3}, at: mmap_read_lock include/linux/mmap_lock.h:142 [inline] ffff88807d8cd4d8 (&mm->mmap_lock){++++}-{3:3}, at: do_user_addr_fault+0xb60/0x1240 arch/x86/mm/fault.c:1413 but task is already holding lock: ffff88807c7d40e0 (&sbi->s_lock#2){+.+.}-{3:3}, at: exfat_iterate+0x111/0xb40 fs/exfat/dir.c:232 which lock already depends on the new lock. the existing dependency chain (in reverse order) is: -> #2 (&sbi->s_lock#2){+.+.}-{3:3}: __mutex_lock_common kernel/locking/mutex.c:603 [inline] __mutex_lock+0x12f/0x1350 kernel/locking/mutex.c:747 exfat_get_block+0x18d/0x16e0 fs/exfat/inode.c:280 do_mpage_readpage+0x768/0x1960 fs/mpage.c:208 mpage_readahead+0x344/0x580 fs/mpage.c:356 read_pages+0x1a2/0xd40 mm/readahead.c:161 page_cache_ra_unbounded+0x477/0x5e0 mm/readahead.c:270 do_page_cache_ra mm/readahead.c:300 [inline] page_cache_ra_order+0x6ec/0xa00 mm/readahead.c:560 ondemand_readahead+0x6b3/0x1080 mm/readahead.c:682 page_cache_sync_ra+0x1c9/0x200 mm/readahead.c:709 page_cache_sync_readahead include/linux/pagemap.h:1209 [inline] filemap_get_pages+0x28d/0x1620 mm/filemap.c:2595 filemap_splice_read+0x2eb/0x890 mm/filemap.c:2906 generic_file_splice_read+0x131/0x1b0 fs/splice.c:399 vfs_splice_read+0x1bd/0x250 fs/splice.c:879 splice_direct_to_actor+0x2ab/0x8a0 fs/splice.c:951 do_splice_direct+0x1ab/0x280 fs/splice.c:1060 do_sendfile+0xb19/0x12c0 fs/read_write.c:1255 __do_sys_sendfile64 fs/read_write.c:1323 [inline] __se_sys_sendfile64 fs/read_write.c:1309 [inline] __x64_sys_sendfile64+0x1d0/0x210 fs/read_write.c:1309 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 -> #1 (mapping.invalidate_lock#5){.+.+}-{3:3}: down_read+0x3d/0x50 kernel/locking/rwsem.c:1520 filemap_invalidate_lock_shared include/linux/fs.h:816 [inline] filemap_fault+0xb94/0x2460 mm/filemap.c:3269 __do_fault+0x107/0x600 mm/memory.c:4163 do_read_fault mm/memory.c:4512 [inline] do_fault mm/memory.c:4641 [inline] do_pte_missing mm/memory.c:3634 [inline] handle_pte_fault mm/memory.c:4929 [inline] __handle_mm_fault+0x278b/0x4030 mm/memory.c:5071 handle_mm_fault+0x2c0/0x9c0 mm/memory.c:5217 do_user_addr_fault+0x53d/0x1240 arch/x86/mm/fault.c:1462 handle_page_fault arch/x86/mm/fault.c:1556 [inline] exc_page_fault+0x98/0x170 arch/x86/mm/fault.c:1612 asm_exc_page_fault+0x26/0x30 arch/x86/include/asm/idtentry.h:570 do_strncpy_from_user lib/strncpy_from_user.c:41 [inline] strncpy_from_user+0x1c1/0x3d0 lib/strncpy_from_user.c:139 getname_flags.part.0+0x95/0x4f0 fs/namei.c:151 getname_flags include/linux/audit.h:321 [inline] getname+0x92/0xd0 fs/namei.c:219 do_sys_openat2+0xf5/0x4c0 fs/open.c:1350 do_sys_open fs/open.c:1372 [inline] __do_sys_creat fs/open.c:1448 [inline] __se_sys_creat fs/open.c:1442 [inline] __x64_sys_creat+0xcd/0x120 fs/open.c:1442 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 (&mm->mmap_lock){++++}-{3:3}: check_prev_add kernel/locking/lockdep.c:3108 [inline] check_prevs_add kernel/locking/lockdep.c:3227 [inline] validate_chain kernel/locking/lockdep.c:3842 [inline] __lock_acquire+0x2f21/0x5df0 kernel/locking/lockdep.c:5074 lock_acquire.part.0+0x11c/0x370 kernel/locking/lockdep.c:5691 down_read+0x3d/0x50 kernel/locking/rwsem.c:1520 mmap_read_lock include/linux/mmap_lock.h:142 [inline] do_user_addr_fault+0xb60/0x1240 arch/x86/mm/fault.c:1413 handle_page_fault arch/x86/mm/fault.c:1556 [inline] exc_page_fault+0x98/0x170 arch/x86/mm/fault.c:1612 asm_exc_page_fault+0x26/0x30 arch/x86/include/asm/idtentry.h:570 filldir+0x1ef/0x680 fs/readdir.c:253 dir_emit_dot include/linux/fs.h:3147 [inline] dir_emit_dots include/linux/fs.h:3158 [inline] exfat_iterate+0x56b/0xb40 fs/exfat/dir.c:235 iterate_dir+0x1fd/0x6f0 fs/readdir.c:67 __do_sys_getdents fs/readdir.c:286 [inline] __se_sys_getdents fs/readdir.c:271 [inline] __x64_sys_getdents+0x13e/0x2c0 fs/readdir.c:271 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: Chain exists of: &mm->mmap_lock --> mapping.invalidate_lock#5 --> &sbi->s_lock#2 Possible unsafe locking scenario: CPU0 CPU1 ---- ---- lock(&sbi->s_lock#2); lock(mapping.invalidate_lock#5); lock(&sbi->s_lock#2); rlock(&mm->mmap_lock); *** DEADLOCK *** 3 locks held by syz-executor.4/28256: #0: ffff88807b6b1c68 (&f->f_pos_lock){+.+.}-{3:3}, at: __fdget_pos+0xe7/0x100 fs/file.c:1047 #1: ffff8880344cf7b0 (&sb->s_type->i_mutex_key#26){++++}-{3:3}, at: iterate_dir+0x504/0x6f0 fs/readdir.c:57 #2: ffff88807c7d40e0 (&sbi->s_lock#2){+.+.}-{3:3}, at: exfat_iterate+0x111/0xb40 fs/exfat/dir.c:232 stack backtrace: CPU: 0 PID: 28256 Comm: syz-executor.4 Not tainted 6.3.0-rc3-next-20230324-syzkaller #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 03/02/2023 Call Trace: __dump_stack lib/dump_stack.c:88 [inline] dump_stack_lvl+0xd9/0x150 lib/dump_stack.c:106 check_noncircular+0x25f/0x2e0 kernel/locking/lockdep.c:2188 check_prev_add kernel/locking/lockdep.c:3108 [inline] check_prevs_add kernel/locking/lockdep.c:3227 [inline] validate_chain kernel/locking/lockdep.c:3842 [inline] __lock_acquire+0x2f21/0x5df0 kernel/locking/lockdep.c:5074 lock_acquire.part.0+0x11c/0x370 kernel/locking/lockdep.c:5691 down_read+0x3d/0x50 kernel/locking/rwsem.c:1520 mmap_read_lock include/linux/mmap_lock.h:142 [inline] do_user_addr_fault+0xb60/0x1240 arch/x86/mm/fault.c:1413 handle_page_fault arch/x86/mm/fault.c:1556 [inline] exc_page_fault+0x98/0x170 arch/x86/mm/fault.c:1612 asm_exc_page_fault+0x26/0x30 arch/x86/include/asm/idtentry.h:570 RIP: 0010:filldir+0x1ef/0x680 fs/readdir.c:253 Code: 48 89 c6 48 89 44 24 10 e8 8e 14 99 ff 48 8b 44 24 10 49 39 c6 0f 87 40 02 00 00 e8 bb 18 99 ff 0f 01 cb 0f ae e8 48 8b 04 24 <49> 89 46 08 e8 a8 18 99 ff 48 8b 44 24 18 49 89 07 e8 9b 18 99 ff RSP: 0018:ffffc90003707c08 EFLAGS: 00050216 RAX: 0000000000000000 RBX: ffffc90003707e98 RCX: ffffc9001528f000 RDX: 0000000000040000 RSI: ffffffff81e9bda5 RDI: 0000000000000006 RBP: 0000000000000001 R08: 0000000000000006 R09: 0000000020001fc0 R10: 00007fffffffefe8 R11: 0000000000000000 R12: 0000000000000018 R13: ffffffff8a660740 R14: 0000000020001fc0 R15: 0000000020001fc0 dir_emit_dot include/linux/fs.h:3147 [inline] dir_emit_dots include/linux/fs.h:3158 [inline] exfat_iterate+0x56b/0xb40 fs/exfat/dir.c:235 iterate_dir+0x1fd/0x6f0 fs/readdir.c:67 __do_sys_getdents fs/readdir.c:286 [inline] __se_sys_getdents fs/readdir.c:271 [inline] __x64_sys_getdents+0x13e/0x2c0 fs/readdir.c:271 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:0x7f71ff48c0f9 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:00007f72001e8168 EFLAGS: 00000246 ORIG_RAX: 000000000000004e RAX: ffffffffffffffda RBX: 00007f71ff5abf80 RCX: 00007f71ff48c0f9 RDX: 00000000000000b8 RSI: 0000000020001fc0 RDI: 0000000000000006 RBP: 00007f71ff4e7b39 R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000 R13: 00007ffdc9b7799f R14: 00007f72001e8300 R15: 0000000000022000 exFAT-fs (loop4): error, invalid access to FAT (entry 0x00000005) bogus content (0x6a46548d) exFAT-fs (loop4): Filesystem has been set read-only ---------------- Code disassembly (best guess): 0: 48 89 c6 mov %rax,%rsi 3: 48 89 44 24 10 mov %rax,0x10(%rsp) 8: e8 8e 14 99 ff callq 0xff99149b d: 48 8b 44 24 10 mov 0x10(%rsp),%rax 12: 49 39 c6 cmp %rax,%r14 15: 0f 87 40 02 00 00 ja 0x25b 1b: e8 bb 18 99 ff callq 0xff9918db 20: 0f 01 cb stac 23: 0f ae e8 lfence 26: 48 8b 04 24 mov (%rsp),%rax * 2a: 49 89 46 08 mov %rax,0x8(%r14) <-- trapping instruction 2e: e8 a8 18 99 ff callq 0xff9918db 33: 48 8b 44 24 18 mov 0x18(%rsp),%rax 38: 49 89 07 mov %rax,(%r15) 3b: e8 9b 18 99 ff callq 0xff9918db