syzbot


possible deadlock in ocfs2_page_mkwrite

Status: upstream: reported on 2024/11/04 07:05
Reported-by: syzbot+0525e622cd4d8cce5b87@syzkaller.appspotmail.com
First crash: 1d07h, last: 1d07h
Similar bugs (2)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
upstream possible deadlock in ocfs2_page_mkwrite ocfs2 167 13h16m 54d 0/28 upstream: reported on 2024/09/12 09:35
linux-5.15 possible deadlock in ocfs2_page_mkwrite 2 38d 49d 0/3 upstream: reported on 2024/09/16 20:58

Sample crash report:
======================================================
WARNING: possible circular locking dependency detected
6.1.115-syzkaller #0 Not tainted
------------------------------------------------------
syz.3.398/6371 is trying to acquire lock:
ffff0000e1285be0 (&ocfs2_file_ip_alloc_sem_key){++++}-{3:3}, at: ocfs2_page_mkwrite+0x388/0xdd4 fs/ocfs2/mmap.c:142

but task is already holding lock:
ffff0000ccf22558 (sb_pagefaults#5){.+.+}-{0:0}, at: do_page_mkwrite+0x144/0x37c mm/memory.c:3009

which lock already depends on the new lock.


the existing dependency chain (in reverse order) is:

-> #2 (sb_pagefaults#5){.+.+}-{0:0}:
       percpu_down_read include/linux/percpu-rwsem.h:51 [inline]
       __sb_start_write include/linux/fs.h:1891 [inline]
       sb_start_pagefault include/linux/fs.h:1995 [inline]
       ocfs2_page_mkwrite+0x1d4/0xdd4 fs/ocfs2/mmap.c:122
       do_page_mkwrite+0x144/0x37c mm/memory.c:3009
       wp_page_shared+0x148/0x550 mm/memory.c:3358
       do_wp_page+0xcbc/0xf44 mm/memory.c:3508
       handle_pte_fault mm/memory.c:5047 [inline]
       __handle_mm_fault mm/memory.c:5171 [inline]
       handle_mm_fault+0x19a4/0x3d38 mm/memory.c:5292
       __do_page_fault arch/arm64/mm/fault.c:499 [inline]
       do_page_fault+0x330/0x890 arch/arm64/mm/fault.c:583
       do_mem_abort+0x74/0x200 arch/arm64/mm/fault.c:803
       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:580
       file_ioctl fs/ioctl.c:327 [inline]
       do_vfs_ioctl+0x2044/0x26f8 fs/ioctl.c:849
       __do_sys_ioctl fs/ioctl.c:868 [inline]
       __se_sys_ioctl fs/ioctl.c:856 [inline]
       __arm64_sys_ioctl+0xe4/0x1c8 fs/ioctl.c:856
       __invoke_syscall arch/arm64/kernel/syscall.c:38 [inline]
       invoke_syscall+0x98/0x2c0 arch/arm64/kernel/syscall.c:52
       el0_svc_common+0x138/0x258 arch/arm64/kernel/syscall.c:140
       do_el0_svc+0x64/0x218 arch/arm64/kernel/syscall.c:204
       el0_svc+0x58/0x168 arch/arm64/kernel/entry-common.c:637
       el0t_64_sync_handler+0x84/0xf0 arch/arm64/kernel/entry-common.c:655
       el0t_64_sync+0x18c/0x190 arch/arm64/kernel/entry.S:585

-> #1 (&mm->mmap_lock){++++}-{3:3}:
       __might_fault+0xc4/0x124 mm/memory.c:5851
       _copy_to_user include/linux/uaccess.h:143 [inline]
       copy_to_user include/linux/uaccess.h:169 [inline]
       fiemap_fill_next_extent+0x1b4/0x424 fs/ioctl.c:144
       ocfs2_fiemap_inline fs/ocfs2/extent_map.c:725 [inline]
       ocfs2_fiemap+0x994/0xc78 fs/ocfs2/extent_map.c:762
       ioctl_fiemap fs/ioctl.c:219 [inline]
       do_vfs_ioctl+0x194c/0x26f8 fs/ioctl.c:810
       __do_sys_ioctl fs/ioctl.c:868 [inline]
       __se_sys_ioctl fs/ioctl.c:856 [inline]
       __arm64_sys_ioctl+0xe4/0x1c8 fs/ioctl.c:856
       __invoke_syscall arch/arm64/kernel/syscall.c:38 [inline]
       invoke_syscall+0x98/0x2c0 arch/arm64/kernel/syscall.c:52
       el0_svc_common+0x138/0x258 arch/arm64/kernel/syscall.c:140
       do_el0_svc+0x64/0x218 arch/arm64/kernel/syscall.c:204
       el0_svc+0x58/0x168 arch/arm64/kernel/entry-common.c:637
       el0t_64_sync_handler+0x84/0xf0 arch/arm64/kernel/entry-common.c:655
       el0t_64_sync+0x18c/0x190 arch/arm64/kernel/entry.S:585

-> #0 (&ocfs2_file_ip_alloc_sem_key){++++}-{3:3}:
       check_prev_add kernel/locking/lockdep.c:3090 [inline]
       check_prevs_add kernel/locking/lockdep.c:3209 [inline]
       validate_chain kernel/locking/lockdep.c:3825 [inline]
       __lock_acquire+0x3338/0x7680 kernel/locking/lockdep.c:5049
       lock_acquire+0x26c/0x7cc kernel/locking/lockdep.c:5662
       down_write+0x5c/0x88 kernel/locking/rwsem.c:1573
       ocfs2_page_mkwrite+0x388/0xdd4 fs/ocfs2/mmap.c:142
       do_page_mkwrite+0x144/0x37c mm/memory.c:3009
       wp_page_shared+0x148/0x550 mm/memory.c:3358
       do_wp_page+0xcbc/0xf44 mm/memory.c:3508
       handle_pte_fault mm/memory.c:5047 [inline]
       __handle_mm_fault mm/memory.c:5171 [inline]
       handle_mm_fault+0x19a4/0x3d38 mm/memory.c:5292
       __do_page_fault arch/arm64/mm/fault.c:499 [inline]
       do_page_fault+0x330/0x890 arch/arm64/mm/fault.c:583
       do_mem_abort+0x74/0x200 arch/arm64/mm/fault.c:803
       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:580
       file_ioctl fs/ioctl.c:327 [inline]
       do_vfs_ioctl+0x2044/0x26f8 fs/ioctl.c:849
       __do_sys_ioctl fs/ioctl.c:868 [inline]
       __se_sys_ioctl fs/ioctl.c:856 [inline]
       __arm64_sys_ioctl+0xe4/0x1c8 fs/ioctl.c:856
       __invoke_syscall arch/arm64/kernel/syscall.c:38 [inline]
       invoke_syscall+0x98/0x2c0 arch/arm64/kernel/syscall.c:52
       el0_svc_common+0x138/0x258 arch/arm64/kernel/syscall.c:140
       do_el0_svc+0x64/0x218 arch/arm64/kernel/syscall.c:204
       el0_svc+0x58/0x168 arch/arm64/kernel/entry-common.c:637
       el0t_64_sync_handler+0x84/0xf0 arch/arm64/kernel/entry-common.c:655
       el0t_64_sync+0x18c/0x190 arch/arm64/kernel/entry.S:585

other info that might help us debug this:

Chain exists of:
  &ocfs2_file_ip_alloc_sem_key --> &mm->mmap_lock --> sb_pagefaults#5

 Possible unsafe locking scenario:

       CPU0                    CPU1
       ----                    ----
  lock(sb_pagefaults#5);
                               lock(&mm->mmap_lock);
                               lock(sb_pagefaults#5);
  lock(&ocfs2_file_ip_alloc_sem_key);

 *** DEADLOCK ***

2 locks held by syz.3.398/6371:
 #0: ffff0000cf6ba548 (&mm->mmap_lock){++++}-{3:3}, at: mmap_read_trylock include/linux/mmap_lock.h:136 [inline]
 #0: ffff0000cf6ba548 (&mm->mmap_lock){++++}-{3:3}, at: get_mmap_lock_carefully mm/memory.c:5320 [inline]
 #0: ffff0000cf6ba548 (&mm->mmap_lock){++++}-{3:3}, at: lock_mm_and_find_vma+0x38/0x2e8 mm/memory.c:5382
 #1: ffff0000ccf22558 (sb_pagefaults#5){.+.+}-{0:0}, at: do_page_mkwrite+0x144/0x37c mm/memory.c:3009

stack backtrace:
CPU: 0 PID: 6371 Comm: syz.3.398 Not tainted 6.1.115-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 09/13/2024
Call trace:
 dump_backtrace+0x1c8/0x1f4 arch/arm64/kernel/stacktrace.c:158
 show_stack+0x2c/0x3c arch/arm64/kernel/stacktrace.c:165
 __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:2048
 check_noncircular+0x2cc/0x378 kernel/locking/lockdep.c:2170
 check_prev_add kernel/locking/lockdep.c:3090 [inline]
 check_prevs_add kernel/locking/lockdep.c:3209 [inline]
 validate_chain kernel/locking/lockdep.c:3825 [inline]
 __lock_acquire+0x3338/0x7680 kernel/locking/lockdep.c:5049
 lock_acquire+0x26c/0x7cc kernel/locking/lockdep.c:5662
 down_write+0x5c/0x88 kernel/locking/rwsem.c:1573
 ocfs2_page_mkwrite+0x388/0xdd4 fs/ocfs2/mmap.c:142
 do_page_mkwrite+0x144/0x37c mm/memory.c:3009
 wp_page_shared+0x148/0x550 mm/memory.c:3358
 do_wp_page+0xcbc/0xf44 mm/memory.c:3508
 handle_pte_fault mm/memory.c:5047 [inline]
 __handle_mm_fault mm/memory.c:5171 [inline]
 handle_mm_fault+0x19a4/0x3d38 mm/memory.c:5292
 __do_page_fault arch/arm64/mm/fault.c:499 [inline]
 do_page_fault+0x330/0x890 arch/arm64/mm/fault.c:583
 do_mem_abort+0x74/0x200 arch/arm64/mm/fault.c:803
 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:580
 file_ioctl fs/ioctl.c:327 [inline]
 do_vfs_ioctl+0x2044/0x26f8 fs/ioctl.c:849
 __do_sys_ioctl fs/ioctl.c:868 [inline]
 __se_sys_ioctl fs/ioctl.c:856 [inline]
 __arm64_sys_ioctl+0xe4/0x1c8 fs/ioctl.c:856
 __invoke_syscall arch/arm64/kernel/syscall.c:38 [inline]
 invoke_syscall+0x98/0x2c0 arch/arm64/kernel/syscall.c:52
 el0_svc_common+0x138/0x258 arch/arm64/kernel/syscall.c:140
 do_el0_svc+0x64/0x218 arch/arm64/kernel/syscall.c:204
 el0_svc+0x58/0x168 arch/arm64/kernel/entry-common.c:637
 el0t_64_sync_handler+0x84/0xf0 arch/arm64/kernel/entry-common.c:655
 el0t_64_sync+0x18c/0x190 arch/arm64/kernel/entry.S:585

Crashes (1):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2024/11/04 07:04 linux-6.1.y 7c15117f9468 f00eed24 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan-arm64 possible deadlock in ocfs2_page_mkwrite
* Struck through repros no longer work on HEAD.