syzbot


possible deadlock in exfat_iterate

Status: upstream: reported on 2022/10/04 15:23
Reported-by: syzbot+38655f1298fefc58a904@syzkaller.appspotmail.com
First crash: 55d, last: 8d03h

Sample crash report:
======================================================
WARNING: possible circular locking dependency detected
6.1.0-rc5-syzkaller-32269-g9500fc6e9e60 #0 Not tainted
------------------------------------------------------
syz-executor.5/22383 is trying to acquire lock:
ffff0000c0e1bb08 (&mm->mmap_lock){++++}-{3:3}, at: __might_fault+0x54/0xb4 mm/memory.c:5645

but task is already holding lock:
ffff0001236580e0 (&sbi->s_lock#3){+.+.}-{3:3}, at: exfat_iterate+0x70/0xcb4 fs/exfat/dir.c:228

which lock already depends on the new lock.


the existing dependency chain (in reverse order) is:

-> #2 (&sbi->s_lock#3){+.+.}-{3:3}:
       __mutex_lock_common+0xd4/0xca8 kernel/locking/mutex.c:603
       __mutex_lock kernel/locking/mutex.c:747 [inline]
       mutex_lock_nested+0x38/0x44 kernel/locking/mutex.c:799
       exfat_get_block+0x6c/0x9ec fs/exfat/inode.c:282
       block_read_full_folio+0x188/0x8c0 fs/buffer.c:2271
       do_mpage_readpage+0x1ec/0xd38 fs/mpage.c:304
       mpage_read_folio+0x74/0xd8 fs/mpage.c:379
       exfat_read_folio+0x28/0x38 fs/exfat/inode.c:340
       filemap_read_folio+0xc4/0x468 mm/filemap.c:2407
       filemap_update_page+0x2bc/0x3b0 mm/filemap.c:2492
       filemap_get_pages+0x280/0x598 mm/filemap.c:2605
       filemap_read+0x14c/0x6f4 mm/filemap.c:2675
       generic_file_read_iter+0x6c/0x25c mm/filemap.c:2821
       call_read_iter include/linux/fs.h:2185 [inline]
       new_sync_read fs/read_write.c:389 [inline]
       vfs_read+0x2d4/0x448 fs/read_write.c:470
       ksys_read+0xb4/0x160 fs/read_write.c:613
       __do_sys_read fs/read_write.c:623 [inline]
       __se_sys_read fs/read_write.c:621 [inline]
       __arm64_sys_read+0x24/0x34 fs/read_write.c:621
       __invoke_syscall arch/arm64/kernel/syscall.c:38 [inline]
       invoke_syscall arch/arm64/kernel/syscall.c:52 [inline]
       el0_svc_common+0x138/0x220 arch/arm64/kernel/syscall.c:142
       do_el0_svc+0x48/0x164 arch/arm64/kernel/syscall.c:206
       el0_svc+0x58/0x150 arch/arm64/kernel/entry-common.c:637
       el0t_64_sync_handler+0x84/0xf0 arch/arm64/kernel/entry-common.c:655
       el0t_64_sync+0x190/0x194 arch/arm64/kernel/entry.S:584

-> #1 (mapping.invalidate_lock#6){.+.+}-{3:3}:
       down_read+0x5c/0x78 kernel/locking/rwsem.c:1509
       filemap_invalidate_lock_shared include/linux/fs.h:811 [inline]
       filemap_fault+0x104/0x7fc mm/filemap.c:3127
       __do_fault+0x60/0x358 mm/memory.c:4203
       do_read_fault mm/memory.c:4554 [inline]
       do_fault+0x338/0x550 mm/memory.c:4683
       handle_pte_fault mm/memory.c:4955 [inline]
       __handle_mm_fault mm/memory.c:5097 [inline]
       handle_mm_fault+0x78c/0xa48 mm/memory.c:5218
       __do_page_fault arch/arm64/mm/fault.c:512 [inline]
       do_page_fault+0x428/0x79c arch/arm64/mm/fault.c:612
       do_translation_fault+0x78/0x194 arch/arm64/mm/fault.c:695
       do_mem_abort+0x54/0x130 arch/arm64/mm/fault.c:831
       el1_abort+0x3c/0x5c arch/arm64/kernel/entry-common.c:367
       el1h_64_sync_handler+0x60/0xac arch/arm64/kernel/entry-common.c:427
       el1h_64_sync+0x64/0x68 arch/arm64/kernel/entry.S:579
       do_strncpy_from_user lib/strncpy_from_user.c:41 [inline]
       strncpy_from_user+0x1a8/0x3d8 lib/strncpy_from_user.c:139
       getname_flags+0x84/0x278 fs/namei.c:150
       getname+0x28/0x38 fs/namei.c:218
       do_sys_openat2+0x78/0x22c fs/open.c:1304
       do_sys_open fs/open.c:1326 [inline]
       __do_sys_openat fs/open.c:1342 [inline]
       __se_sys_openat fs/open.c:1337 [inline]
       __arm64_sys_openat+0xb0/0xe0 fs/open.c:1337
       __invoke_syscall arch/arm64/kernel/syscall.c:38 [inline]
       invoke_syscall arch/arm64/kernel/syscall.c:52 [inline]
       el0_svc_common+0x138/0x220 arch/arm64/kernel/syscall.c:142
       do_el0_svc+0x48/0x164 arch/arm64/kernel/syscall.c:206
       el0_svc+0x58/0x150 arch/arm64/kernel/entry-common.c:637
       el0t_64_sync_handler+0x84/0xf0 arch/arm64/kernel/entry-common.c:655
       el0t_64_sync+0x190/0x194 arch/arm64/kernel/entry.S:584

-> #0 (&mm->mmap_lock){++++}-{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+0x1530/0x3084 kernel/locking/lockdep.c:5055
       lock_acquire+0x100/0x1f8 kernel/locking/lockdep.c:5668
       __might_fault+0x7c/0xb4 mm/memory.c:5646
       filldir64+0x1e8/0x574 fs/readdir.c:335
       dir_emit_dot include/linux/fs.h:3561 [inline]
       dir_emit_dots include/linux/fs.h:3572 [inline]
       exfat_iterate+0xd4/0xcb4 fs/exfat/dir.c:231
       iterate_dir+0x114/0x28c
       __do_sys_getdents64 fs/readdir.c:369 [inline]
       __se_sys_getdents64 fs/readdir.c:354 [inline]
       __arm64_sys_getdents64+0x80/0x204 fs/readdir.c:354
       __invoke_syscall arch/arm64/kernel/syscall.c:38 [inline]
       invoke_syscall arch/arm64/kernel/syscall.c:52 [inline]
       el0_svc_common+0x138/0x220 arch/arm64/kernel/syscall.c:142
       do_el0_svc+0x48/0x164 arch/arm64/kernel/syscall.c:206
       el0_svc+0x58/0x150 arch/arm64/kernel/entry-common.c:637
       el0t_64_sync_handler+0x84/0xf0 arch/arm64/kernel/entry-common.c:655
       el0t_64_sync+0x190/0x194 arch/arm64/kernel/entry.S:584

other info that might help us debug this:

Chain exists of:
  &mm->mmap_lock --> mapping.invalidate_lock#6 --> &sbi->s_lock#3

 Possible unsafe locking scenario:

       CPU0                    CPU1
       ----                    ----
  lock(&sbi->s_lock#3);
                               lock(mapping.invalidate_lock#6);
                               lock(&sbi->s_lock#3);
  lock(&mm->mmap_lock);

 *** DEADLOCK ***

3 locks held by syz-executor.5/22383:
 #0: ffff00010fba9ee8 (&f->f_pos_lock){+.+.}-{3:3}, at: __fdget_pos+0x12c/0x154 fs/file.c:1037
 #1: ffff0001191a20d8 (&sb->s_type->i_mutex_key#26){++++}-{3:3}, at: iterate_dir+0xb8/0x28c fs/readdir.c:57
 #2: ffff0001236580e0 (&sbi->s_lock#3){+.+.}-{3:3}, at: exfat_iterate+0x70/0xcb4 fs/exfat/dir.c:228

stack backtrace:
CPU: 1 PID: 22383 Comm: syz-executor.5 Not tainted 6.1.0-rc5-syzkaller-32269-g9500fc6e9e60 #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 09/30/2022
Call trace:
 dump_backtrace+0x1c4/0x1f0 arch/arm64/kernel/stacktrace.c:156
 show_stack+0x2c/0x54 arch/arm64/kernel/stacktrace.c:163
 __dump_stack lib/dump_stack.c:88 [inline]
 dump_stack_lvl+0x104/0x16c lib/dump_stack.c:106
 dump_stack+0x1c/0x58 lib/dump_stack.c:113
 print_circular_bug+0x2c4/0x2c8 kernel/locking/lockdep.c:2055
 check_noncircular+0x14c/0x154 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+0x1530/0x3084 kernel/locking/lockdep.c:5055
 lock_acquire+0x100/0x1f8 kernel/locking/lockdep.c:5668
 __might_fault+0x7c/0xb4 mm/memory.c:5646
 filldir64+0x1e8/0x574 fs/readdir.c:335
 dir_emit_dot include/linux/fs.h:3561 [inline]
 dir_emit_dots include/linux/fs.h:3572 [inline]
 exfat_iterate+0xd4/0xcb4 fs/exfat/dir.c:231
 iterate_dir+0x114/0x28c
 __do_sys_getdents64 fs/readdir.c:369 [inline]
 __se_sys_getdents64 fs/readdir.c:354 [inline]
 __arm64_sys_getdents64+0x80/0x204 fs/readdir.c:354
 __invoke_syscall arch/arm64/kernel/syscall.c:38 [inline]
 invoke_syscall arch/arm64/kernel/syscall.c:52 [inline]
 el0_svc_common+0x138/0x220 arch/arm64/kernel/syscall.c:142
 do_el0_svc+0x48/0x164 arch/arm64/kernel/syscall.c:206
 el0_svc+0x58/0x150 arch/arm64/kernel/entry-common.c:637
 el0t_64_sync_handler+0x84/0xf0 arch/arm64/kernel/entry-common.c:655
 el0t_64_sync+0x190/0x194 arch/arm64/kernel/entry.S:584

Crashes (9):
Manager Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Title
ci-upstream-gce-arm64 2022/11/21 07:12 git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git for-kernelci 9500fc6e9e60 5bb70014 .config log report info possible deadlock in exfat_iterate
ci-upstream-gce-arm64 2022/11/17 16:52 git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git for-kernelci 9500fc6e9e60 3a127a31 .config log report info possible deadlock in exfat_iterate
ci-upstream-gce-arm64 2022/11/16 01:28 git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git for-kernelci 9500fc6e9e60 3a127a31 .config log report info possible deadlock in exfat_iterate
ci-upstream-gce-arm64 2022/11/15 09:42 git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git for-kernelci 9e4ce762f0e7 97de9cfc .config log report info possible deadlock in exfat_iterate
ci-upstream-gce-arm64 2022/11/14 12:42 git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git for-kernelci 1621b6eaebf7 943f4cb8 .config log report info possible deadlock in exfat_iterate
ci-upstream-gce-arm64 2022/11/03 08:05 git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git for-kernelci bbed346d5a96 7a2ebf95 .config log report info possible deadlock in exfat_iterate
ci-upstream-gce-arm64 2022/10/27 00:32 git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git for-kernelci bbed346d5a96 86777b7f .config log report info possible deadlock in exfat_iterate
ci-upstream-gce-arm64 2022/10/10 16:27 git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git for-kernelci bbed346d5a96 aea5da89 .config log report info possible deadlock in exfat_iterate
ci-upstream-gce-arm64 2022/10/04 15:06 git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git for-kernelci bbed346d5a96 eab8f949 .config log report info possible deadlock in exfat_iterate
* Struck through repros no longer work on HEAD.