syzbot


possible deadlock in ocfs2_fiemap

Status: upstream: reported on 2024/10/11 18:44
Reported-by: syzbot+d66730458cf34fe77585@syzkaller.appspotmail.com
First crash: 75d, last: 11d
Similar bugs (2)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
upstream possible deadlock in ocfs2_fiemap ocfs2 C done 546 6h53m 113d 0/28 upstream: reported C repro on 2024/09/03 20:43
linux-5.15 possible deadlock in ocfs2_fiemap 5 18d 75d 0/3 upstream: reported on 2024/10/11 15:39

Sample crash report:
ocfs2: Mounting device (7,3) on (node local, slot 0) with ordered data mode.
======================================================
WARNING: possible circular locking dependency detected
6.1.119-syzkaller #0 Not tainted
------------------------------------------------------
syz.3.39/4657 is trying to acquire lock:
ffff88807aa8f1d8 (&mm->mmap_lock){++++}-{3:3}, at: __might_fault+0xa1/0x110 mm/memory.c:5851

but task is already holding lock:
ffff888056383f60 (&oi->ip_alloc_sem){++++}-{3:3}, at: ocfs2_fiemap+0x36f/0xf80 fs/ocfs2/extent_map.c:755

which lock already depends on the new lock.


the existing dependency chain (in reverse order) is:

-> #2 (&oi->ip_alloc_sem){++++}-{3:3}:
       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
       do_user_addr_fault arch/x86/mm/fault.c:1340 [inline]
       handle_page_fault arch/x86/mm/fault.c:1431 [inline]
       exc_page_fault+0x26f/0x620 arch/x86/mm/fault.c:1487
       asm_exc_page_fault+0x22/0x30 arch/x86/include/asm/idtentry.h:608

-> #1 (sb_pagefaults#2){.+.+}-{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
       do_user_addr_fault arch/x86/mm/fault.c:1340 [inline]
       handle_page_fault arch/x86/mm/fault.c:1431 [inline]
       exc_page_fault+0x26f/0x620 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+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
       __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+0x9e9/0xf80 fs/ocfs2/extent_map.c:796
       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

other info that might help us debug this:

Chain exists of:
  &mm->mmap_lock --> sb_pagefaults#2 --> &oi->ip_alloc_sem

 Possible unsafe locking scenario:

       CPU0                    CPU1
       ----                    ----
  lock(&oi->ip_alloc_sem);
                               lock(sb_pagefaults#2);
                               lock(&oi->ip_alloc_sem);
  lock(&mm->mmap_lock);

 *** DEADLOCK ***

1 lock held by syz.3.39/4657:
 #0: ffff888056383f60 (&oi->ip_alloc_sem){++++}-{3:3}, at: ocfs2_fiemap+0x36f/0xf80 fs/ocfs2/extent_map.c:755

stack backtrace:
CPU: 1 PID: 4657 Comm: syz.3.39 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
 __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+0x9e9/0xf80 fs/ocfs2/extent_map.c:796
 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
RIP: 0033:0x7fed08d85d19
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:00007fed09b14038 EFLAGS: 00000246 ORIG_RAX: 0000000000000010
RAX: ffffffffffffffda RBX: 00007fed08f75fa0 RCX: 00007fed08d85d19
RDX: 0000000020000300 RSI: 00000000c020660b RDI: 0000000000000004
RBP: 00007fed08e01a20 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 0000000000000000 R14: 00007fed08f75fa0 R15: 00007ffed6009e58
 </TASK>

Crashes (9):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
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
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.