syzbot


possible deadlock in vfs_rename (2)

Status: auto-obsoleted due to no activity on 2025/04/27 15:12
Subsystems: ntfs3
[Documentation on labels]
Reported-by: syzbot+9edbc41b1330724a6243@syzkaller.appspotmail.com
First crash: 152d, last: 100d
Discussions (1)
Title Replies (including bot) Last reply
[syzbot] [ntfs3?] possible deadlock in vfs_rename (2) 0 (1) 2024/11/30 00:07
Similar bugs (4)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
linux-5.15 possible deadlock in vfs_rename 13 41d 354d 0/3 upstream: reported on 2024/05/08 00:59
upstream possible deadlock in vfs_rename kernel 1 809d 809d 0/28 closed as invalid on 2023/02/08 16:28
linux-6.1 possible deadlock in vfs_rename (2) 3 43d 117d 0/3 upstream: reported on 2024/12/31 00:31
linux-6.1 possible deadlock in vfs_rename 8 222d 258d 0/3 auto-obsoleted due to no activity on 2024/12/25 19:29

Sample crash report:
======================================================
WARNING: possible circular locking dependency detected
6.13.0-rc7-syzkaller-00149-g9bffa1ad25b8 #0 Not tainted
------------------------------------------------------
syz.0.5753/23685 is trying to acquire lock:
ffff88807761a850 (&sb->s_type->i_mutex_key#26/4){+.+.}-{4:4}, at: vfs_rename+0x6a2/0xf00 fs/namei.c:5038

but task is already holding lock:
ffff888077572fa8 (&sb->s_type->i_mutex_key#26){+.+.}-{4:4}, at: inode_lock include/linux/fs.h:818 [inline]
ffff888077572fa8 (&sb->s_type->i_mutex_key#26){+.+.}-{4:4}, at: lock_two_nondirectories+0xe1/0x170 fs/inode.c:1281

which lock already depends on the new lock.


the existing dependency chain (in reverse order) is:

-> #4 (&sb->s_type->i_mutex_key#26){+.+.}-{4:4}:
       lock_acquire+0x1ed/0x550 kernel/locking/lockdep.c:5849
       down_write+0x99/0x220 kernel/locking/rwsem.c:1577
       inode_lock include/linux/fs.h:818 [inline]
       ntfs_file_mmap+0x5bc/0x850 fs/ntfs3/file.c:379
       call_mmap include/linux/fs.h:2183 [inline]
       mmap_file mm/internal.h:124 [inline]
       __mmap_new_file_vma mm/vma.c:2291 [inline]
       __mmap_new_vma mm/vma.c:2355 [inline]
       __mmap_region+0x2250/0x2d30 mm/vma.c:2456
       mmap_region+0x226/0x2c0 mm/mmap.c:1352
       do_mmap+0x97a/0x10d0 mm/mmap.c:500
       vm_mmap_pgoff+0x1dd/0x3d0 mm/util.c:575
       ksys_mmap_pgoff+0x4eb/0x720 mm/mmap.c:546
       do_syscall_x64 arch/x86/entry/common.c:52 [inline]
       do_syscall_64+0xf3/0x230 arch/x86/entry/common.c:83
       entry_SYSCALL_64_after_hwframe+0x77/0x7f

-> #3 (&mm->mmap_lock){++++}-{4:4}:
       lock_acquire+0x1ed/0x550 kernel/locking/lockdep.c:5849
       __might_fault+0xc6/0x120 mm/memory.c:6751
       _inline_copy_to_user include/linux/uaccess.h:192 [inline]
       _copy_to_user+0x2c/0xb0 lib/usercopy.c:26
       copy_to_user include/linux/uaccess.h:225 [inline]
       fiemap_fill_next_extent+0x235/0x410 fs/ioctl.c:145
       ni_fiemap+0x96b/0x1220 fs/ntfs3/frecord.c:2037
       ntfs_fiemap+0x132/0x180 fs/ntfs3/file.c:1360
       ioctl_fiemap fs/ioctl.c:220 [inline]
       do_vfs_ioctl+0x1c03/0x2e40 fs/ioctl.c:840
       __do_sys_ioctl fs/ioctl.c:904 [inline]
       __se_sys_ioctl+0x80/0x170 fs/ioctl.c:892
       do_syscall_x64 arch/x86/entry/common.c:52 [inline]
       do_syscall_64+0xf3/0x230 arch/x86/entry/common.c:83
       entry_SYSCALL_64_after_hwframe+0x77/0x7f

-> #2 (&ni->ni_lock#2/5){+.+.}-{4:4}:
       lock_acquire+0x1ed/0x550 kernel/locking/lockdep.c:5849
       __mutex_lock_common kernel/locking/mutex.c:585 [inline]
       __mutex_lock+0x1ac/0xee0 kernel/locking/mutex.c:735
       ni_lock fs/ntfs3/ntfs_fs.h:1110 [inline]
       ntfs_link+0xf4/0x270 fs/ntfs3/namei.c:141
       vfs_link+0x4f2/0x6e0 fs/namei.c:4793
       do_linkat+0x555/0x6f0 fs/namei.c:4863
       __do_sys_link fs/namei.c:4897 [inline]
       __se_sys_link fs/namei.c:4895 [inline]
       __x64_sys_link+0x82/0x90 fs/namei.c:4895
       do_syscall_x64 arch/x86/entry/common.c:52 [inline]
       do_syscall_64+0xf3/0x230 arch/x86/entry/common.c:83
       entry_SYSCALL_64_after_hwframe+0x77/0x7f

-> #1 (&ni->ni_lock/6){+.+.}-{4:4}:
       lock_acquire+0x1ed/0x550 kernel/locking/lockdep.c:5849
       __mutex_lock_common kernel/locking/mutex.c:585 [inline]
       __mutex_lock+0x1ac/0xee0 kernel/locking/mutex.c:735
       ni_lock_dir fs/ntfs3/ntfs_fs.h:1115 [inline]
       ntfs_rename+0x72f/0xd10 fs/ntfs3/namei.c:311
       vfs_rename+0xbdd/0xf00 fs/namei.c:5067
       do_renameat2+0xd94/0x13f0 fs/namei.c:5224
       __do_sys_rename fs/namei.c:5271 [inline]
       __se_sys_rename fs/namei.c:5269 [inline]
       __x64_sys_rename+0x82/0x90 fs/namei.c:5269
       do_syscall_x64 arch/x86/entry/common.c:52 [inline]
       do_syscall_64+0xf3/0x230 arch/x86/entry/common.c:83
       entry_SYSCALL_64_after_hwframe+0x77/0x7f

-> #0 (&sb->s_type->i_mutex_key#26/4){+.+.}-{4:4}:
       check_prev_add kernel/locking/lockdep.c:3161 [inline]
       check_prevs_add kernel/locking/lockdep.c:3280 [inline]
       validate_chain+0x18ef/0x5920 kernel/locking/lockdep.c:3904
       __lock_acquire+0x1397/0x2100 kernel/locking/lockdep.c:5226
       lock_acquire+0x1ed/0x550 kernel/locking/lockdep.c:5849
       down_write_nested+0xa2/0x220 kernel/locking/rwsem.c:1693
       vfs_rename+0x6a2/0xf00 fs/namei.c:5038
       do_renameat2+0xd94/0x13f0 fs/namei.c:5224
       __do_sys_rename fs/namei.c:5271 [inline]
       __se_sys_rename fs/namei.c:5269 [inline]
       __x64_sys_rename+0x82/0x90 fs/namei.c:5269
       do_syscall_x64 arch/x86/entry/common.c:52 [inline]
       do_syscall_64+0xf3/0x230 arch/x86/entry/common.c:83
       entry_SYSCALL_64_after_hwframe+0x77/0x7f

other info that might help us debug this:

Chain exists of:
  &sb->s_type->i_mutex_key#26/4 --> &mm->mmap_lock --> &sb->s_type->i_mutex_key#26

 Possible unsafe locking scenario:

       CPU0                    CPU1
       ----                    ----
  lock(&sb->s_type->i_mutex_key#26);
                               lock(&mm->mmap_lock);
                               lock(&sb->s_type->i_mutex_key#26);
  lock(&sb->s_type->i_mutex_key#26/4);

 *** DEADLOCK ***

3 locks held by syz.0.5753/23685:
 #0: ffff888032b14420 (sb_writers#20){.+.+}-{0:0}, at: mnt_want_write+0x3f/0x90 fs/namespace.c:516
 #1: ffff88807761d460 (&type->i_mutex_dir_key#12/1){+.+.}-{4:4}, at: inode_lock_nested include/linux/fs.h:853 [inline]
 #1: ffff88807761d460 (&type->i_mutex_dir_key#12/1){+.+.}-{4:4}, at: lock_rename fs/namei.c:3215 [inline]
 #1: ffff88807761d460 (&type->i_mutex_dir_key#12/1){+.+.}-{4:4}, at: do_renameat2+0x62c/0x13f0 fs/namei.c:5159
 #2: ffff888077572fa8 (&sb->s_type->i_mutex_key#26){+.+.}-{4:4}, at: inode_lock include/linux/fs.h:818 [inline]
 #2: ffff888077572fa8 (&sb->s_type->i_mutex_key#26){+.+.}-{4:4}, at: lock_two_nondirectories+0xe1/0x170 fs/inode.c:1281

stack backtrace:
CPU: 1 UID: 0 PID: 23685 Comm: syz.0.5753 Not tainted 6.13.0-rc7-syzkaller-00149-g9bffa1ad25b8 #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 12/27/2024
Call Trace:
 <TASK>
 __dump_stack lib/dump_stack.c:94 [inline]
 dump_stack_lvl+0x241/0x360 lib/dump_stack.c:120
 print_circular_bug+0x13a/0x1b0 kernel/locking/lockdep.c:2074
 check_noncircular+0x36a/0x4a0 kernel/locking/lockdep.c:2206
 check_prev_add kernel/locking/lockdep.c:3161 [inline]
 check_prevs_add kernel/locking/lockdep.c:3280 [inline]
 validate_chain+0x18ef/0x5920 kernel/locking/lockdep.c:3904
 __lock_acquire+0x1397/0x2100 kernel/locking/lockdep.c:5226
 lock_acquire+0x1ed/0x550 kernel/locking/lockdep.c:5849
 down_write_nested+0xa2/0x220 kernel/locking/rwsem.c:1693
 vfs_rename+0x6a2/0xf00 fs/namei.c:5038
 do_renameat2+0xd94/0x13f0 fs/namei.c:5224
 __do_sys_rename fs/namei.c:5271 [inline]
 __se_sys_rename fs/namei.c:5269 [inline]
 __x64_sys_rename+0x82/0x90 fs/namei.c:5269
 do_syscall_x64 arch/x86/entry/common.c:52 [inline]
 do_syscall_64+0xf3/0x230 arch/x86/entry/common.c:83
 entry_SYSCALL_64_after_hwframe+0x77/0x7f
RIP: 0033:0x7f5262b85d29
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:00007f526390c038 EFLAGS: 00000246 ORIG_RAX: 0000000000000052
RAX: ffffffffffffffda RBX: 00007f5262d75fa0 RCX: 00007f5262b85d29
RDX: 0000000000000000 RSI: 0000000020000080 RDI: 0000000020000340
RBP: 00007f5262c01b08 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 0000000000000000 R14: 00007f5262d75fa0 R15: 00007ffdab2f6668
 </TASK>

Crashes (3):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2025/01/17 15:11 upstream 9bffa1ad25b8 953d1c45 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-kasan-gce-root possible deadlock in vfs_rename
2024/11/25 19:43 upstream 9f16d5e6f220 11dbc254 .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-fs possible deadlock in vfs_rename
2024/11/25 19:42 upstream 9f16d5e6f220 11dbc254 .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-fs possible deadlock in vfs_rename
* Struck through repros no longer work on HEAD.