syzbot


possible deadlock in ocfs2_del_inode_from_orphan

Status: upstream: reported on 2024/12/11 18:58
Reported-by: syzbot+9160da0ca779c1f03228@syzkaller.appspotmail.com
First crash: 10d, last: 7d07h
Similar bugs (1)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
upstream possible deadlock in ocfs2_del_inode_from_orphan ocfs2 C inconclusive 298 10h07m 79d 0/28 upstream: reported C repro on 2024/10/03 02:18

Sample crash report:
======================================================
WARNING: possible circular locking dependency detected
6.1.119-syzkaller #0 Not tainted
------------------------------------------------------
syz.7.55/4885 is trying to acquire lock:
ffff8880555fed88 (&ocfs2_sysfile_lock_key[args->fi_sysfile_type]){+.+.}-{3:3}, at: inode_lock include/linux/fs.h:758 [inline]
ffff8880555fed88 (&ocfs2_sysfile_lock_key[args->fi_sysfile_type]){+.+.}-{3:3}, at: ocfs2_del_inode_from_orphan+0x155/0x7f0 fs/ocfs2/namei.c:2711

but task is already holding lock:
ffff888070ecb120 (&ocfs2_quota_ip_alloc_sem_key){++++}-{3:3}, at: ocfs2_dio_end_io_write fs/ocfs2/aops.c:2325 [inline]
ffff888070ecb120 (&ocfs2_quota_ip_alloc_sem_key){++++}-{3:3}, at: ocfs2_dio_end_io+0x446/0x1250 fs/ocfs2/aops.c:2431

which lock already depends on the new lock.


the existing dependency chain (in reverse order) is:

-> #3 (&ocfs2_quota_ip_alloc_sem_key){++++}-{3:3}:
       lock_acquire+0x1f8/0x5a0 kernel/locking/lockdep.c:5662
       down_write+0x36/0x60 kernel/locking/rwsem.c:1573
       ocfs2_create_local_dquot+0x1dc/0x1b50 fs/ocfs2/quota_local.c:1231
       ocfs2_acquire_dquot+0x7df/0xb60 fs/ocfs2/quota_global.c:866
       dqget+0x762/0xe90 fs/quota/dquot.c:986
       __dquot_initialize+0x2d9/0xea0 fs/quota/dquot.c:1515
       ocfs2_get_init_inode+0x154/0x1c0 fs/ocfs2/namei.c:202
       ocfs2_mknod+0xe32/0x2e20 fs/ocfs2/namei.c:308
       ocfs2_create+0x1c0/0x4e0 fs/ocfs2/namei.c:672
       lookup_open fs/namei.c:3482 [inline]
       open_last_lookups fs/namei.c:3550 [inline]
       path_openat+0x12f1/0x2e60 fs/namei.c:3780
       do_filp_open+0x230/0x480 fs/namei.c:3810
       do_sys_openat2+0x13b/0x4f0 fs/open.c:1318
       do_sys_open fs/open.c:1334 [inline]
       __do_sys_open fs/open.c:1342 [inline]
       __se_sys_open fs/open.c:1338 [inline]
       __x64_sys_open+0x221/0x270 fs/open.c:1338
       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 (&dquot->dq_lock){+.+.}-{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
       wait_on_dquot fs/quota/dquot.c:356 [inline]
       dqget+0x6dc/0xe90 fs/quota/dquot.c:981
       __dquot_initialize+0x2d9/0xea0 fs/quota/dquot.c:1515
       ocfs2_get_init_inode+0x154/0x1c0 fs/ocfs2/namei.c:202
       ocfs2_mknod+0xe32/0x2e20 fs/ocfs2/namei.c:308
       ocfs2_create+0x1c0/0x4e0 fs/ocfs2/namei.c:672
       lookup_open fs/namei.c:3482 [inline]
       open_last_lookups fs/namei.c:3550 [inline]
       path_openat+0x12f1/0x2e60 fs/namei.c:3780
       do_filp_open+0x230/0x480 fs/namei.c:3810
       do_sys_openat2+0x13b/0x4f0 fs/open.c:1318
       do_sys_open fs/open.c:1334 [inline]
       __do_sys_open fs/open.c:1342 [inline]
       __se_sys_open fs/open.c:1338 [inline]
       __x64_sys_open+0x221/0x270 fs/open.c:1338
       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 (&ocfs2_sysfile_lock_key[args->fi_sysfile_type]#3){+.+.}-{3:3}:
       lock_acquire+0x1f8/0x5a0 kernel/locking/lockdep.c:5662
       down_write+0x36/0x60 kernel/locking/rwsem.c:1573
       inode_lock include/linux/fs.h:758 [inline]
       ocfs2_remove_inode fs/ocfs2/inode.c:655 [inline]
       ocfs2_wipe_inode fs/ocfs2/inode.c:818 [inline]
       ocfs2_delete_inode fs/ocfs2/inode.c:1079 [inline]
       ocfs2_evict_inode+0x17ce/0x4c30 fs/ocfs2/inode.c:1216
       evict+0x529/0x930 fs/inode.c:701
       d_delete_notify include/linux/fsnotify.h:267 [inline]
       vfs_rmdir+0x381/0x4b0 fs/namei.c:4204
       do_rmdir+0x3a2/0x590 fs/namei.c:4252
       __do_sys_unlinkat fs/namei.c:4432 [inline]
       __se_sys_unlinkat fs/namei.c:4426 [inline]
       __x64_sys_unlinkat+0xdc/0xf0 fs/namei.c:4426
       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 (&ocfs2_sysfile_lock_key[args->fi_sysfile_type]){+.+.}-{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
       inode_lock include/linux/fs.h:758 [inline]
       ocfs2_del_inode_from_orphan+0x155/0x7f0 fs/ocfs2/namei.c:2711
       ocfs2_dio_end_io_write fs/ocfs2/aops.c:2333 [inline]
       ocfs2_dio_end_io+0x556/0x1250 fs/ocfs2/aops.c:2431
       dio_complete+0x24a/0x7b0 fs/direct-io.c:271
       __blockdev_direct_IO+0x3ffb/0x4810 fs/direct-io.c:1326
       ocfs2_direct_IO+0x250/0x2c0 fs/ocfs2/aops.c:2468
       generic_file_direct_write+0x204/0x460 mm/filemap.c:3769
       __generic_file_write_iter+0x1c4/0x400 mm/filemap.c:3929
       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

other info that might help us debug this:

Chain exists of:
  &ocfs2_sysfile_lock_key[args->fi_sysfile_type] --> &dquot->dq_lock --> &ocfs2_quota_ip_alloc_sem_key

 Possible unsafe locking scenario:

       CPU0                    CPU1
       ----                    ----
  lock(&ocfs2_quota_ip_alloc_sem_key);
                               lock(&dquot->dq_lock);
                               lock(&ocfs2_quota_ip_alloc_sem_key);
  lock(&ocfs2_sysfile_lock_key[args->fi_sysfile_type]);

 *** DEADLOCK ***

3 locks held by syz.7.55/4885:
 #0: ffff88802a0f6460 (sb_writers#15){.+.+}-{0:0}, at: vfs_writev fs/read_write.c:933 [inline]
 #0: ffff88802a0f6460 (sb_writers#15){.+.+}-{0:0}, at: do_pwritev+0x1fa/0x360 fs/read_write.c:1031
 #1: ffff888070ecb488 (&sb->s_type->i_mutex_key#22){+.+.}-{3:3}, at: inode_lock include/linux/fs.h:758 [inline]
 #1: ffff888070ecb488 (&sb->s_type->i_mutex_key#22){+.+.}-{3:3}, at: ocfs2_file_write_iter+0x476/0x2020 fs/ocfs2/file.c:2399
 #2: ffff888070ecb120 (&ocfs2_quota_ip_alloc_sem_key){++++}-{3:3}, at: ocfs2_dio_end_io_write fs/ocfs2/aops.c:2325 [inline]
 #2: ffff888070ecb120 (&ocfs2_quota_ip_alloc_sem_key){++++}-{3:3}, at: ocfs2_dio_end_io+0x446/0x1250 fs/ocfs2/aops.c:2431

stack backtrace:
CPU: 0 PID: 4885 Comm: syz.7.55 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
 inode_lock include/linux/fs.h:758 [inline]
 ocfs2_del_inode_from_orphan+0x155/0x7f0 fs/ocfs2/namei.c:2711
 ocfs2_dio_end_io_write fs/ocfs2/aops.c:2333 [inline]
 ocfs2_dio_end_io+0x556/0x1250 fs/ocfs2/aops.c:2431
 dio_complete+0x24a/0x7b0 fs/direct-io.c:271
 __blockdev_direct_IO+0x3ffb/0x4810 fs/direct-io.c:1326
 ocfs2_direct_IO+0x250/0x2c0 fs/ocfs2/aops.c:2468
 generic_file_direct_write+0x204/0x460 mm/filemap.c:3769
 __generic_file_write_iter+0x1c4/0x400 mm/filemap.c:3929
 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
RIP: 0033:0x7f1c56385d19
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:00007f1c5716a038 EFLAGS: 00000246 ORIG_RAX: 0000000000000148
RAX: ffffffffffffffda RBX: 00007f1c56575fa0 RCX: 00007f1c56385d19
RDX: 0000000000000001 RSI: 0000000020000240 RDI: 0000000000000004
RBP: 00007f1c56401a20 R08: 0000000000000000 R09: 0000000000000003
R10: 0000000000001400 R11: 0000000000000246 R12: 0000000000000000
R13: 0000000000000000 R14: 00007f1c56575fa0 R15: 00007ffc6bda2be8
 </TASK>

Crashes (2):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2024/12/14 18:47 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_del_inode_from_orphan
2024/12/11 18:57 linux-6.1.y e4d90d63d385 ff949d25 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan possible deadlock in ocfs2_del_inode_from_orphan
* Struck through repros no longer work on HEAD.