syzbot


possible deadlock in ocfs2_fiemap

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

Sample crash report:
======================================================
WARNING: possible circular locking dependency detected
6.1.119-syzkaller #0 Not tainted
------------------------------------------------------
syz.2.6/4338 is trying to acquire lock:
ffff8880796e44d8 (&mm->mmap_lock){++++}-{3:3}, at: __might_fault+0xa1/0x110 mm/memory.c:5851

but task is already holding lock:
ffff8880551dbf60 (&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.2.6/4338:
 #0: ffff8880551dbf60 (&oi->ip_alloc_sem){++++}-{3:3}, at: ocfs2_fiemap+0x36f/0xf80 fs/ocfs2/extent_map.c:755

stack backtrace:
CPU: 0 PID: 4338 Comm: syz.2.6 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:0x7fb3e937fed9
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:00007fb3ea274058 EFLAGS: 00000246 ORIG_RAX: 0000000000000010
RAX: ffffffffffffffda RBX: 00007fb3e9545fa0 RCX: 00007fb3e937fed9
RDX: 0000000020000280 RSI: 00000000c020660b RDI: 0000000000000004
RBP: 00007fb3e93f3cc8 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 0000000000000000 R14: 00007fb3e9545fa0 R15: 00007ffc8f154e78
 </TASK>

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