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: 30d, last: 9d20h
Similar bugs (2)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
upstream possible deadlock in ocfs2_page_mkwrite ocfs2 C done 283 20h02m 83d 0/28 upstream: reported C repro on 2024/09/12 09:35
linux-5.15 possible deadlock in ocfs2_page_mkwrite 3 8h20m 78d 0/3 upstream: reported on 2024/09/16 20:58

Sample crash report:
======================================================
WARNING: possible circular locking dependency detected
6.1.119-syzkaller #0 Not tainted
------------------------------------------------------
syz.3.388/6717 is trying to acquire lock:
ffff8880687cdbe0 (&oi->ip_alloc_sem){++++}-{3:3}, at: ocfs2_page_mkwrite+0x340/0xea0 fs/ocfs2/mmap.c:142

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

which lock already depends on the new lock.


the existing dependency chain (in reverse order) is:

-> #4 (sb_pagefaults#5){.+.+}-{0:0}:
       lock_acquire+0x1f8/0x5a0 kernel/locking/lockdep.c:5662
       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+0x21e/0xea0 fs/ocfs2/mmap.c:122
       do_page_mkwrite+0x1a1/0x5f0 mm/memory.c:3009
       do_shared_fault mm/memory.c:4694 [inline]
       do_fault mm/memory.c:4762 [inline]
       handle_pte_fault mm/memory.c:5029 [inline]
       __handle_mm_fault mm/memory.c:5171 [inline]
       handle_mm_fault+0x22eb/0x5340 mm/memory.c:5292
       faultin_page mm/gup.c:1009 [inline]
       __get_user_pages+0x4f3/0x1190 mm/gup.c:1233
       __get_user_pages_locked mm/gup.c:1497 [inline]
       get_user_pages_unlocked+0x436/0x8a0 mm/gup.c:2346
       __gup_longterm_unlocked mm/gup.c:2957 [inline]
       internal_get_user_pages_fast+0x2832/0x2cf0 mm/gup.c:3047
       __iov_iter_get_pages_alloc+0x3b1/0xa70 lib/iov_iter.c:1460
       iov_iter_get_pages2+0xcb/0x120 lib/iov_iter.c:1503
       dio_refill_pages fs/direct-io.c:172 [inline]
       dio_get_page fs/direct-io.c:215 [inline]
       do_direct_IO fs/direct-io.c:932 [inline]
       __blockdev_direct_IO+0x13d6/0x4810 fs/direct-io.c:1266
       ocfs2_direct_IO+0x250/0x2c0 fs/ocfs2/aops.c:2468
       generic_file_read_iter+0x333/0x540 mm/filemap.c:2890
       ocfs2_file_read_iter+0x4b0/0xc30 fs/ocfs2/file.c:2585
       call_read_iter include/linux/fs.h:2259 [inline]
       new_sync_read fs/read_write.c:389 [inline]
       vfs_read+0x88d/0xbf0 fs/read_write.c:470
       ksys_read+0x19c/0x2c0 fs/read_write.c:613
       do_syscall_x64 arch/x86/entry/common.c:51 [inline]
       do_syscall_64+0x3b/0xb0 arch/x86/entry/common.c:81
       entry_SYSCALL_64_after_hwframe+0x68/0xd2

-> #3 (&mm->mmap_lock){++++}-{3:3}:
       lock_acquire+0x1f8/0x5a0 kernel/locking/lockdep.c:5662
       __might_fault+0xbd/0x110 mm/memory.c:5851
       _copy_to_user+0x26/0x130 lib/usercopy.c:36
       copy_to_user include/linux/uaccess.h:169 [inline]
       fiemap_fill_next_extent+0x231/0x410 fs/ioctl.c:144
       ocfs2_fiemap_inline fs/ocfs2/extent_map.c:725 [inline]
       ocfs2_fiemap+0xc1d/0xf80 fs/ocfs2/extent_map.c:762
       ioctl_fiemap fs/ioctl.c:219 [inline]
       do_vfs_ioctl+0x18e9/0x2a90 fs/ioctl.c:810
       __do_sys_ioctl fs/ioctl.c:868 [inline]
       __se_sys_ioctl+0x81/0x160 fs/ioctl.c:856
       do_syscall_x64 arch/x86/entry/common.c:51 [inline]
       do_syscall_64+0x3b/0xb0 arch/x86/entry/common.c:81
       entry_SYSCALL_64_after_hwframe+0x68/0xd2

-> #2 (&ocfs2_file_ip_alloc_sem_key){++++}-{3:3}:
       lock_acquire+0x1f8/0x5a0 kernel/locking/lockdep.c:5662
       down_read+0xad/0xa30 kernel/locking/rwsem.c:1520
       ocfs2_read_virt_blocks+0x2dc/0xab0 fs/ocfs2/extent_map.c:976
       ocfs2_read_dir_block fs/ocfs2/dir.c:508 [inline]
       ocfs2_find_entry_el fs/ocfs2/dir.c:715 [inline]
       ocfs2_find_entry+0x436/0x28c0 fs/ocfs2/dir.c:1080
       ocfs2_find_files_on_disk+0x10d/0x3a0 fs/ocfs2/dir.c:1982
       ocfs2_lookup_ino_from_name+0xad/0x1e0 fs/ocfs2/dir.c:2004
       _ocfs2_get_system_file_inode fs/ocfs2/sysfile.c:136 [inline]
       ocfs2_get_system_file_inode+0x314/0x7b0 fs/ocfs2/sysfile.c:112
       ocfs2_init_global_system_inodes+0x328/0x720 fs/ocfs2/super.c:457
       ocfs2_initialize_super fs/ocfs2/super.c:2250 [inline]
       ocfs2_fill_super+0x2f72/0x5720 fs/ocfs2/super.c:994
       mount_bdev+0x2c9/0x3f0 fs/super.c:1443
       legacy_get_tree+0xeb/0x180 fs/fs_context.c:632
       vfs_get_tree+0x88/0x270 fs/super.c:1573
       do_new_mount+0x2ba/0xb40 fs/namespace.c:3056
       do_mount fs/namespace.c:3399 [inline]
       __do_sys_mount fs/namespace.c:3607 [inline]
       __se_sys_mount+0x2d5/0x3c0 fs/namespace.c:3584
       do_syscall_x64 arch/x86/entry/common.c:51 [inline]
       do_syscall_64+0x3b/0xb0 arch/x86/entry/common.c:81
       entry_SYSCALL_64_after_hwframe+0x68/0xd2

-> #1 (&osb->system_file_mutex){+.+.}-{3:3}:
       lock_acquire+0x1f8/0x5a0 kernel/locking/lockdep.c:5662
       __mutex_lock_common kernel/locking/mutex.c:603 [inline]
       __mutex_lock+0x132/0xd80 kernel/locking/mutex.c:747
       ocfs2_get_system_file_inode+0x1a1/0x7b0 fs/ocfs2/sysfile.c:101
       ocfs2_reserve_local_alloc_bits+0xfe/0x29d0 fs/ocfs2/localalloc.c:626
       ocfs2_reserve_clusters_with_limit+0x1b4/0xb50 fs/ocfs2/suballoc.c:1162
       ocfs2_reserve_clusters fs/ocfs2/suballoc.c:1223 [inline]
       ocfs2_lock_allocators+0x306/0x620 fs/ocfs2/suballoc.c:2669
       ocfs2_write_begin_nolock+0x271a/0x4e40 fs/ocfs2/aops.c:1740
       ocfs2_write_begin+0x201/0x390 fs/ocfs2/aops.c:1904
       generic_perform_write+0x2fc/0x5e0 mm/filemap.c:3845
       __generic_file_write_iter+0x176/0x400 mm/filemap.c:3973
       ocfs2_file_write_iter+0x17c6/0x2020 fs/ocfs2/file.c:2467
       do_iter_write+0x6e6/0xc40 fs/read_write.c:861
       vfs_writev fs/read_write.c:934 [inline]
       do_pwritev+0x216/0x360 fs/read_write.c:1031
       do_syscall_x64 arch/x86/entry/common.c:51 [inline]
       do_syscall_64+0x3b/0xb0 arch/x86/entry/common.c:81
       entry_SYSCALL_64_after_hwframe+0x68/0xd2

-> #0 (&oi->ip_alloc_sem){++++}-{3:3}:
       check_prev_add kernel/locking/lockdep.c:3090 [inline]
       check_prevs_add kernel/locking/lockdep.c:3209 [inline]
       validate_chain+0x1661/0x5950 kernel/locking/lockdep.c:3825
       __lock_acquire+0x125b/0x1f80 kernel/locking/lockdep.c:5049
       lock_acquire+0x1f8/0x5a0 kernel/locking/lockdep.c:5662
       down_write+0x36/0x60 kernel/locking/rwsem.c:1573
       ocfs2_page_mkwrite+0x340/0xea0 fs/ocfs2/mmap.c:142
       do_page_mkwrite+0x1a1/0x5f0 mm/memory.c:3009
       do_shared_fault mm/memory.c:4694 [inline]
       do_fault mm/memory.c:4762 [inline]
       handle_pte_fault mm/memory.c:5029 [inline]
       __handle_mm_fault mm/memory.c:5171 [inline]
       handle_mm_fault+0x22eb/0x5340 mm/memory.c:5292
       faultin_page mm/gup.c:1009 [inline]
       __get_user_pages+0x4f3/0x1190 mm/gup.c:1233
       __get_user_pages_locked mm/gup.c:1497 [inline]
       get_user_pages_unlocked+0x436/0x8a0 mm/gup.c:2346
       __gup_longterm_unlocked mm/gup.c:2957 [inline]
       internal_get_user_pages_fast+0x2832/0x2cf0 mm/gup.c:3047
       __iov_iter_get_pages_alloc+0x3b1/0xa70 lib/iov_iter.c:1460
       iov_iter_get_pages2+0xcb/0x120 lib/iov_iter.c:1503
       dio_refill_pages fs/direct-io.c:172 [inline]
       dio_get_page fs/direct-io.c:215 [inline]
       do_direct_IO fs/direct-io.c:932 [inline]
       __blockdev_direct_IO+0x13d6/0x4810 fs/direct-io.c:1266
       ocfs2_direct_IO+0x250/0x2c0 fs/ocfs2/aops.c:2468
       generic_file_read_iter+0x333/0x540 mm/filemap.c:2890
       ocfs2_file_read_iter+0x4b0/0xc30 fs/ocfs2/file.c:2585
       call_read_iter include/linux/fs.h:2259 [inline]
       new_sync_read fs/read_write.c:389 [inline]
       vfs_read+0x88d/0xbf0 fs/read_write.c:470
       ksys_read+0x19c/0x2c0 fs/read_write.c:613
       do_syscall_x64 arch/x86/entry/common.c:51 [inline]
       do_syscall_64+0x3b/0xb0 arch/x86/entry/common.c:81
       entry_SYSCALL_64_after_hwframe+0x68/0xd2

other info that might help us debug this:

Chain exists of:
  &oi->ip_alloc_sem --> &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(&oi->ip_alloc_sem);

 *** DEADLOCK ***

3 locks held by syz.3.388/6717:
 #0: ffff88807c385c68 (&f->f_pos_lock){+.+.}-{3:3}, at: __fdget_pos+0x2ba/0x360 fs/file.c:1031
 #1: ffff888079d197d8 (&mm->mmap_lock){++++}-{3:3}, at: mmap_read_lock_killable include/linux/mmap_lock.h:126 [inline]
 #1: ffff888079d197d8 (&mm->mmap_lock){++++}-{3:3}, at: __get_user_pages_locked mm/gup.c:1488 [inline]
 #1: ffff888079d197d8 (&mm->mmap_lock){++++}-{3:3}, at: get_user_pages_unlocked+0x3d7/0x8a0 mm/gup.c:2346
 #2: ffff88807cc96558 (sb_pagefaults#5){.+.+}-{0:0}, at: do_page_mkwrite+0x1a1/0x5f0 mm/memory.c:3009

stack backtrace:
CPU: 0 PID: 6717 Comm: syz.3.388 Not tainted 6.1.119-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 09/13/2024
Call Trace:
 <TASK>
 __dump_stack lib/dump_stack.c:88 [inline]
 dump_stack_lvl+0x1e3/0x2cb lib/dump_stack.c:106
 check_noncircular+0x2fa/0x3b0 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+0x1661/0x5950 kernel/locking/lockdep.c:3825
 __lock_acquire+0x125b/0x1f80 kernel/locking/lockdep.c:5049
 lock_acquire+0x1f8/0x5a0 kernel/locking/lockdep.c:5662
 down_write+0x36/0x60 kernel/locking/rwsem.c:1573
 ocfs2_page_mkwrite+0x340/0xea0 fs/ocfs2/mmap.c:142
 do_page_mkwrite+0x1a1/0x5f0 mm/memory.c:3009
 do_shared_fault mm/memory.c:4694 [inline]
 do_fault mm/memory.c:4762 [inline]
 handle_pte_fault mm/memory.c:5029 [inline]
 __handle_mm_fault mm/memory.c:5171 [inline]
 handle_mm_fault+0x22eb/0x5340 mm/memory.c:5292
 faultin_page mm/gup.c:1009 [inline]
 __get_user_pages+0x4f3/0x1190 mm/gup.c:1233
 __get_user_pages_locked mm/gup.c:1497 [inline]
 get_user_pages_unlocked+0x436/0x8a0 mm/gup.c:2346
 __gup_longterm_unlocked mm/gup.c:2957 [inline]
 internal_get_user_pages_fast+0x2832/0x2cf0 mm/gup.c:3047
 __iov_iter_get_pages_alloc+0x3b1/0xa70 lib/iov_iter.c:1460
 iov_iter_get_pages2+0xcb/0x120 lib/iov_iter.c:1503
 dio_refill_pages fs/direct-io.c:172 [inline]
 dio_get_page fs/direct-io.c:215 [inline]
 do_direct_IO fs/direct-io.c:932 [inline]
 __blockdev_direct_IO+0x13d6/0x4810 fs/direct-io.c:1266
 ocfs2_direct_IO+0x250/0x2c0 fs/ocfs2/aops.c:2468
 generic_file_read_iter+0x333/0x540 mm/filemap.c:2890
 ocfs2_file_read_iter+0x4b0/0xc30 fs/ocfs2/file.c:2585
 call_read_iter include/linux/fs.h:2259 [inline]
 new_sync_read fs/read_write.c:389 [inline]
 vfs_read+0x88d/0xbf0 fs/read_write.c:470
 ksys_read+0x19c/0x2c0 fs/read_write.c:613
 do_syscall_x64 arch/x86/entry/common.c:51 [inline]
 do_syscall_64+0x3b/0xb0 arch/x86/entry/common.c:81
 entry_SYSCALL_64_after_hwframe+0x68/0xd2
RIP: 0033:0x7f97ced7e819
Code: ff ff c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 40 00 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 a8 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007f97cfc02038 EFLAGS: 00000246 ORIG_RAX: 0000000000000000
RAX: ffffffffffffffda RBX: 00007f97cef35fa0 RCX: 00007f97ced7e819
RDX: 0000000000002000 RSI: 0000000020000000 RDI: 0000000000000006
RBP: 00007f97cedf175e R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 0000000000000000 R14: 00007f97cef35fa0 R15: 00007fffa19a3c78
 </TASK>
syz.3.388 (6717) used greatest stack depth: 18224 bytes left

Crashes (3):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2024/11/24 22:00 linux-6.1.y e4d90d63d385 68da6d95 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan possible deadlock in ocfs2_page_mkwrite
2024/11/18 21:04 linux-6.1.y b67dc5c9ade9 e7bb5d6e .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan-arm64 possible deadlock in ocfs2_page_mkwrite
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.