syzbot


possible deadlock in filemap_fault (2)

Status: upstream: reported C repro on 2024/04/06 04:54
Bug presence: origin:upstream
[Documentation on labels]
Reported-by: syzbot+54939dc0a0cce798e592@syzkaller.appspotmail.com
First crash: 51d, last: 17d
Bug presence (1)
Date Name Commit Repro Result
2024/04/16 upstream (ToT) 96fca68c4fbf C [report] possible deadlock in filemap_fault
Similar bugs (4)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
linux-5.15 possible deadlock in filemap_fault 84 261d 436d 0/3 auto-obsoleted due to no activity on 2023/11/17 20:19
upstream possible deadlock in filemap_fault mm ntfs3 C done 1065 15h38m 570d 0/26 upstream: reported C repro on 2022/11/03 22:14
linux-6.1 possible deadlock in filemap_fault (2) 35 3d01h 156d 0/3 upstream: reported on 2023/12/22 21:26
linux-6.1 possible deadlock in filemap_fault 192 263d 438d 0/3 auto-obsoleted due to no activity on 2023/11/15 23:38

Sample crash report:
======================================================
WARNING: possible circular locking dependency detected
5.15.155-syzkaller #0 Not tainted
------------------------------------------------------
syz-executor234/4707 is trying to acquire lock:
ffff0000d5dd0b60 (mapping.invalidate_lock#3){.+.+}-{3:3}, at: filemap_invalidate_lock_shared include/linux/fs.h:844 [inline]
ffff0000d5dd0b60 (mapping.invalidate_lock#3){.+.+}-{3:3}, at: filemap_fault+0x52c/0xf5c mm/filemap.c:3081

but task is already holding lock:
ffff0000d238dd18 (&mm->mmap_lock){++++}-{3:3}, at: mmap_read_trylock include/linux/mmap_lock.h:136 [inline]
ffff0000d238dd18 (&mm->mmap_lock){++++}-{3:3}, at: do_page_fault+0x380/0xb60 arch/arm64/mm/fault.c:586

which lock already depends on the new lock.


the existing dependency chain (in reverse order) is:

-> #3 (&mm->mmap_lock){++++}-{3:3}:
       __might_fault+0xc8/0x128 mm/memory.c:5328
       filldir64+0x2bc/0x9e4 fs/readdir.c:335
       dir_emit_dot include/linux/fs.h:3678 [inline]
       hfsplus_readdir+0x398/0xf68 fs/hfsplus/dir.c:159
       iterate_dir+0x1f4/0x4e4
       __do_sys_getdents64 fs/readdir.c:369 [inline]
       __se_sys_getdents64 fs/readdir.c:354 [inline]
       __arm64_sys_getdents64+0x1c4/0x4c4 fs/readdir.c:354
       __invoke_syscall arch/arm64/kernel/syscall.c:38 [inline]
       invoke_syscall+0x98/0x2b8 arch/arm64/kernel/syscall.c:52
       el0_svc_common+0x138/0x258 arch/arm64/kernel/syscall.c:142
       do_el0_svc+0x58/0x14c arch/arm64/kernel/syscall.c:181
       el0_svc+0x7c/0x1f0 arch/arm64/kernel/entry-common.c:608
       el0t_64_sync_handler+0x84/0xe4 arch/arm64/kernel/entry-common.c:626
       el0t_64_sync+0x1a0/0x1a4 arch/arm64/kernel/entry.S:584

-> #2 (&tree->tree_lock){+.+.}-{3:3}:
       __mutex_lock_common+0x194/0x2154 kernel/locking/mutex.c:596
       __mutex_lock kernel/locking/mutex.c:729 [inline]
       mutex_lock_nested+0xa4/0xf8 kernel/locking/mutex.c:743
       hfsplus_file_truncate+0x630/0x9cc fs/hfsplus/extents.c:609
       hfsplus_write_failed+0x88/0xa4 fs/hfsplus/inode.c:42
       hfsplus_write_begin+0xf4/0xf8 fs/hfsplus/inode.c:57
       generic_perform_write+0x24c/0x520 mm/filemap.c:3785
       __generic_file_write_iter+0x230/0x454 mm/filemap.c:3912
       generic_file_write_iter+0xb4/0x1b8 mm/filemap.c:3944
       call_write_iter include/linux/fs.h:2172 [inline]
       new_sync_write fs/read_write.c:507 [inline]
       vfs_write+0x87c/0xb3c fs/read_write.c:594
       ksys_write+0x15c/0x26c fs/read_write.c:647
       __do_sys_write fs/read_write.c:659 [inline]
       __se_sys_write fs/read_write.c:656 [inline]
       __arm64_sys_write+0x7c/0x90 fs/read_write.c:656
       __invoke_syscall arch/arm64/kernel/syscall.c:38 [inline]
       invoke_syscall+0x98/0x2b8 arch/arm64/kernel/syscall.c:52
       el0_svc_common+0x138/0x258 arch/arm64/kernel/syscall.c:142
       do_el0_svc+0x58/0x14c arch/arm64/kernel/syscall.c:181
       el0_svc+0x7c/0x1f0 arch/arm64/kernel/entry-common.c:608
       el0t_64_sync_handler+0x84/0xe4 arch/arm64/kernel/entry-common.c:626
       el0t_64_sync+0x1a0/0x1a4 arch/arm64/kernel/entry.S:584

-> #1 (&hip->extents_lock){+.+.}-{3:3}:
       __mutex_lock_common+0x194/0x2154 kernel/locking/mutex.c:596
       __mutex_lock kernel/locking/mutex.c:729 [inline]
       mutex_lock_nested+0xa4/0xf8 kernel/locking/mutex.c:743
       hfsplus_get_block+0x2c4/0x1194 fs/hfsplus/extents.c:260
       block_read_full_page+0x2a0/0xc4c fs/buffer.c:2290
       hfsplus_readpage+0x28/0x38 fs/hfsplus/inode.c:28
       read_pages+0x298/0x420 mm/readahead.c:145
       page_cache_ra_unbounded+0x534/0x654 mm/readahead.c:239
       do_page_cache_ra+0x100/0x11c mm/readahead.c:269
       do_sync_mmap_readahead+0x514/0x6d4 mm/filemap.c:2996
       filemap_fault+0x5a4/0xf5c mm/filemap.c:3089
       __do_fault+0x120/0x5d0 mm/memory.c:3898
       do_shared_fault mm/memory.c:4288 [inline]
       do_fault mm/memory.c:4366 [inline]
       handle_pte_fault mm/memory.c:4621 [inline]
       __handle_mm_fault mm/memory.c:4756 [inline]
       handle_mm_fault+0x19a8/0x3424 mm/memory.c:4854
       __do_page_fault arch/arm64/mm/fault.c:505 [inline]
       do_page_fault+0x700/0xb60 arch/arm64/mm/fault.c:605
       do_translation_fault+0xe8/0x138 arch/arm64/mm/fault.c:686
       do_mem_abort+0x70/0x1d8 arch/arm64/mm/fault.c:819
       el1_abort+0x3c/0x5c arch/arm64/kernel/entry-common.c:358
       el1h_64_sync_handler+0x60/0xac arch/arm64/kernel/entry-common.c:418
       el1h_64_sync+0x78/0x7c arch/arm64/kernel/entry.S:579
       __arch_copy_to_user+0xbc/0x218 arch/arm64/lib/copy_template.S:111
       __do_sys_fcntl fs/fcntl.c:472 [inline]
       __se_sys_fcntl fs/fcntl.c:457 [inline]
       __arm64_sys_fcntl+0x110/0x1f8 fs/fcntl.c:457
       __invoke_syscall arch/arm64/kernel/syscall.c:38 [inline]
       invoke_syscall+0x98/0x2b8 arch/arm64/kernel/syscall.c:52
       el0_svc_common+0x138/0x258 arch/arm64/kernel/syscall.c:142
       do_el0_svc+0x58/0x14c arch/arm64/kernel/syscall.c:181
       el0_svc+0x7c/0x1f0 arch/arm64/kernel/entry-common.c:608
       el0t_64_sync_handler+0x84/0xe4 arch/arm64/kernel/entry-common.c:626
       el0t_64_sync+0x1a0/0x1a4 arch/arm64/kernel/entry.S:584

-> #0 (mapping.invalidate_lock#3){.+.+}-{3:3}:
       check_prev_add kernel/locking/lockdep.c:3053 [inline]
       check_prevs_add kernel/locking/lockdep.c:3172 [inline]
       validate_chain kernel/locking/lockdep.c:3788 [inline]
       __lock_acquire+0x32d4/0x7638 kernel/locking/lockdep.c:5012
       lock_acquire+0x240/0x77c kernel/locking/lockdep.c:5623
       down_read+0xc0/0x398 kernel/locking/rwsem.c:1498
       filemap_invalidate_lock_shared include/linux/fs.h:844 [inline]
       filemap_fault+0x52c/0xf5c mm/filemap.c:3081
       __do_fault+0x120/0x5d0 mm/memory.c:3898
       do_shared_fault mm/memory.c:4288 [inline]
       do_fault mm/memory.c:4366 [inline]
       handle_pte_fault mm/memory.c:4621 [inline]
       __handle_mm_fault mm/memory.c:4756 [inline]
       handle_mm_fault+0x19a8/0x3424 mm/memory.c:4854
       __do_page_fault arch/arm64/mm/fault.c:505 [inline]
       do_page_fault+0x700/0xb60 arch/arm64/mm/fault.c:605
       do_translation_fault+0xe8/0x138 arch/arm64/mm/fault.c:686
       do_mem_abort+0x70/0x1d8 arch/arm64/mm/fault.c:819
       el0_da+0x94/0x20c arch/arm64/kernel/entry-common.c:494
       el0t_64_sync_handler+0xc0/0xe4 arch/arm64/kernel/entry-common.c:629
       el0t_64_sync+0x1a0/0x1a4 arch/arm64/kernel/entry.S:584

other info that might help us debug this:

Chain exists of:
  mapping.invalidate_lock#3 --> &tree->tree_lock --> &mm->mmap_lock

 Possible unsafe locking scenario:

       CPU0                    CPU1
       ----                    ----
  lock(&mm->mmap_lock);
                               lock(&tree->tree_lock);
                               lock(&mm->mmap_lock);
  lock(mapping.invalidate_lock#3);

 *** DEADLOCK ***

1 lock held by syz-executor234/4707:
 #0: ffff0000d238dd18 (&mm->mmap_lock){++++}-{3:3}, at: mmap_read_trylock include/linux/mmap_lock.h:136 [inline]
 #0: ffff0000d238dd18 (&mm->mmap_lock){++++}-{3:3}, at: do_page_fault+0x380/0xb60 arch/arm64/mm/fault.c:586

stack backtrace:
CPU: 0 PID: 4707 Comm: syz-executor234 Not tainted 5.15.155-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 03/27/2024
Call trace:
 dump_backtrace+0x0/0x530 arch/arm64/kernel/stacktrace.c:152
 show_stack+0x2c/0x3c arch/arm64/kernel/stacktrace.c:216
 __dump_stack lib/dump_stack.c:88 [inline]
 dump_stack_lvl+0x108/0x170 lib/dump_stack.c:106
 dump_stack+0x1c/0x58 lib/dump_stack.c:113
 print_circular_bug+0x150/0x1b8 kernel/locking/lockdep.c:2011
 check_noncircular+0x2cc/0x378 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 kernel/locking/lockdep.c:3788 [inline]
 __lock_acquire+0x32d4/0x7638 kernel/locking/lockdep.c:5012
 lock_acquire+0x240/0x77c kernel/locking/lockdep.c:5623
 down_read+0xc0/0x398 kernel/locking/rwsem.c:1498
 filemap_invalidate_lock_shared include/linux/fs.h:844 [inline]
 filemap_fault+0x52c/0xf5c mm/filemap.c:3081
 __do_fault+0x120/0x5d0 mm/memory.c:3898
 do_shared_fault mm/memory.c:4288 [inline]
 do_fault mm/memory.c:4366 [inline]
 handle_pte_fault mm/memory.c:4621 [inline]
 __handle_mm_fault mm/memory.c:4756 [inline]
 handle_mm_fault+0x19a8/0x3424 mm/memory.c:4854
 __do_page_fault arch/arm64/mm/fault.c:505 [inline]
 do_page_fault+0x700/0xb60 arch/arm64/mm/fault.c:605
 do_translation_fault+0xe8/0x138 arch/arm64/mm/fault.c:686
 do_mem_abort+0x70/0x1d8 arch/arm64/mm/fault.c:819
 el0_da+0x94/0x20c arch/arm64/kernel/entry-common.c:494
 el0t_64_sync_handler+0xc0/0xe4 arch/arm64/kernel/entry-common.c:629
 el0t_64_sync+0x1a0/0x1a4 arch/arm64/kernel/entry.S:584

Crashes (15):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2024/04/16 10:31 linux-5.15.y fa3df276cd36 0d592ce4 .config console log report syz C [disk image] [vmlinux] [kernel image] [mounted in repro] ci2-linux-5-15-kasan-arm64 possible deadlock in filemap_fault
2024/05/10 03:33 linux-5.15.y 284087d4f7d5 de979bc2 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan possible deadlock in filemap_fault
2024/05/08 18:49 linux-5.15.y 284087d4f7d5 20bf80e1 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan possible deadlock in filemap_fault
2024/05/08 18:49 linux-5.15.y 284087d4f7d5 20bf80e1 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan possible deadlock in filemap_fault
2024/05/01 02:24 linux-5.15.y b925f60c6ee7 3ba885bc .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan possible deadlock in filemap_fault
2024/04/29 22:57 linux-5.15.y b925f60c6ee7 f10afd69 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan possible deadlock in filemap_fault
2024/04/16 04:55 linux-5.15.y fa3df276cd36 0d592ce4 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan possible deadlock in filemap_fault
2024/04/15 15:16 linux-5.15.y fa3df276cd36 b9af7e61 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan possible deadlock in filemap_fault
2024/04/12 05:02 linux-5.15.y cdfd0a7f0139 27de0a5c .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan possible deadlock in filemap_fault
2024/05/08 02:11 linux-5.15.y 284087d4f7d5 4cf3f9b3 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan-arm64 possible deadlock in filemap_fault
2024/04/26 14:27 linux-5.15.y c52b9710c83d 059e9963 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan-arm64 possible deadlock in filemap_fault
2024/04/16 05:04 linux-5.15.y fa3df276cd36 0d592ce4 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan-arm64 possible deadlock in filemap_fault
2024/04/11 05:17 linux-5.15.y cdfd0a7f0139 33b9e058 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan-arm64 possible deadlock in filemap_fault
2024/04/09 22:34 linux-5.15.y 9465fef4ae35 171ec371 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan-arm64 possible deadlock in filemap_fault
2024/04/06 04:53 linux-5.15.y 9465fef4ae35 ca620dd8 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan-arm64 possible deadlock in filemap_fault
* Struck through repros no longer work on HEAD.