syzbot


possible deadlock in lock_two_nondirectories

Status: auto-obsoleted due to no activity on 2023/08/21 19:52
Subsystems: reiserfs ext4
[Documentation on labels]
Reported-by: syzbot+fa80832503dc44cfd65d@syzkaller.appspotmail.com
First crash: 573d, last: 356d
Discussions (1)
Title Replies (including bot) Last reply
[syzbot] possible deadlock in lock_two_nondirectories 0 (1) 2022/09/22 22:24
Similar bugs (1)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
linux-4.14 possible deadlock in lock_two_nondirectories 1 1462d 1462d 0/1 auto-closed as invalid on 2020/08/10 20:40

Sample crash report:
REISERFS (device loop3): checking transaction log (loop3)
REISERFS (device loop3): Using r5 hash to sort names
REISERFS (device loop3): Created .reiserfs_priv - reserved for xattr storage.
======================================================
WARNING: possible circular locking dependency detected
6.2.0-rc7-syzkaller-00231-g711e9a4d52bf #0 Not tainted
------------------------------------------------------
syz-executor.3/15761 is trying to acquire lock:
ffff888087f8e640 (&sb->s_type->i_mutex_key#29){+.+.}-{3:3}, at: inode_lock include/linux/fs.h:756 [inline]
ffff888087f8e640 (&sb->s_type->i_mutex_key#29){+.+.}-{3:3}, at: lock_two_nondirectories+0xf0/0x110 fs/inode.c:1121

but task is already holding lock:
ffff888087f8ece0 (&type->i_mutex_dir_key#16/2){+.+.}-{3:3}, at: inode_lock_nested include/linux/fs.h:791 [inline]
ffff888087f8ece0 (&type->i_mutex_dir_key#16/2){+.+.}-{3:3}, at: lock_rename+0xd8/0x280 fs/namei.c:2999

which lock already depends on the new lock.


the existing dependency chain (in reverse order) is:

-> #2 (&type->i_mutex_dir_key#16/2){+.+.}-{3:3}:
       down_write_nested+0x98/0x220 kernel/locking/rwsem.c:1672
       inode_lock_nested include/linux/fs.h:791 [inline]
       xattr_rmdir fs/reiserfs/xattr.c:106 [inline]
       delete_one_xattr+0x141/0x2d0 fs/reiserfs/xattr.c:338
       reiserfs_for_each_xattr+0x70e/0x9a0 fs/reiserfs/xattr.c:311
       reiserfs_delete_xattrs+0x20/0xa0 fs/reiserfs/xattr.c:364
       reiserfs_evict_inode+0x2e7/0x540 fs/reiserfs/inode.c:53
       evict+0x2ed/0x6b0 fs/inode.c:664
       iput_final fs/inode.c:1747 [inline]
       iput.part.0+0x59b/0x880 fs/inode.c:1773
       iput+0x5c/0x80 fs/inode.c:1763
       dentry_unlink_inode+0x2b1/0x460 fs/dcache.c:401
       __dentry_kill+0x3c0/0x640 fs/dcache.c:607
       dentry_kill fs/dcache.c:745 [inline]
       dput+0x651/0xdb0 fs/dcache.c:913
       ovl_create_over_whiteout fs/overlayfs/dir.c:551 [inline]
       ovl_create_or_link+0x1059/0x1780 fs/overlayfs/dir.c:613
       ovl_create_object+0x20b/0x290 fs/overlayfs/dir.c:647
       vfs_mkdir+0x48d/0x740 fs/namei.c:4036
       do_mkdirat+0x27b/0x2f0 fs/namei.c:4061
       __do_sys_mkdir fs/namei.c:4081 [inline]
       __se_sys_mkdir fs/namei.c:4079 [inline]
       __x64_sys_mkdir+0xf6/0x140 fs/namei.c:4079
       do_syscall_x64 arch/x86/entry/common.c:50 [inline]
       do_syscall_64+0x39/0xb0 arch/x86/entry/common.c:80
       entry_SYSCALL_64_after_hwframe+0x63/0xcd

-> #1 (&type->i_mutex_dir_key#16/3){+.+.}-{3:3}:
       down_write_nested+0x98/0x220 kernel/locking/rwsem.c:1672
       inode_lock_nested include/linux/fs.h:791 [inline]
       open_xa_root fs/reiserfs/xattr.c:127 [inline]
       open_xa_dir+0x127/0x830 fs/reiserfs/xattr.c:152
       xattr_lookup+0x21/0x3d0 fs/reiserfs/xattr.c:395
       reiserfs_xattr_get+0x118/0xa80 fs/reiserfs/xattr.c:677
       security_get+0x83/0xb0 fs/reiserfs/xattr_security.c:19
       __vfs_getxattr+0x138/0x1a0 fs/xattr.c:425
       cap_inode_need_killpriv+0x40/0x60 security/commoncap.c:301
       security_inode_need_killpriv+0x44/0xa0 security/security.c:1492
       dentry_needs_remove_privs fs/inode.c:1967 [inline]
       __file_remove_privs+0x382/0x5f0 fs/inode.c:1998
       __generic_file_write_iter+0xc7/0x500 mm/filemap.c:3845
       generic_file_write_iter+0xe3/0x350 mm/filemap.c:3932
       call_write_iter include/linux/fs.h:2189 [inline]
       new_sync_write fs/read_write.c:491 [inline]
       vfs_write+0x9ed/0xdd0 fs/read_write.c:584
       ksys_write+0x12b/0x250 fs/read_write.c:637
       do_syscall_x64 arch/x86/entry/common.c:50 [inline]
       do_syscall_64+0x39/0xb0 arch/x86/entry/common.c:80
       entry_SYSCALL_64_after_hwframe+0x63/0xcd

-> #0 (&sb->s_type->i_mutex_key#29){+.+.}-{3:3}:
       check_prev_add kernel/locking/lockdep.c:3097 [inline]
       check_prevs_add kernel/locking/lockdep.c:3216 [inline]
       validate_chain kernel/locking/lockdep.c:3831 [inline]
       __lock_acquire+0x2a43/0x56d0 kernel/locking/lockdep.c:5055
       lock_acquire kernel/locking/lockdep.c:5668 [inline]
       lock_acquire+0x1e3/0x630 kernel/locking/lockdep.c:5633
       down_write+0x94/0x220 kernel/locking/rwsem.c:1562
       inode_lock include/linux/fs.h:756 [inline]
       lock_two_nondirectories+0xf0/0x110 fs/inode.c:1121
       vfs_rename+0xc18/0x1a90 fs/namei.c:4749
       do_renameat2+0xb22/0xc30 fs/namei.c:4930
       __do_sys_renameat2 fs/namei.c:4963 [inline]
       __se_sys_renameat2 fs/namei.c:4960 [inline]
       __x64_sys_renameat2+0xe8/0x120 fs/namei.c:4960
       do_syscall_x64 arch/x86/entry/common.c:50 [inline]
       do_syscall_64+0x39/0xb0 arch/x86/entry/common.c:80
       entry_SYSCALL_64_after_hwframe+0x63/0xcd

other info that might help us debug this:

Chain exists of:
  &sb->s_type->i_mutex_key#29 --> &type->i_mutex_dir_key#16/3 --> &type->i_mutex_dir_key#16/2

 Possible unsafe locking scenario:

       CPU0                    CPU1
       ----                    ----
  lock(&type->i_mutex_dir_key#16/2);
                               lock(&type->i_mutex_dir_key#16/3);
                               lock(&type->i_mutex_dir_key#16/2);
  lock(&sb->s_type->i_mutex_key#29);

 *** DEADLOCK ***

4 locks held by syz-executor.3/15761:
 #0: ffff888088836460 (sb_writers#23){.+.+}-{0:0}, at: do_renameat2+0x37f/0xc30 fs/namei.c:4866
 #1: ffff888088836748 (&type->s_vfs_rename_key#3){+.+.}-{3:3}, at: lock_rename+0x58/0x280 fs/namei.c:2994
 #2: ffff888087f8cbc0 (&type->i_mutex_dir_key#16/1){+.+.}-{3:3}, at: inode_lock_nested include/linux/fs.h:791 [inline]
 #2: ffff888087f8cbc0 (&type->i_mutex_dir_key#16/1){+.+.}-{3:3}, at: lock_rename+0xa4/0x280 fs/namei.c:2998
 #3: ffff888087f8ece0 (&type->i_mutex_dir_key#16/2){+.+.}-{3:3}, at: inode_lock_nested include/linux/fs.h:791 [inline]
 #3: ffff888087f8ece0 (&type->i_mutex_dir_key#16/2){+.+.}-{3:3}, at: lock_rename+0xd8/0x280 fs/namei.c:2999

stack backtrace:
CPU: 1 PID: 15761 Comm: syz-executor.3 Not tainted 6.2.0-rc7-syzkaller-00231-g711e9a4d52bf #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/21/2023
Call Trace:
 <TASK>
 __dump_stack lib/dump_stack.c:88 [inline]
 dump_stack_lvl+0xd1/0x138 lib/dump_stack.c:106
 check_noncircular+0x25f/0x2e0 kernel/locking/lockdep.c:2177
 check_prev_add kernel/locking/lockdep.c:3097 [inline]
 check_prevs_add kernel/locking/lockdep.c:3216 [inline]
 validate_chain kernel/locking/lockdep.c:3831 [inline]
 __lock_acquire+0x2a43/0x56d0 kernel/locking/lockdep.c:5055
 lock_acquire kernel/locking/lockdep.c:5668 [inline]
 lock_acquire+0x1e3/0x630 kernel/locking/lockdep.c:5633
 down_write+0x94/0x220 kernel/locking/rwsem.c:1562
 inode_lock include/linux/fs.h:756 [inline]
 lock_two_nondirectories+0xf0/0x110 fs/inode.c:1121
 vfs_rename+0xc18/0x1a90 fs/namei.c:4749
 do_renameat2+0xb22/0xc30 fs/namei.c:4930
 __do_sys_renameat2 fs/namei.c:4963 [inline]
 __se_sys_renameat2 fs/namei.c:4960 [inline]
 __x64_sys_renameat2+0xe8/0x120 fs/namei.c:4960
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x39/0xb0 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x63/0xcd
RIP: 0033:0x7fdf7e88c0f9
Code: 28 00 00 00 75 05 48 83 c4 28 c3 e8 f1 19 00 00 90 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 b8 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007fdf7f52e168 EFLAGS: 00000246 ORIG_RAX: 000000000000013c
RAX: ffffffffffffffda RBX: 00007fdf7e9abf80 RCX: 00007fdf7e88c0f9
RDX: 0000000000000007 RSI: 00000000200001c0 RDI: 0000000000000007
RBP: 00007fdf7e8e7ae9 R08: 0000000000000000 R09: 0000000000000000
R10: 00000000200002c0 R11: 0000000000000246 R12: 0000000000000000
R13: 00007ffc09a8da8f R14: 00007fdf7f52e300 R15: 0000000000022000
 </TASK>

Crashes (7):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2023/02/13 04:19 upstream 711e9a4d52bf 93e26d60 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-kasan-gce-root possible deadlock in lock_two_nondirectories
2023/02/08 13:04 upstream 0983f6bf2bfc abbb67b7 .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-fs possible deadlock in lock_two_nondirectories
2023/02/08 12:31 upstream 0983f6bf2bfc abbb67b7 .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-fs possible deadlock in lock_two_nondirectories
2023/02/08 11:04 upstream 0983f6bf2bfc 15c3d445 .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-fs possible deadlock in lock_two_nondirectories
2022/12/25 21:29 upstream 72a85e2b0a1e 9da18ae8 .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-fs possible deadlock in lock_two_nondirectories
2022/09/18 22:17 upstream 38eddeedbbea dd9a85ff .config console log report info ci-upstream-kasan-gce-root possible deadlock in lock_two_nondirectories
2023/04/23 19:51 git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git for-kernelci 14f8db1c0f9a 2b32bd34 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-gce-arm64 possible deadlock in lock_two_nondirectories
* Struck through repros no longer work on HEAD.