syzbot


possible deadlock in ocfs2_fiemap

Status: upstream: reported on 2024/10/11 18:44
Reported-by: syzbot+d66730458cf34fe77585@syzkaller.appspotmail.com
First crash: 275d, last: 1d02h
Similar bugs (3)
Kernel Title Rank 🛈 Repro Cause bisect Fix bisect Count Last Reported Patched Status
upstream possible deadlock in ocfs2_fiemap ocfs2 4 C done 1438 52m 312d 0/29 upstream: reported C repro on 2024/09/03 20:43
linux-5.15 possible deadlock in ocfs2_fiemap 4 17 9d05h 275d 0/3 upstream: reported on 2024/10/11 15:39
linux-6.6 possible deadlock in ocfs2_fiemap 4 1 8d05h 8d05h 0/2 upstream: reported on 2025/07/05 14:07

Sample crash report:
ocfs2: Slot 0 on device (7,3) was already allocated to this node!
ocfs2: Mounting device (7,3) on (node local, slot 0) with ordered data mode.
======================================================
WARNING: possible circular locking dependency detected
6.1.142-syzkaller #0 Not tainted
------------------------------------------------------
syz.3.13709/3886 is trying to acquire lock:
ffff8880299353d8 (&mm->mmap_lock){++++}-{3:3}, at: __might_fault+0xa6/0x120 mm/memory.c:5852

but task is already holding lock:
ffff888050cc5be0 (&ocfs2_file_ip_alloc_sem_key){++++}-{3:3}, at: ocfs2_fiemap+0x2b3/0xc60 fs/ocfs2/extent_map.c:755

which lock already depends on the new lock.


the existing dependency chain (in reverse order) is:

-> #6 (&ocfs2_file_ip_alloc_sem_key){++++}-{3:3}:
       down_read+0x42/0x2d0 kernel/locking/rwsem.c:1520
       ocfs2_read_virt_blocks+0x265/0x950 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+0x3d1/0x20c0 fs/ocfs2/dir.c:1091
       ocfs2_find_files_on_disk+0x102/0x390 fs/ocfs2/dir.c:1995
       ocfs2_lookup_ino_from_name+0x4f/0xf0 fs/ocfs2/dir.c:2017
       _ocfs2_get_system_file_inode fs/ocfs2/sysfile.c:136 [inline]
       ocfs2_get_system_file_inode+0x332/0x7b0 fs/ocfs2/sysfile.c:112
       ocfs2_init_global_system_inodes+0x316/0x650 fs/ocfs2/super.c:457
       ocfs2_initialize_super fs/ocfs2/super.c:2253 [inline]
       ocfs2_fill_super+0x2a32/0x4d00 fs/ocfs2/super.c:994
       mount_bdev+0x287/0x3c0 fs/super.c:1443
       legacy_get_tree+0xe6/0x180 fs/fs_context.c:632
       vfs_get_tree+0x88/0x270 fs/super.c:1573
       do_new_mount+0x24a/0xa40 fs/namespace.c:3058
       do_mount fs/namespace.c:3401 [inline]
       __do_sys_mount fs/namespace.c:3609 [inline]
       __se_sys_mount+0x2d6/0x3c0 fs/namespace.c:3586
       do_syscall_x64 arch/x86/entry/common.c:51 [inline]
       do_syscall_64+0x4c/0xa0 arch/x86/entry/common.c:81
       entry_SYSCALL_64_after_hwframe+0x68/0xd2

-> #5 (&osb->system_file_mutex){+.+.}-{3:3}:
       __mutex_lock_common kernel/locking/mutex.c:603 [inline]
       __mutex_lock+0x120/0xaf0 kernel/locking/mutex.c:747
       ocfs2_get_system_file_inode+0x1a2/0x7b0 fs/ocfs2/sysfile.c:101
       ocfs2_reserve_local_alloc_bits+0xfc/0x2670 fs/ocfs2/localalloc.c:626
       ocfs2_reserve_clusters_with_limit+0x1bb/0xba0 fs/ocfs2/suballoc.c:1162
       ocfs2_reserve_clusters fs/ocfs2/suballoc.c:1223 [inline]
       ocfs2_lock_allocators+0x2f7/0x5b0 fs/ocfs2/suballoc.c:2669
       ocfs2_write_begin_nolock+0x2286/0x4270 fs/ocfs2/aops.c:1740
       ocfs2_write_begin+0x1b8/0x300 fs/ocfs2/aops.c:1904
       generic_perform_write+0x2db/0x560 mm/filemap.c:3846
       __generic_file_write_iter+0x172/0x430 mm/filemap.c:3974
       ocfs2_file_write_iter+0x1593/0x1df0 fs/ocfs2/file.c:2469
       call_write_iter include/linux/fs.h:2265 [inline]
       new_sync_write fs/read_write.c:491 [inline]
       vfs_write+0x44c/0x960 fs/read_write.c:584
       ksys_pwrite64 fs/read_write.c:699 [inline]
       __do_sys_pwrite64 fs/read_write.c:709 [inline]
       __se_sys_pwrite64 fs/read_write.c:706 [inline]
       __x64_sys_pwrite64+0x191/0x220 fs/read_write.c:706
       do_syscall_x64 arch/x86/entry/common.c:51 [inline]
       do_syscall_64+0x4c/0xa0 arch/x86/entry/common.c:81
       entry_SYSCALL_64_after_hwframe+0x68/0xd2

-> #4 (&ocfs2_quota_ip_alloc_sem_key){++++}-{3:3}:
       down_write+0x36/0x60 kernel/locking/rwsem.c:1573
       ocfs2_create_local_dquot+0x1a0/0x1790 fs/ocfs2/quota_local.c:1224
       ocfs2_acquire_dquot+0x7ae/0xb10 fs/ocfs2/quota_global.c:871
       dqget+0x778/0xeb0 fs/quota/dquot.c:988
       dquot_set_dqblk+0x27/0xf90 fs/quota/dquot.c:2833
       quota_setquota+0x4ac/0x530 fs/quota/quota.c:310
       __do_sys_quotactl fs/quota/quota.c:960 [inline]
       __se_sys_quotactl+0x295/0x6b0 fs/quota/quota.c:916
       do_syscall_x64 arch/x86/entry/common.c:51 [inline]
       do_syscall_64+0x4c/0xa0 arch/x86/entry/common.c:81
       entry_SYSCALL_64_after_hwframe+0x68/0xd2

-> #3 (&dquot->dq_lock){+.+.}-{3:3}:
       __mutex_lock_common kernel/locking/mutex.c:603 [inline]
       __mutex_lock+0x120/0xaf0 kernel/locking/mutex.c:747
       dquot_commit+0x5a/0x410 fs/quota/dquot.c:507
       ext4_write_dquot+0x1f0/0x360 fs/ext4/super.c:6790
       mark_dquot_dirty fs/quota/dquot.c:372 [inline]
       mark_all_dquot_dirty+0x1e3/0x400 fs/quota/dquot.c:412
       dquot_alloc_inode+0x765/0xa20 fs/quota/dquot.c:1801
       ext4_xattr_inode_alloc_quota fs/ext4/xattr.c:883 [inline]
       ext4_xattr_inode_lookup_create+0xc0/0x1d10 fs/ext4/xattr.c:1542
       ext4_xattr_block_set+0x23a/0x32a0 fs/ext4/xattr.c:1876
       ext4_xattr_set_handle+0x10c1/0x12b0 fs/ext4/xattr.c:2413
       ext4_xattr_set+0x22a/0x320 fs/ext4/xattr.c:2515
       __vfs_setxattr+0x3e0/0x420 fs/xattr.c:182
       __vfs_setxattr_noperm+0x129/0x5e0 fs/xattr.c:216
       vfs_setxattr+0x168/0x2f0 fs/xattr.c:309
       do_setxattr fs/xattr.c:594 [inline]
       setxattr+0x2b2/0x2d0 fs/xattr.c:617
       path_setxattr+0x142/0x280 fs/xattr.c:636
       __do_sys_setxattr fs/xattr.c:652 [inline]
       __se_sys_setxattr fs/xattr.c:648 [inline]
       __x64_sys_setxattr+0xb7/0xd0 fs/xattr.c:648
       do_syscall_x64 arch/x86/entry/common.c:51 [inline]
       do_syscall_64+0x4c/0xa0 arch/x86/entry/common.c:81
       entry_SYSCALL_64_after_hwframe+0x68/0xd2

-> #2 (&ei->xattr_sem){++++}-{3:3}:
       down_read+0x42/0x2d0 kernel/locking/rwsem.c:1520
       ext4_readpage_inline+0x2e/0x2a0 fs/ext4/inline.c:519
       ext4_read_folio+0x172/0x370 fs/ext4/inode.c:3251
       filemap_read_folio+0x160/0x760 mm/filemap.c:2490
       filemap_create_folio mm/filemap.c:2619 [inline]
       filemap_get_pages mm/filemap.c:2672 [inline]
       filemap_read+0xe38/0x2f80 mm/filemap.c:2759
       generic_file_read_iter+0x115/0x670 mm/filemap.c:2914
       __kernel_read+0x2dc/0x6b0 fs/read_write.c:428
       prepare_binprm fs/exec.c:1694 [inline]
       search_binary_handler fs/exec.c:1748 [inline]
       exec_binprm fs/exec.c:1805 [inline]
       bprm_execve+0xa57/0x18a0 fs/exec.c:1874
       do_execveat_common+0x51b/0x6c0 fs/exec.c:1979
       do_execve fs/exec.c:2053 [inline]
       __do_sys_execve fs/exec.c:2129 [inline]
       __se_sys_execve fs/exec.c:2124 [inline]
       __x64_sys_execve+0x8e/0xa0 fs/exec.c:2124
       do_syscall_x64 arch/x86/entry/common.c:51 [inline]
       do_syscall_64+0x4c/0xa0 arch/x86/entry/common.c:81
       entry_SYSCALL_64_after_hwframe+0x68/0xd2

-> #1 (mapping.invalidate_lock){++++}-{3:3}:
       down_read+0x42/0x2d0 kernel/locking/rwsem.c:1520
       filemap_invalidate_lock_shared include/linux/fs.h:813 [inline]
       filemap_fault+0x53c/0x1670 mm/filemap.c:3220
       __do_fault+0x13b/0x4e0 mm/memory.c:4280
       do_shared_fault mm/memory.c:4686 [inline]
       do_fault mm/memory.c:4764 [inline]
       handle_pte_fault mm/memory.c:5031 [inline]
       __handle_mm_fault mm/memory.c:5173 [inline]
       handle_mm_fault+0x1a93/0x3e70 mm/memory.c:5294
       do_user_addr_fault+0x51f/0xb10 arch/x86/mm/fault.c:1340
       handle_page_fault arch/x86/mm/fault.c:1431 [inline]
       exc_page_fault+0x60/0x100 arch/x86/mm/fault.c:1487
       asm_exc_page_fault+0x22/0x30 arch/x86/include/asm/idtentry.h:608

-> #0 (&mm->mmap_lock){++++}-{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+0x2cf8/0x7c50 kernel/locking/lockdep.c:5049
       lock_acquire+0x1b4/0x490 kernel/locking/lockdep.c:5662
       __might_fault+0xc2/0x120 mm/memory.c:5852
       _copy_to_user+0x27/0x130 lib/usercopy.c:36
       copy_to_user include/linux/uaccess.h:169 [inline]
       fiemap_fill_next_extent+0x19d/0x360 fs/ioctl.c:144
       ocfs2_fiemap_inline fs/ocfs2/extent_map.c:725 [inline]
       ocfs2_fiemap+0x9b4/0xc60 fs/ocfs2/extent_map.c:762
       ioctl_fiemap fs/ioctl.c:219 [inline]
       do_vfs_ioctl+0x1425/0x1d10 fs/ioctl.c:810
       __do_sys_ioctl fs/ioctl.c:868 [inline]
       __se_sys_ioctl+0x83/0x170 fs/ioctl.c:856
       do_syscall_x64 arch/x86/entry/common.c:51 [inline]
       do_syscall_64+0x4c/0xa0 arch/x86/entry/common.c:81
       entry_SYSCALL_64_after_hwframe+0x68/0xd2

other info that might help us debug this:

Chain exists of:
  &mm->mmap_lock --> &osb->system_file_mutex --> &ocfs2_file_ip_alloc_sem_key

 Possible unsafe locking scenario:

       CPU0                    CPU1
       ----                    ----
  lock(&ocfs2_file_ip_alloc_sem_key);
                               lock(&osb->system_file_mutex);
                               lock(&ocfs2_file_ip_alloc_sem_key);
  lock(&mm->mmap_lock);

 *** DEADLOCK ***

1 lock held by syz.3.13709/3886:
 #0: ffff888050cc5be0 (&ocfs2_file_ip_alloc_sem_key){++++}-{3:3}, at: ocfs2_fiemap+0x2b3/0xc60 fs/ocfs2/extent_map.c:755

stack backtrace:
CPU: 0 PID: 3886 Comm: syz.3.13709 Not tainted 6.1.142-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 05/07/2025
Call Trace:
 <TASK>
 dump_stack_lvl+0x168/0x22e lib/dump_stack.c:106
 check_noncircular+0x274/0x310 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+0x2cf8/0x7c50 kernel/locking/lockdep.c:5049
 lock_acquire+0x1b4/0x490 kernel/locking/lockdep.c:5662
 __might_fault+0xc2/0x120 mm/memory.c:5852
 _copy_to_user+0x27/0x130 lib/usercopy.c:36
 copy_to_user include/linux/uaccess.h:169 [inline]
 fiemap_fill_next_extent+0x19d/0x360 fs/ioctl.c:144
 ocfs2_fiemap_inline fs/ocfs2/extent_map.c:725 [inline]
 ocfs2_fiemap+0x9b4/0xc60 fs/ocfs2/extent_map.c:762
 ioctl_fiemap fs/ioctl.c:219 [inline]
 do_vfs_ioctl+0x1425/0x1d10 fs/ioctl.c:810
 __do_sys_ioctl fs/ioctl.c:868 [inline]
 __se_sys_ioctl+0x83/0x170 fs/ioctl.c:856
 do_syscall_x64 arch/x86/entry/common.c:51 [inline]
 do_syscall_64+0x4c/0xa0 arch/x86/entry/common.c:81
 entry_SYSCALL_64_after_hwframe+0x68/0xd2
RIP: 0033:0x7f0a32d8e929
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:00007f0a33b91038 EFLAGS: 00000246 ORIG_RAX: 0000000000000010
RAX: ffffffffffffffda RBX: 00007f0a32fb5fa0 RCX: 00007f0a32d8e929
RDX: 0000200000000280 RSI: 00000000c020660b RDI: 0000000000000004
RBP: 00007f0a32e10b39 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 0000000000000000 R14: 00007f0a32fb5fa0 R15: 00007ffd3f36eaa8
 </TASK>

Crashes (21):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2025/07/05 07:28 linux-6.1.y 7e69c33e4858 4f67c4ae .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan possible deadlock in ocfs2_fiemap
2025/02/14 14:39 linux-6.1.y 0cbb5f65e52f 1022af74 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan possible deadlock in ocfs2_fiemap
2025/02/02 12:54 linux-6.1.y 0cbb5f65e52f 568559e4 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan possible deadlock in ocfs2_fiemap
2025/02/02 12:54 linux-6.1.y 0cbb5f65e52f 568559e4 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan possible deadlock in ocfs2_fiemap
2025/02/02 12:49 linux-6.1.y 0cbb5f65e52f 568559e4 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan possible deadlock in ocfs2_fiemap
2025/01/26 10:37 linux-6.1.y 75cefdf153f5 9fbd772e .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan possible deadlock in ocfs2_fiemap
2025/01/01 08:57 linux-6.1.y 563edd786f0a d3ccff63 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan possible deadlock in ocfs2_fiemap
2024/12/14 06:12 linux-6.1.y e4d90d63d385 7cbfbb3a .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan possible deadlock in ocfs2_fiemap
2024/12/07 14:19 linux-6.1.y e4d90d63d385 9ac0fdc6 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan possible deadlock in ocfs2_fiemap
2024/12/07 14:17 linux-6.1.y e4d90d63d385 9ac0fdc6 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan possible deadlock in ocfs2_fiemap
2024/10/11 18:44 linux-6.1.y aa4cd140bba5 cd942402 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan possible deadlock in ocfs2_fiemap
2025/07/12 17:06 linux-6.1.y dfc486ec9cce 3cda49cf .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan-arm64 possible deadlock in ocfs2_fiemap
2025/04/10 04:12 linux-6.1.y 3dfebb87d7eb 988b336c .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan-arm64 possible deadlock in ocfs2_fiemap
2025/04/09 05:32 linux-6.1.y 3dfebb87d7eb a775275d .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan-arm64 possible deadlock in ocfs2_fiemap
2025/02/04 07:52 linux-6.1.y 0cbb5f65e52f 8f267cef .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan-arm64 possible deadlock in ocfs2_fiemap
2025/02/04 07:51 linux-6.1.y 0cbb5f65e52f 8f267cef .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan-arm64 possible deadlock in ocfs2_fiemap
2024/12/14 11:45 linux-6.1.y e4d90d63d385 7cbfbb3a .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan-arm64 possible deadlock in ocfs2_fiemap
2024/11/28 01:13 linux-6.1.y e4d90d63d385 5df23865 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan-arm64 possible deadlock in ocfs2_fiemap
2024/11/25 08:20 linux-6.1.y e4d90d63d385 68da6d95 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan-arm64 possible deadlock in ocfs2_fiemap
2024/11/16 18:30 linux-6.1.y 59d7b1a7104a cfe3a04a .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan-arm64 possible deadlock in ocfs2_fiemap
2024/11/10 09:12 linux-6.1.y d7039b844a1c 6b856513 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan-arm64 possible deadlock in ocfs2_fiemap
* Struck through repros no longer work on HEAD.