[syzbot] [ext4?] possible deadlock in ext4_find_inline_entry

Visto 7 veces
Saltar al primer mensaje no leído

syzbot

no leída,
28 dic 2022, 2:59:3928/12/22
a adilger...@dilger.ca,linux...@vger.kernel.org,linux-...@vger.kernel.org,syzkall...@googlegroups.com,ty...@mit.edu
Hello,

syzbot found the following issue on:

HEAD commit: a5541c0811a0 Merge branch 'for-next/core' into for-kernelci
git tree: git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git for-kernelci
console output: https://syzkaller.appspot.com/x/log.txt?x=124896ff880000
kernel config: https://syzkaller.appspot.com/x/.config?x=cbd4e584773e9397
dashboard link: https://syzkaller.appspot.com/bug?extid=d3bb749184481f92deb5
compiler: Debian clang version 13.0.1-++20220126092033+75e33f71c2da-1~exp1~20220126212112.63, GNU ld (GNU Binutils for Debian) 2.35.2
userspace arch: arm64
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=11711df8480000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=161e81b0480000

Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/4b7702208fb9/disk-a5541c08.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/9ec0153ec051/vmlinux-a5541c08.xz
kernel image: https://storage.googleapis.com/syzbot-assets/6f8725ad290a/Image-a5541c08.gz.xz
mounted in repro: https://storage.googleapis.com/syzbot-assets/5ea71b2bd574/mount_0.gz

IMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by: syzbot+d3bb74...@syzkaller.appspotmail.com

EXT4-fs: Warning: mounting with an experimental mount option 'dioread_nolock' for blocksize < PAGE_SIZE
EXT4-fs (loop0): mounted filesystem without journal. Quota mode: none.
======================================================
WARNING: possible circular locking dependency detected
6.1.0-rc8-syzkaller-33330-ga5541c0811a0 #0 Not tainted
------------------------------------------------------
syz-executor246/3073 is trying to acquire lock:
ffff0000cacbcd48 (&ei->xattr_sem){++++}-{3:3}, at: ext4_find_inline_entry+0x80/0x224 fs/ext4/inline.c:1690

but task is already holding lock:
ffff0000cacbda10 (&ea_inode->i_rwsem#8/1){+.+.}-{3:3}, at: inode_lock include/linux/fs.h:756 [inline]
ffff0000cacbda10 (&ea_inode->i_rwsem#8/1){+.+.}-{3:3}, at: vfs_unlink+0x78/0x300 fs/namei.c:4241

which lock already depends on the new lock.


the existing dependency chain (in reverse order) is:

-> #1 (&ea_inode->i_rwsem#8/1){+.+.}-{3:3}:
down_write+0x5c/0x88 kernel/locking/rwsem.c:1562
inode_lock include/linux/fs.h:756 [inline]
ext4_xattr_inode_create fs/ext4/xattr.c:1454 [inline]
ext4_xattr_inode_lookup_create fs/ext4/xattr.c:1537 [inline]
ext4_xattr_set_entry+0xde4/0xe28 fs/ext4/xattr.c:1665
ext4_xattr_ibody_set+0x94/0x184 fs/ext4/xattr.c:2225
ext4_xattr_set_handle+0x648/0x9a0 fs/ext4/xattr.c:2382
ext4_xattr_set+0x100/0x1d0 fs/ext4/xattr.c:2496
ext4_xattr_trusted_set+0x4c/0x64 fs/ext4/xattr_trusted.c:38
__vfs_setxattr+0x250/0x260 fs/xattr.c:182
__vfs_setxattr_noperm+0xcc/0x320 fs/xattr.c:216
__vfs_setxattr_locked+0x16c/0x194 fs/xattr.c:277
vfs_setxattr+0xf4/0x1f4 fs/xattr.c:309
do_setxattr fs/xattr.c:594 [inline]
setxattr fs/xattr.c:617 [inline]
path_setxattr+0x354/0x414 fs/xattr.c:636
__do_sys_lsetxattr fs/xattr.c:659 [inline]
__se_sys_lsetxattr fs/xattr.c:655 [inline]
__arm64_sys_lsetxattr+0x2c/0x40 fs/xattr.c:655
__invoke_syscall arch/arm64/kernel/syscall.c:38 [inline]
invoke_syscall arch/arm64/kernel/syscall.c:52 [inline]
el0_svc_common+0x138/0x220 arch/arm64/kernel/syscall.c:142
do_el0_svc+0x48/0x140 arch/arm64/kernel/syscall.c:197
el0_svc+0x58/0x150 arch/arm64/kernel/entry-common.c:637
el0t_64_sync_handler+0x84/0xf0 arch/arm64/kernel/entry-common.c:655
el0t_64_sync+0x190/0x194 arch/arm64/kernel/entry.S:584

-> #0 (&ei->xattr_sem){++++}-{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+0x1530/0x3084 kernel/locking/lockdep.c:5055
lock_acquire+0x100/0x1f8 kernel/locking/lockdep.c:5668
down_read+0x5c/0x78 kernel/locking/rwsem.c:1509
ext4_find_inline_entry+0x80/0x224 fs/ext4/inline.c:1690
__ext4_find_entry+0xe8/0xb4c fs/ext4/namei.c:1596
ext4_find_entry fs/ext4/namei.c:1731 [inline]
__ext4_unlink+0xa8/0x3e4 fs/ext4/namei.c:3215
ext4_unlink+0x150/0x200 fs/ext4/namei.c:3291
vfs_unlink+0x1dc/0x300 fs/namei.c:4252
do_unlinkat+0x200/0x3dc fs/namei.c:4320
__do_sys_unlinkat fs/namei.c:4363 [inline]
__se_sys_unlinkat fs/namei.c:4356 [inline]
__arm64_sys_unlinkat+0x7c/0xa8 fs/namei.c:4356
__invoke_syscall arch/arm64/kernel/syscall.c:38 [inline]
invoke_syscall arch/arm64/kernel/syscall.c:52 [inline]
el0_svc_common+0x138/0x220 arch/arm64/kernel/syscall.c:142
do_el0_svc+0x48/0x140 arch/arm64/kernel/syscall.c:197
el0_svc+0x58/0x150 arch/arm64/kernel/entry-common.c:637
el0t_64_sync_handler+0x84/0xf0 arch/arm64/kernel/entry-common.c:655
el0t_64_sync+0x190/0x194 arch/arm64/kernel/entry.S:584

other info that might help us debug this:

Possible unsafe locking scenario:

CPU0 CPU1
---- ----
lock(&ea_inode->i_rwsem#8/1);
lock(&ei->xattr_sem);
lock(&ea_inode->i_rwsem#8/1);
lock(&ei->xattr_sem);

*** DEADLOCK ***

3 locks held by syz-executor246/3073:
#0: ffff0000ca036460 (sb_writers#3){.+.+}-{0:0}, at: mnt_want_write+0x20/0x64 fs/namespace.c:393
#1: ffff0000cacbd080 (&type->i_mutex_dir_key#3/1){+.+.}-{3:3}, at: inode_lock_nested include/linux/fs.h:791 [inline]
#1: ffff0000cacbd080 (&type->i_mutex_dir_key#3/1){+.+.}-{3:3}, at: do_unlinkat+0xf0/0x3dc fs/namei.c:4303
#2: ffff0000cacbda10 (&ea_inode->i_rwsem#8/1){+.+.}-{3:3}, at: inode_lock include/linux/fs.h:756 [inline]
#2: ffff0000cacbda10 (&ea_inode->i_rwsem#8/1){+.+.}-{3:3}, at: vfs_unlink+0x78/0x300 fs/namei.c:4241

stack backtrace:
CPU: 1 PID: 3073 Comm: syz-executor246 Not tainted 6.1.0-rc8-syzkaller-33330-ga5541c0811a0 #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 10/26/2022
Call trace:
dump_backtrace+0x1c4/0x1f0 arch/arm64/kernel/stacktrace.c:156
show_stack+0x2c/0x3c arch/arm64/kernel/stacktrace.c:163
__dump_stack lib/dump_stack.c:88 [inline]
dump_stack_lvl+0x104/0x16c lib/dump_stack.c:106
dump_stack+0x1c/0x58 lib/dump_stack.c:113
print_circular_bug+0x2c4/0x2c8 kernel/locking/lockdep.c:2055
check_noncircular+0x14c/0x154 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+0x1530/0x3084 kernel/locking/lockdep.c:5055
lock_acquire+0x100/0x1f8 kernel/locking/lockdep.c:5668
down_read+0x5c/0x78 kernel/locking/rwsem.c:1509
ext4_find_inline_entry+0x80/0x224 fs/ext4/inline.c:1690
__ext4_find_entry+0xe8/0xb4c fs/ext4/namei.c:1596
ext4_find_entry fs/ext4/namei.c:1731 [inline]
__ext4_unlink+0xa8/0x3e4 fs/ext4/namei.c:3215
ext4_unlink+0x150/0x200 fs/ext4/namei.c:3291
vfs_unlink+0x1dc/0x300 fs/namei.c:4252
do_unlinkat+0x200/0x3dc fs/namei.c:4320
__do_sys_unlinkat fs/namei.c:4363 [inline]
__se_sys_unlinkat fs/namei.c:4356 [inline]
__arm64_sys_unlinkat+0x7c/0xa8 fs/namei.c:4356
__invoke_syscall arch/arm64/kernel/syscall.c:38 [inline]
invoke_syscall arch/arm64/kernel/syscall.c:52 [inline]
el0_svc_common+0x138/0x220 arch/arm64/kernel/syscall.c:142
do_el0_svc+0x48/0x140 arch/arm64/kernel/syscall.c:197
el0_svc+0x58/0x150 arch/arm64/kernel/entry-common.c:637
el0t_64_sync_handler+0x84/0xf0 arch/arm64/kernel/entry-common.c:655
el0t_64_sync+0x190/0x194 arch/arm64/kernel/entry.S:584


---
This report is generated by a bot. It may contain errors.
See https://goo.gl/tpsmEJ for more information about syzbot.
syzbot engineers can be reached at syzk...@googlegroups.com.

syzbot will keep track of this issue. See:
https://goo.gl/tpsmEJ#status for how to communicate with syzbot.
syzbot can test patches for this issue, for details see:
https://goo.gl/tpsmEJ#testing-patches

Hillf Danton

no leída,
28 dic 2022, 4:38:5628/12/22
a syzbot,linux-...@vger.kernel.org,syzkall...@googlegroups.com
On 27 Dec 2022 23:59:37 -0800
> syzbot found the following issue on:
>
> HEAD commit: a5541c0811a0 Merge branch 'for-next/core' into for-kernelci
> git tree: git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git for-kernelci
> C reproducer: https://syzkaller.appspot.com/x/repro.c?x=161e81b0480000

Create new inode with S_IFREG and S_NOQUOTA set in a bid to break the lock chain.

#syz test https://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git a5541c0811a0

--- x/fs/ext4/xattr.c
+++ y/fs/ext4/xattr.c
@@ -1427,7 +1427,7 @@ static struct inode *ext4_xattr_inode_cr
* in the same group, or nearby one.
*/
ea_inode = ext4_new_inode(handle, inode->i_sb->s_root->d_inode,
- S_IFREG | 0600, NULL, inode->i_ino + 1, owner,
+ S_IFREG | S_NOQUOTA | 0600, NULL, inode->i_ino + 1, owner,
EXT4_EA_INODE_FL);
if (!IS_ERR(ea_inode)) {
ea_inode->i_op = &ext4_file_inode_operations;
@@ -1451,9 +1451,6 @@ static struct inode *ext4_xattr_inode_cr
*/
dquot_free_inode(ea_inode);
dquot_drop(ea_inode);
- inode_lock(ea_inode);
- ea_inode->i_flags |= S_NOQUOTA;
- inode_unlock(ea_inode);
}

return ea_inode;
--

syzbot

no leída,
28 dic 2022, 4:50:1528/12/22
a hda...@sina.com,linux-...@vger.kernel.org,syzkall...@googlegroups.com
Hello,

syzbot has tested the proposed patch but the reproducer is still triggering an issue:
possible deadlock in ext4_find_inline_entry

EXT4-fs: Warning: mounting with an experimental mount option 'dioread_nolock' for blocksize < PAGE_SIZE
EXT4-fs (loop0): mounted filesystem without journal. Quota mode: none.
======================================================
WARNING: possible circular locking dependency detected
6.1.0-rc8-syzkaller-00172-ga5541c0811a0-dirty #0 Not tainted
------------------------------------------------------
syz-executor.0/3637 is trying to acquire lock:
ffff0000d11c93e8 (&ei->xattr_sem){++++}-{3:3}, at: ext4_find_inline_entry+0x80/0x224 fs/ext4/inline.c:1690

but task is already holding lock:
ffff0000d11ca0b0 (&ea_inode->i_rwsem#8/1){+.+.}-{3:3}, at: inode_lock include/linux/fs.h:756 [inline]
ffff0000d11ca0b0 (&ea_inode->i_rwsem#8/1){+.+.}-{3:3}, at: vfs_unlink+0x78/0x300 fs/namei.c:4241

which lock already depends on the new lock.


the existing dependency chain (in reverse order) is:

-> #1 (&ea_inode->i_rwsem#8/1){+.+.}-{3:3}:
down_write+0x5c/0x88 kernel/locking/rwsem.c:1562
inode_lock include/linux/fs.h:756 [inline]
ext4_xattr_inode_write+0x2f0/0x460 fs/ext4/xattr.c:1400
ext4_xattr_inode_lookup_create fs/ext4/xattr.c:1538 [inline]
ext4_xattr_set_entry+0xd38/0xe08 fs/ext4/xattr.c:1662
ext4_xattr_ibody_set+0x94/0x184 fs/ext4/xattr.c:2222
ext4_xattr_set_handle+0x648/0x9a0 fs/ext4/xattr.c:2379
ext4_xattr_set+0x100/0x1d0 fs/ext4/xattr.c:2493
3 locks held by syz-executor.0/3637:
#0: ffff0000cabc0460 (sb_writers#3){.+.+}-{0:0}, at: mnt_want_write+0x20/0x64 fs/namespace.c:393
#1: ffff0000d11c9720 (&type->i_mutex_dir_key#3/1){+.+.}-{3:3}, at: inode_lock_nested include/linux/fs.h:791 [inline]
#1: ffff0000d11c9720 (&type->i_mutex_dir_key#3/1){+.+.}-{3:3}, at: do_unlinkat+0xf0/0x3dc fs/namei.c:4303
#2: ffff0000d11ca0b0 (&ea_inode->i_rwsem#8/1){+.+.}-{3:3}, at: inode_lock include/linux/fs.h:756 [inline]
#2: ffff0000d11ca0b0 (&ea_inode->i_rwsem#8/1){+.+.}-{3:3}, at: vfs_unlink+0x78/0x300 fs/namei.c:4241

stack backtrace:
CPU: 0 PID: 3637 Comm: syz-executor.0 Not tainted 6.1.0-rc8-syzkaller-00172-ga5541c0811a0-dirty #0
Tested on:

commit: a5541c08 Merge branch 'for-next/core' into for-kernelci
git tree: https://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git
console output: https://syzkaller.appspot.com/x/log.txt?x=10d9aec4480000
kernel config: https://syzkaller.appspot.com/x/.config?x=cbd4e584773e9397
dashboard link: https://syzkaller.appspot.com/bug?extid=d3bb749184481f92deb5
compiler: Debian clang version 13.0.1-++20220126092033+75e33f71c2da-1~exp1~20220126212112.63, GNU ld (GNU Binutils for Debian) 2.35.2
userspace arch: arm64
patch: https://syzkaller.appspot.com/x/patch.diff?x=15213e32480000

Hillf Danton

no leída,
28 dic 2022, 19:55:5628/12/22
a syzbot,linux-...@vger.kernel.org,syzkall...@googlegroups.com
On 27 Dec 2022 23:59:37 -0800
> syzbot found the following issue on:
>
> HEAD commit: a5541c0811a0 Merge branch 'for-next/core' into for-kernelci
> git tree: git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git for-kernelci
> C reproducer: https://syzkaller.appspot.com/x/repro.c?x=161e81b0480000

See if lock key can make a difference.

#syz test https://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git a5541c0811a0

--- x/fs/ext4/xattr.c
+++ y/fs/ext4/xattr.c
@@ -1433,7 +1433,6 @@ static struct inode *ext4_xattr_inode_cr
ea_inode->i_op = &ext4_file_inode_operations;
ea_inode->i_fop = &ext4_file_operations;
ext4_set_aops(ea_inode);
- ext4_xattr_inode_set_class(ea_inode);
unlock_new_inode(ea_inode);
ext4_xattr_inode_set_ref(ea_inode, 1);
ext4_xattr_inode_set_hash(ea_inode, hash);
--

syzbot

no leída,
28 dic 2022, 20:23:2328/12/22
a hda...@sina.com,linux-...@vger.kernel.org,syzkall...@googlegroups.com
Hello,

syzbot has tested the proposed patch but the reproducer is still triggering an issue:
possible deadlock in ext4_xattr_set_entry

EXT4-fs: Warning: mounting with an experimental mount option 'dioread_nolock' for blocksize < PAGE_SIZE
EXT4-fs (loop0): mounted filesystem without journal. Quota mode: none.
======================================================
WARNING: possible circular locking dependency detected
6.1.0-rc8-syzkaller-00172-ga5541c0811a0-dirty #0 Not tainted
------------------------------------------------------
syz-executor.0/3668 is trying to acquire lock:
ffff0000cf16bd60 (&sb->s_type->i_mutex_key#8){++++}-{3:3}, at: inode_lock include/linux/fs.h:756 [inline]
ffff0000cf16bd60 (&sb->s_type->i_mutex_key#8){++++}-{3:3}, at: ext4_xattr_inode_create fs/ext4/xattr.c:1453 [inline]
ffff0000cf16bd60 (&sb->s_type->i_mutex_key#8){++++}-{3:3}, at: ext4_xattr_inode_lookup_create fs/ext4/xattr.c:1536 [inline]
ffff0000cf16bd60 (&sb->s_type->i_mutex_key#8){++++}-{3:3}, at: ext4_xattr_set_entry+0xdbc/0xe00 fs/ext4/xattr.c:1664

but task is already holding lock:
ffff0000cf16b098 (&ei->xattr_sem){++++}-{3:3}, at: ext4_write_lock_xattr fs/ext4/xattr.h:155 [inline]
ffff0000cf16b098 (&ei->xattr_sem){++++}-{3:3}, at: ext4_xattr_set_handle+0xd0/0x9a0 fs/ext4/xattr.c:2308

which lock already depends on the new lock.


the existing dependency chain (in reverse order) is:

-> #1 (&ei->xattr_sem){++++}-{3:3}:
down_read+0x5c/0x78 kernel/locking/rwsem.c:1509
ext4_xattr_get+0x90/0x418 fs/ext4/xattr.c:665
ext4_xattr_security_get+0x40/0x54 fs/ext4/xattr_security.c:20
__vfs_getxattr+0x1fc/0x20c fs/xattr.c:407
cap_inode_need_killpriv+0x34/0x5c security/commoncap.c:301
security_inode_need_killpriv+0x34/0x88 security/security.c:1422
dentry_needs_remove_privs fs/inode.c:1995 [inline]
__file_remove_privs+0xe0/0x308 fs/inode.c:2026
file_modified_flags+0x60/0x330 fs/inode.c:2148
file_modified+0x24/0x34 fs/inode.c:2177
ext4_write_checks fs/ext4/file.c:264 [inline]
ext4_buffered_write_iter+0x12c/0x294 fs/ext4/file.c:280
ext4_file_write_iter+0x84/0x408 fs/ext4/file.c:700
call_write_iter include/linux/fs.h:2199 [inline]
new_sync_write fs/read_write.c:491 [inline]
vfs_write+0x2dc/0x46c fs/read_write.c:584
ksys_write+0xb4/0x160 fs/read_write.c:637
__do_sys_write fs/read_write.c:649 [inline]
__se_sys_write fs/read_write.c:646 [inline]
__arm64_sys_write+0x24/0x34 fs/read_write.c:646
__invoke_syscall arch/arm64/kernel/syscall.c:38 [inline]
invoke_syscall arch/arm64/kernel/syscall.c:52 [inline]
el0_svc_common+0x138/0x220 arch/arm64/kernel/syscall.c:142
do_el0_svc+0x48/0x140 arch/arm64/kernel/syscall.c:197
el0_svc+0x58/0x150 arch/arm64/kernel/entry-common.c:637
el0t_64_sync_handler+0x84/0xf0 arch/arm64/kernel/entry-common.c:655
el0t_64_sync+0x190/0x194 arch/arm64/kernel/entry.S:584

-> #0 (&sb->s_type->i_mutex_key#8){++++}-{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+0x1530/0x3084 kernel/locking/lockdep.c:5055
lock_acquire+0x100/0x1f8 kernel/locking/lockdep.c:5668
down_write+0x5c/0x88 kernel/locking/rwsem.c:1562
inode_lock include/linux/fs.h:756 [inline]
ext4_xattr_inode_create fs/ext4/xattr.c:1453 [inline]
ext4_xattr_inode_lookup_create fs/ext4/xattr.c:1536 [inline]
ext4_xattr_set_entry+0xdbc/0xe00 fs/ext4/xattr.c:1664
ext4_xattr_ibody_set+0x94/0x184 fs/ext4/xattr.c:2224
ext4_xattr_set_handle+0x648/0x9a0 fs/ext4/xattr.c:2381
ext4_xattr_set+0x100/0x1d0 fs/ext4/xattr.c:2495
ext4_xattr_trusted_set+0x4c/0x64 fs/ext4/xattr_trusted.c:38
__vfs_setxattr+0x250/0x260 fs/xattr.c:182
__vfs_setxattr_noperm+0xcc/0x320 fs/xattr.c:216
__vfs_setxattr_locked+0x16c/0x194 fs/xattr.c:277
vfs_setxattr+0xf4/0x1f4 fs/xattr.c:309
do_setxattr fs/xattr.c:594 [inline]
setxattr fs/xattr.c:617 [inline]
path_setxattr+0x354/0x414 fs/xattr.c:636
__do_sys_lsetxattr fs/xattr.c:659 [inline]
__se_sys_lsetxattr fs/xattr.c:655 [inline]
__arm64_sys_lsetxattr+0x2c/0x40 fs/xattr.c:655
__invoke_syscall arch/arm64/kernel/syscall.c:38 [inline]
invoke_syscall arch/arm64/kernel/syscall.c:52 [inline]
el0_svc_common+0x138/0x220 arch/arm64/kernel/syscall.c:142
do_el0_svc+0x48/0x140 arch/arm64/kernel/syscall.c:197
el0_svc+0x58/0x150 arch/arm64/kernel/entry-common.c:637
el0t_64_sync_handler+0x84/0xf0 arch/arm64/kernel/entry-common.c:655
el0t_64_sync+0x190/0x194 arch/arm64/kernel/entry.S:584

other info that might help us debug this:

Possible unsafe locking scenario:

CPU0 CPU1
---- ----
lock(&ei->xattr_sem);
lock(&sb->s_type->i_mutex_key#8);
lock(&ei->xattr_sem);
lock(&sb->s_type->i_mutex_key#8);

*** DEADLOCK ***

3 locks held by syz-executor.0/3668:
#0: ffff0000c9dee460 (sb_writers#3){.+.+}-{0:0}, at: mnt_want_write+0x20/0x64 fs/namespace.c:393
#1: ffff0000cf16b3d0 (&type->i_mutex_dir_key#3){++++}-{3:3}, at: inode_lock include/linux/fs.h:756 [inline]
#1: ffff0000cf16b3d0 (&type->i_mutex_dir_key#3){++++}-{3:3}, at: vfs_setxattr+0xd4/0x1f4 fs/xattr.c:308
#2: ffff0000cf16b098 (&ei->xattr_sem){++++}-{3:3}, at: ext4_write_lock_xattr fs/ext4/xattr.h:155 [inline]
#2: ffff0000cf16b098 (&ei->xattr_sem){++++}-{3:3}, at: ext4_xattr_set_handle+0xd0/0x9a0 fs/ext4/xattr.c:2308

stack backtrace:
CPU: 1 PID: 3668 Comm: syz-executor.0 Not tainted 6.1.0-rc8-syzkaller-00172-ga5541c0811a0-dirty #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 10/26/2022
Call trace:
dump_backtrace+0x1c4/0x1f0 arch/arm64/kernel/stacktrace.c:156
show_stack+0x2c/0x3c arch/arm64/kernel/stacktrace.c:163
__dump_stack lib/dump_stack.c:88 [inline]
dump_stack_lvl+0x104/0x16c lib/dump_stack.c:106
dump_stack+0x1c/0x58 lib/dump_stack.c:113
print_circular_bug+0x2c4/0x2c8 kernel/locking/lockdep.c:2055
check_noncircular+0x14c/0x154 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+0x1530/0x3084 kernel/locking/lockdep.c:5055
lock_acquire+0x100/0x1f8 kernel/locking/lockdep.c:5668
down_write+0x5c/0x88 kernel/locking/rwsem.c:1562
inode_lock include/linux/fs.h:756 [inline]
ext4_xattr_inode_create fs/ext4/xattr.c:1453 [inline]
ext4_xattr_inode_lookup_create fs/ext4/xattr.c:1536 [inline]
ext4_xattr_set_entry+0xdbc/0xe00 fs/ext4/xattr.c:1664
ext4_xattr_ibody_set+0x94/0x184 fs/ext4/xattr.c:2224
ext4_xattr_set_handle+0x648/0x9a0 fs/ext4/xattr.c:2381
ext4_xattr_set+0x100/0x1d0 fs/ext4/xattr.c:2495
ext4_xattr_trusted_set+0x4c/0x64 fs/ext4/xattr_trusted.c:38
__vfs_setxattr+0x250/0x260 fs/xattr.c:182
__vfs_setxattr_noperm+0xcc/0x320 fs/xattr.c:216
__vfs_setxattr_locked+0x16c/0x194 fs/xattr.c:277
vfs_setxattr+0xf4/0x1f4 fs/xattr.c:309
do_setxattr fs/xattr.c:594 [inline]
setxattr fs/xattr.c:617 [inline]
path_setxattr+0x354/0x414 fs/xattr.c:636
__do_sys_lsetxattr fs/xattr.c:659 [inline]
__se_sys_lsetxattr fs/xattr.c:655 [inline]
__arm64_sys_lsetxattr+0x2c/0x40 fs/xattr.c:655
__invoke_syscall arch/arm64/kernel/syscall.c:38 [inline]
invoke_syscall arch/arm64/kernel/syscall.c:52 [inline]
el0_svc_common+0x138/0x220 arch/arm64/kernel/syscall.c:142
do_el0_svc+0x48/0x140 arch/arm64/kernel/syscall.c:197
el0_svc+0x58/0x150 arch/arm64/kernel/entry-common.c:637
el0t_64_sync_handler+0x84/0xf0 arch/arm64/kernel/entry-common.c:655
el0t_64_sync+0x190/0x194 arch/arm64/kernel/entry.S:584


Tested on:

commit: a5541c08 Merge branch 'for-next/core' into for-kernelci
git tree: https://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git
console output: https://syzkaller.appspot.com/x/log.txt?x=16f5d4bc480000
kernel config: https://syzkaller.appspot.com/x/.config?x=cbd4e584773e9397
dashboard link: https://syzkaller.appspot.com/bug?extid=d3bb749184481f92deb5
compiler: Debian clang version 13.0.1-++20220126092033+75e33f71c2da-1~exp1~20220126212112.63, GNU ld (GNU Binutils for Debian) 2.35.2
userspace arch: arm64
patch: https://syzkaller.appspot.com/x/patch.diff?x=15be6de4480000

Hillf Danton

no leída,
29 dic 2022, 4:37:1029/12/22
a syzbot,linux-...@vger.kernel.org,syzkall...@googlegroups.com
On 27 Dec 2022 23:59:37 -0800
> syzbot found the following issue on:
>
> HEAD commit: a5541c0811a0 Merge branch 'for-next/core' into for-kernelci
> git tree: git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git for-kernelci
> C reproducer: https://syzkaller.appspot.com/x/repro.c?x=161e81b0480000

See if lock key can make a difference.

#syz test https://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git a5541c0811a0

--- x/fs/ext4/xattr.c
+++ y/fs/ext4/xattr.c
@@ -123,7 +123,8 @@ ext4_expand_inode_array(struct ext4_xatt
#ifdef CONFIG_LOCKDEP
void ext4_xattr_inode_set_class(struct inode *ea_inode)
{
- lockdep_set_subclass(&ea_inode->i_rwsem, 1);
+ lockdep_register_key(&ea_inode->i_lockkey);
+ lockdep_set_class(&ea_inode->i_rwsem, &ea_inode->i_lockkey);
}
#endif

--- x/include/linux/fs.h
+++ y/include/linux/fs.h
@@ -695,6 +695,7 @@ struct inode {
struct fscrypt_info *i_crypt_info;
#endif

+ struct lock_class_key i_lockkey;
#ifdef CONFIG_FS_VERITY
struct fsverity_info *i_verity_info;
#endif
--

syzbot

no leída,
29 dic 2022, 4:52:2029/12/22
a hda...@sina.com,linux-...@vger.kernel.org,syzkall...@googlegroups.com
Hello,

syzbot has tested the proposed patch but the reproducer is still triggering an issue:
possible deadlock in ext4_find_inline_entry

EXT4-fs: Warning: mounting with an experimental mount option 'dioread_nolock' for blocksize < PAGE_SIZE
EXT4-fs (loop0): mounted filesystem without journal. Quota mode: none.
======================================================
WARNING: possible circular locking dependency detected
6.1.0-rc8-syzkaller-00172-ga5541c0811a0-dirty #0 Not tainted
------------------------------------------------------
syz-executor.0/3645 is trying to acquire lock:
ffff0000caafc428 (&ei->xattr_sem){++++}-{3:3}, at: ext4_find_inline_entry+0x80/0x224 fs/ext4/inline.c:1690

but task is already holding lock:
ffff0000caafbdc0 (&ea_inode->i_lockkey){+.+.}-{3:3}, at: inode_lock include/linux/fs.h:757 [inline]
ffff0000caafbdc0 (&ea_inode->i_lockkey){+.+.}-{3:3}, at: vfs_unlink+0x78/0x300 fs/namei.c:4241

which lock already depends on the new lock.


the existing dependency chain (in reverse order) is:

-> #1 (&ea_inode->i_lockkey){+.+.}-{3:3}:
down_write+0x5c/0x88 kernel/locking/rwsem.c:1562
inode_lock include/linux/fs.h:757 [inline]
ext4_xattr_inode_create fs/ext4/xattr.c:1455 [inline]
ext4_xattr_inode_lookup_create fs/ext4/xattr.c:1538 [inline]
ext4_xattr_set_entry+0xdf0/0xe34 fs/ext4/xattr.c:1666
ext4_xattr_ibody_set+0x94/0x184 fs/ext4/xattr.c:2226
ext4_xattr_set_handle+0x648/0x9a0 fs/ext4/xattr.c:2383
ext4_xattr_set+0x100/0x1d0 fs/ext4/xattr.c:2497
ext4_xattr_trusted_set+0x4c/0x64 fs/ext4/xattr_trusted.c:38
__vfs_setxattr+0x250/0x260 fs/xattr.c:182
__vfs_setxattr_noperm+0xcc/0x320 fs/xattr.c:216
__vfs_setxattr_locked+0x16c/0x194 fs/xattr.c:277
vfs_setxattr+0xf4/0x1f4 fs/xattr.c:309
do_setxattr fs/xattr.c:594 [inline]
setxattr fs/xattr.c:617 [inline]
path_setxattr+0x354/0x414 fs/xattr.c:636
__do_sys_lsetxattr fs/xattr.c:659 [inline]
__se_sys_lsetxattr fs/xattr.c:655 [inline]
__arm64_sys_lsetxattr+0x2c/0x40 fs/xattr.c:655
__invoke_syscall arch/arm64/kernel/syscall.c:38 [inline]
invoke_syscall arch/arm64/kernel/syscall.c:52 [inline]
el0_svc_common+0x138/0x220 arch/arm64/kernel/syscall.c:142
do_el0_svc+0x48/0x140 arch/arm64/kernel/syscall.c:197
el0_svc+0x58/0x150 arch/arm64/kernel/entry-common.c:637
el0t_64_sync_handler+0x84/0xf0 arch/arm64/kernel/entry-common.c:655
el0t_64_sync+0x190/0x194 arch/arm64/kernel/entry.S:584

-> #0 (&ei->xattr_sem){++++}-{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+0x1530/0x3084 kernel/locking/lockdep.c:5055
lock_acquire+0x100/0x1f8 kernel/locking/lockdep.c:5668
down_read+0x5c/0x78 kernel/locking/rwsem.c:1509
ext4_find_inline_entry+0x80/0x224 fs/ext4/inline.c:1690
__ext4_find_entry+0xe8/0xb4c fs/ext4/namei.c:1596
ext4_find_entry fs/ext4/namei.c:1731 [inline]
__ext4_unlink+0xa8/0x3e4 fs/ext4/namei.c:3215
ext4_unlink+0x150/0x200 fs/ext4/namei.c:3291
vfs_unlink+0x1dc/0x300 fs/namei.c:4252
do_unlinkat+0x200/0x3dc fs/namei.c:4320
__do_sys_unlinkat fs/namei.c:4363 [inline]
__se_sys_unlinkat fs/namei.c:4356 [inline]
__arm64_sys_unlinkat+0x7c/0xa8 fs/namei.c:4356
__invoke_syscall arch/arm64/kernel/syscall.c:38 [inline]
invoke_syscall arch/arm64/kernel/syscall.c:52 [inline]
el0_svc_common+0x138/0x220 arch/arm64/kernel/syscall.c:142
do_el0_svc+0x48/0x140 arch/arm64/kernel/syscall.c:197
el0_svc+0x58/0x150 arch/arm64/kernel/entry-common.c:637
el0t_64_sync_handler+0x84/0xf0 arch/arm64/kernel/entry-common.c:655
el0t_64_sync+0x190/0x194 arch/arm64/kernel/entry.S:584

other info that might help us debug this:

Possible unsafe locking scenario:

CPU0 CPU1
---- ----
lock(&ea_inode->i_lockkey);
lock(&ei->xattr_sem);
lock(&ea_inode->i_lockkey);
lock(&ei->xattr_sem);

*** DEADLOCK ***

3 locks held by syz-executor.0/3645:
#0: ffff0000cba7a460 (sb_writers#3){.+.+}-{0:0}, at: mnt_want_write+0x20/0x64 fs/namespace.c:393
#1: ffff0000caafc760 (&type->i_mutex_dir_key#3/1){+.+.}-{3:3}, at: inode_lock_nested include/linux/fs.h:792 [inline]
#1: ffff0000caafc760 (&type->i_mutex_dir_key#3/1){+.+.}-{3:3}, at: do_unlinkat+0xf0/0x3dc fs/namei.c:4303
#2: ffff0000caafbdc0 (&ea_inode->i_lockkey){+.+.}-{3:3}, at: inode_lock include/linux/fs.h:757 [inline]
#2: ffff0000caafbdc0 (&ea_inode->i_lockkey){+.+.}-{3:3}, at: vfs_unlink+0x78/0x300 fs/namei.c:4241

stack backtrace:
CPU: 1 PID: 3645 Comm: syz-executor.0 Not tainted 6.1.0-rc8-syzkaller-00172-ga5541c0811a0-dirty #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 10/26/2022
Call trace:
dump_backtrace+0x1c4/0x1f0 arch/arm64/kernel/stacktrace.c:156
show_stack+0x2c/0x3c arch/arm64/kernel/stacktrace.c:163
__dump_stack lib/dump_stack.c:88 [inline]
dump_stack_lvl+0x104/0x16c lib/dump_stack.c:106
dump_stack+0x1c/0x58 lib/dump_stack.c:113
print_circular_bug+0x2c4/0x2c8 kernel/locking/lockdep.c:2055
check_noncircular+0x14c/0x154 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+0x1530/0x3084 kernel/locking/lockdep.c:5055
lock_acquire+0x100/0x1f8 kernel/locking/lockdep.c:5668
down_read+0x5c/0x78 kernel/locking/rwsem.c:1509
ext4_find_inline_entry+0x80/0x224 fs/ext4/inline.c:1690
__ext4_find_entry+0xe8/0xb4c fs/ext4/namei.c:1596
ext4_find_entry fs/ext4/namei.c:1731 [inline]
__ext4_unlink+0xa8/0x3e4 fs/ext4/namei.c:3215
ext4_unlink+0x150/0x200 fs/ext4/namei.c:3291
vfs_unlink+0x1dc/0x300 fs/namei.c:4252
do_unlinkat+0x200/0x3dc fs/namei.c:4320
__do_sys_unlinkat fs/namei.c:4363 [inline]
__se_sys_unlinkat fs/namei.c:4356 [inline]
__arm64_sys_unlinkat+0x7c/0xa8 fs/namei.c:4356
__invoke_syscall arch/arm64/kernel/syscall.c:38 [inline]
invoke_syscall arch/arm64/kernel/syscall.c:52 [inline]
el0_svc_common+0x138/0x220 arch/arm64/kernel/syscall.c:142
do_el0_svc+0x48/0x140 arch/arm64/kernel/syscall.c:197
el0_svc+0x58/0x150 arch/arm64/kernel/entry-common.c:637
el0t_64_sync_handler+0x84/0xf0 arch/arm64/kernel/entry-common.c:655
el0t_64_sync+0x190/0x194 arch/arm64/kernel/entry.S:584


Tested on:

commit: a5541c08 Merge branch 'for-next/core' into for-kernelci
git tree: https://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git
console output: https://syzkaller.appspot.com/x/log.txt?x=12e927f8480000
kernel config: https://syzkaller.appspot.com/x/.config?x=cbd4e584773e9397
dashboard link: https://syzkaller.appspot.com/bug?extid=d3bb749184481f92deb5
compiler: Debian clang version 13.0.1-++20220126092033+75e33f71c2da-1~exp1~20220126212112.63, GNU ld (GNU Binutils for Debian) 2.35.2
userspace arch: arm64
patch: https://syzkaller.appspot.com/x/patch.diff?x=14e927f8480000

syzbot

no leída,
1 ago 2023, 4:49:481/8/23
a syzkall...@googlegroups.com
Auto-closing this bug as obsolete.
No recent activity, existing reproducers are no longer triggering the issue.
Responder a todos
Responder al autor
Reenviar
0 mensajes nuevos