[v5.15] possible deadlock in hfsplus_file_extend

0 views
Skip to first unread message

syzbot

unread,
Mar 11, 2023, 12:12:46 PM3/11/23
to syzkaller...@googlegroups.com
Hello,

syzbot found the following issue on:

HEAD commit: d214f240b0f6 Linux 5.15.100
git tree: linux-5.15.y
console output: https://syzkaller.appspot.com/x/log.txt?x=1632ecdac80000
kernel config: https://syzkaller.appspot.com/x/.config?x=2ce2e44a77402c69
dashboard link: https://syzkaller.appspot.com/bug?extid=355de36ace0d0601982f
compiler: Debian clang version 15.0.7, GNU ld (GNU Binutils for Debian) 2.35.2
userspace arch: arm64

Unfortunately, I don't have any reproducer for this issue yet.

Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/16b7e741b1bc/disk-d214f240.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/d659bc0db8bc/vmlinux-d214f240.xz
kernel image: https://storage.googleapis.com/syzbot-assets/64813dcb1631/Image-d214f240.gz.xz

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

======================================================
WARNING: possible circular locking dependency detected
5.15.100-syzkaller #0 Not tainted
------------------------------------------------------
syz-executor.2/12172 is trying to acquire lock:
ffff0000ce9c0e88 (&HFSPLUS_I(inode)->extents_lock){+.+.}-{3:3}, at: hfsplus_file_extend+0x198/0x14e0 fs/hfsplus/extents.c:457

but task is already holding lock:
ffff0000ccdd60b0 (&tree->tree_lock#2/2){+.+.}-{3:3}, at: hfsplus_find_init+0x144/0x1bc

which lock already depends on the new lock.


the existing dependency chain (in reverse order) is:

-> #2 (&tree->tree_lock#2/2){+.+.}-{3:3}:
__mutex_lock_common+0x194/0x2154 kernel/locking/mutex.c:596
__mutex_lock kernel/locking/mutex.c:729 [inline]
mutex_lock_nested+0xa4/0xf8 kernel/locking/mutex.c:743
hfsplus_find_init+0x144/0x1bc
hfsplus_attr_exists+0xf8/0x1c8 fs/hfsplus/attributes.c:178
__hfsplus_setxattr+0x384/0x1df0 fs/hfsplus/xattr.c:336
hfsplus_setxattr+0xb4/0xec fs/hfsplus/xattr.c:434
hfsplus_user_setxattr+0x54/0x6c fs/hfsplus/xattr_user.c:30
__vfs_setxattr+0x388/0x3a4 fs/xattr.c:182
__vfs_setxattr_noperm+0x110/0x528 fs/xattr.c:216
__vfs_setxattr_locked+0x1ec/0x218 fs/xattr.c:277
vfs_setxattr+0x1a8/0x344 fs/xattr.c:303
do_setxattr fs/xattr.c:588 [inline]
setxattr+0x250/0x2b4 fs/xattr.c:611
path_setxattr+0x17c/0x258 fs/xattr.c:630
__do_sys_setxattr fs/xattr.c:646 [inline]
__se_sys_setxattr fs/xattr.c:642 [inline]
__arm64_sys_setxattr+0xbc/0xd8 fs/xattr.c:642
__invoke_syscall arch/arm64/kernel/syscall.c:38 [inline]
invoke_syscall+0x98/0x2b8 arch/arm64/kernel/syscall.c:52
el0_svc_common+0x138/0x258 arch/arm64/kernel/syscall.c:142
do_el0_svc+0x58/0x14c arch/arm64/kernel/syscall.c:181
el0_svc+0x7c/0x1f0 arch/arm64/kernel/entry-common.c:596
el0t_64_sync_handler+0x84/0xe4 arch/arm64/kernel/entry-common.c:614
el0t_64_sync+0x1a0/0x1a4 <unknown>:584

-> #1 (&tree->tree_lock#2){+.+.}-{3:3}:
__mutex_lock_common+0x194/0x2154 kernel/locking/mutex.c:596
__mutex_lock kernel/locking/mutex.c:729 [inline]
mutex_lock_nested+0xa4/0xf8 kernel/locking/mutex.c:743
hfsplus_file_truncate+0x6d4/0x9cc fs/hfsplus/extents.c:595
hfsplus_setattr+0x18c/0x25c fs/hfsplus/inode.c:267
notify_change+0xae4/0xd80 fs/attr.c:426
do_truncate+0x1bc/0x288 fs/open.c:65
handle_truncate fs/namei.c:3136 [inline]
do_open fs/namei.c:3484 [inline]
path_openat+0x20c4/0x26cc fs/namei.c:3615
do_filp_open+0x1a8/0x3b4 fs/namei.c:3642
do_sys_openat2+0x128/0x3d8 fs/open.c:1211
do_sys_open fs/open.c:1227 [inline]
__do_sys_openat fs/open.c:1243 [inline]
__se_sys_openat fs/open.c:1238 [inline]
__arm64_sys_openat+0x1f0/0x240 fs/open.c:1238
__invoke_syscall arch/arm64/kernel/syscall.c:38 [inline]
invoke_syscall+0x98/0x2b8 arch/arm64/kernel/syscall.c:52
el0_svc_common+0x138/0x258 arch/arm64/kernel/syscall.c:142
do_el0_svc+0x58/0x14c arch/arm64/kernel/syscall.c:181
el0_svc+0x7c/0x1f0 arch/arm64/kernel/entry-common.c:596
el0t_64_sync_handler+0x84/0xe4 arch/arm64/kernel/entry-common.c:614
el0t_64_sync+0x1a0/0x1a4 <unknown>:584

-> #0 (&HFSPLUS_I(inode)->extents_lock){+.+.}-{3:3}:
check_prev_add kernel/locking/lockdep.c:3053 [inline]
check_prevs_add kernel/locking/lockdep.c:3172 [inline]
validate_chain kernel/locking/lockdep.c:3787 [inline]
__lock_acquire+0x32cc/0x7620 kernel/locking/lockdep.c:5011
lock_acquire+0x2c0/0x89c kernel/locking/lockdep.c:5622
__mutex_lock_common+0x194/0x2154 kernel/locking/mutex.c:596
__mutex_lock kernel/locking/mutex.c:729 [inline]
mutex_lock_nested+0xa4/0xf8 kernel/locking/mutex.c:743
hfsplus_file_extend+0x198/0x14e0 fs/hfsplus/extents.c:457
hfsplus_bmap_reserve+0xec/0x474 fs/hfsplus/btree.c:357
hfsplus_create_attr+0x1b0/0x568 fs/hfsplus/attributes.c:221
__hfsplus_setxattr+0x9a8/0x1df0 fs/hfsplus/xattr.c:354
hfsplus_setxattr+0xb4/0xec fs/hfsplus/xattr.c:434
hfsplus_user_setxattr+0x54/0x6c fs/hfsplus/xattr_user.c:30
__vfs_setxattr+0x388/0x3a4 fs/xattr.c:182
__vfs_setxattr_noperm+0x110/0x528 fs/xattr.c:216
__vfs_setxattr_locked+0x1ec/0x218 fs/xattr.c:277
vfs_setxattr+0x1a8/0x344 fs/xattr.c:303
do_setxattr fs/xattr.c:588 [inline]
setxattr+0x250/0x2b4 fs/xattr.c:611
path_setxattr+0x17c/0x258 fs/xattr.c:630
__do_sys_setxattr fs/xattr.c:646 [inline]
__se_sys_setxattr fs/xattr.c:642 [inline]
__arm64_sys_setxattr+0xbc/0xd8 fs/xattr.c:642
__invoke_syscall arch/arm64/kernel/syscall.c:38 [inline]
invoke_syscall+0x98/0x2b8 arch/arm64/kernel/syscall.c:52
el0_svc_common+0x138/0x258 arch/arm64/kernel/syscall.c:142
do_el0_svc+0x58/0x14c arch/arm64/kernel/syscall.c:181
el0_svc+0x7c/0x1f0 arch/arm64/kernel/entry-common.c:596
el0t_64_sync_handler+0x84/0xe4 arch/arm64/kernel/entry-common.c:614
el0t_64_sync+0x1a0/0x1a4 <unknown>:584

other info that might help us debug this:

Chain exists of:
&HFSPLUS_I(inode)->extents_lock --> &tree->tree_lock#2 --> &tree->tree_lock#2/2

Possible unsafe locking scenario:

CPU0 CPU1
---- ----
lock(&tree->tree_lock#2/2);
lock(&tree->tree_lock#2);
lock(&tree->tree_lock#2/2);
lock(&HFSPLUS_I(inode)->extents_lock);

*** DEADLOCK ***

4 locks held by syz-executor.2/12172:
#0: ffff0000c8fcc460 (sb_writers#22){.+.+}-{0:0}, at: mnt_want_write+0x44/0x9c fs/namespace.c:377
#1: ffff0000ce9c2b80 (&sb->s_type->i_mutex_key#30){+.+.}-{3:3}, at: inode_lock include/linux/fs.h:787 [inline]
#1: ffff0000ce9c2b80 (&sb->s_type->i_mutex_key#30){+.+.}-{3:3}, at: vfs_setxattr+0x17c/0x344 fs/xattr.c:302
#2: ffff0000ccdd00b0 (&tree->tree_lock#2){+.+.}-{3:3}, at: hfsplus_find_init+0x144/0x1bc
#3: ffff0000ccdd60b0 (&tree->tree_lock#2/2){+.+.}-{3:3}, at: hfsplus_find_init+0x144/0x1bc

stack backtrace:
CPU: 1 PID: 12172 Comm: syz-executor.2 Not tainted 5.15.100-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 03/02/2023
Call trace:
dump_backtrace+0x0/0x530 arch/arm64/kernel/stacktrace.c:152
show_stack+0x2c/0x3c arch/arm64/kernel/stacktrace.c:216
__dump_stack lib/dump_stack.c:88 [inline]
dump_stack_lvl+0x108/0x170 lib/dump_stack.c:106
dump_stack+0x1c/0x58 lib/dump_stack.c:113
print_circular_bug+0x150/0x1b8 kernel/locking/lockdep.c:2011
check_noncircular+0x2cc/0x378 kernel/locking/lockdep.c:2133
check_prev_add kernel/locking/lockdep.c:3053 [inline]
check_prevs_add kernel/locking/lockdep.c:3172 [inline]
validate_chain kernel/locking/lockdep.c:3787 [inline]
__lock_acquire+0x32cc/0x7620 kernel/locking/lockdep.c:5011
lock_acquire+0x2c0/0x89c kernel/locking/lockdep.c:5622
__mutex_lock_common+0x194/0x2154 kernel/locking/mutex.c:596
__mutex_lock kernel/locking/mutex.c:729 [inline]
mutex_lock_nested+0xa4/0xf8 kernel/locking/mutex.c:743
hfsplus_file_extend+0x198/0x14e0 fs/hfsplus/extents.c:457
hfsplus_bmap_reserve+0xec/0x474 fs/hfsplus/btree.c:357
hfsplus_create_attr+0x1b0/0x568 fs/hfsplus/attributes.c:221
__hfsplus_setxattr+0x9a8/0x1df0 fs/hfsplus/xattr.c:354
hfsplus_setxattr+0xb4/0xec fs/hfsplus/xattr.c:434
hfsplus_user_setxattr+0x54/0x6c fs/hfsplus/xattr_user.c:30
__vfs_setxattr+0x388/0x3a4 fs/xattr.c:182
__vfs_setxattr_noperm+0x110/0x528 fs/xattr.c:216
__vfs_setxattr_locked+0x1ec/0x218 fs/xattr.c:277
vfs_setxattr+0x1a8/0x344 fs/xattr.c:303
do_setxattr fs/xattr.c:588 [inline]
setxattr+0x250/0x2b4 fs/xattr.c:611
path_setxattr+0x17c/0x258 fs/xattr.c:630
__do_sys_setxattr fs/xattr.c:646 [inline]
__se_sys_setxattr fs/xattr.c:642 [inline]
__arm64_sys_setxattr+0xbc/0xd8 fs/xattr.c:642
__invoke_syscall arch/arm64/kernel/syscall.c:38 [inline]
invoke_syscall+0x98/0x2b8 arch/arm64/kernel/syscall.c:52
el0_svc_common+0x138/0x258 arch/arm64/kernel/syscall.c:142
do_el0_svc+0x58/0x14c arch/arm64/kernel/syscall.c:181
el0_svc+0x7c/0x1f0 arch/arm64/kernel/entry-common.c:596
el0t_64_sync_handler+0x84/0xe4 arch/arm64/kernel/entry-common.c:614
el0t_64_sync+0x1a0/0x1a4 <unknown>: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

unread,
Mar 13, 2023, 10:24:50 AM3/13/23
to syzkaller...@googlegroups.com
Hello,

syzbot found the following issue on:

HEAD commit: 6449a0ba6843 Linux 6.1.19
git tree: linux-6.1.y
console output: https://syzkaller.appspot.com/x/log.txt?x=15f4ce52c80000
kernel config: https://syzkaller.appspot.com/x/.config?x=75eadb21ef1208e4
dashboard link: https://syzkaller.appspot.com/bug?extid=a9b05956c6ee2e5563cb
compiler: Debian clang version 15.0.7, GNU ld (GNU Binutils for Debian) 2.35.2
userspace arch: arm64

Unfortunately, I don't have any reproducer for this issue yet.

Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/dc227ecd3e21/disk-6449a0ba.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/1d08e21b50c2/vmlinux-6449a0ba.xz
kernel image: https://storage.googleapis.com/syzbot-assets/71a43f2c4d2c/Image-6449a0ba.gz.xz

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

======================================================
WARNING: possible circular locking dependency detected
6.1.19-syzkaller #0 Not tainted
------------------------------------------------------
syz-executor.4/15033 is trying to acquire lock:
ffff0000d71eb708 (&HFSPLUS_I(inode)->extents_lock){+.+.}-{3:3}, at: hfsplus_file_extend+0x198/0x14cc fs/hfsplus/extents.c:457

but task is already holding lock:
ffff0000cf8340b0 (&tree->tree_lock#2/2){+.+.}-{3:3}, at: hfsplus_find_init+0x144/0x1bc

which lock already depends on the new lock.


the existing dependency chain (in reverse order) is:

-> #2 (&tree->tree_lock#2/2){+.+.}-{3:3}:
__mutex_lock_common+0x190/0x21a0 kernel/locking/mutex.c:603
__mutex_lock kernel/locking/mutex.c:747 [inline]
mutex_lock_nested+0x38/0x44 kernel/locking/mutex.c:799
hfsplus_find_init+0x144/0x1bc
hfsplus_attr_exists+0xf8/0x1c8 fs/hfsplus/attributes.c:178
__hfsplus_setxattr+0x384/0x1d10 fs/hfsplus/xattr.c:336
hfsplus_setxattr+0xb4/0xec fs/hfsplus/xattr.c:434
hfsplus_user_setxattr+0x54/0x6c fs/hfsplus/xattr_user.c:30
__vfs_setxattr+0x388/0x3a4 fs/xattr.c:182
__vfs_setxattr_noperm+0x110/0x528 fs/xattr.c:216
__vfs_setxattr_locked+0x1ec/0x218 fs/xattr.c:277
vfs_setxattr+0x1a8/0x344 fs/xattr.c:309
do_setxattr fs/xattr.c:594 [inline]
setxattr+0x230/0x294 fs/xattr.c:617
path_setxattr+0x17c/0x258 fs/xattr.c:636
__do_sys_setxattr fs/xattr.c:652 [inline]
__se_sys_setxattr fs/xattr.c:648 [inline]
__arm64_sys_setxattr+0xbc/0xd8 fs/xattr.c:648
__invoke_syscall arch/arm64/kernel/syscall.c:38 [inline]
invoke_syscall+0x98/0x2c0 arch/arm64/kernel/syscall.c:52
el0_svc_common+0x138/0x258 arch/arm64/kernel/syscall.c:142
do_el0_svc+0x64/0x218 arch/arm64/kernel/syscall.c:206
el0_svc+0x58/0x168 arch/arm64/kernel/entry-common.c:637
el0t_64_sync_handler+0x84/0xf0 arch/arm64/kernel/entry-common.c:655
el0t_64_sync+0x18c/0x190 arch/arm64/kernel/entry.S:581

-> #1 (&tree->tree_lock#2){+.+.}-{3:3}:
__mutex_lock_common+0x190/0x21a0 kernel/locking/mutex.c:603
__mutex_lock kernel/locking/mutex.c:747 [inline]
mutex_lock_nested+0x38/0x44 kernel/locking/mutex.c:799
hfsplus_file_truncate+0x6d0/0x9b8 fs/hfsplus/extents.c:595
hfsplus_setattr+0x18c/0x25c fs/hfsplus/inode.c:269
notify_change+0xc24/0xec0 fs/attr.c:482
do_truncate+0x1c0/0x28c fs/open.c:65
vfs_truncate+0x2c4/0x36c fs/open.c:111
do_sys_truncate+0xec/0x1b4 fs/open.c:134
__do_sys_truncate fs/open.c:146 [inline]
__se_sys_truncate fs/open.c:144 [inline]
__arm64_sys_truncate+0x5c/0x70 fs/open.c:144
__invoke_syscall arch/arm64/kernel/syscall.c:38 [inline]
invoke_syscall+0x98/0x2c0 arch/arm64/kernel/syscall.c:52
el0_svc_common+0x138/0x258 arch/arm64/kernel/syscall.c:142
do_el0_svc+0x64/0x218 arch/arm64/kernel/syscall.c:206
el0_svc+0x58/0x168 arch/arm64/kernel/entry-common.c:637
el0t_64_sync_handler+0x84/0xf0 arch/arm64/kernel/entry-common.c:655
el0t_64_sync+0x18c/0x190 arch/arm64/kernel/entry.S:581

-> #0 (&HFSPLUS_I(inode)->extents_lock){+.+.}-{3:3}:
check_prev_add kernel/locking/lockdep.c:3098 [inline]
check_prevs_add kernel/locking/lockdep.c:3217 [inline]
validate_chain kernel/locking/lockdep.c:3832 [inline]
__lock_acquire+0x3338/0x764c kernel/locking/lockdep.c:5056
lock_acquire+0x300/0x8e4 kernel/locking/lockdep.c:5669
__mutex_lock_common+0x190/0x21a0 kernel/locking/mutex.c:603
__mutex_lock kernel/locking/mutex.c:747 [inline]
mutex_lock_nested+0x38/0x44 kernel/locking/mutex.c:799
hfsplus_file_extend+0x198/0x14cc fs/hfsplus/extents.c:457
hfsplus_bmap_reserve+0xec/0x474 fs/hfsplus/btree.c:358
hfsplus_create_attr+0x1b0/0x568 fs/hfsplus/attributes.c:221
__hfsplus_setxattr+0x990/0x1d10 fs/hfsplus/xattr.c:354
hfsplus_setxattr+0xb4/0xec fs/hfsplus/xattr.c:434
hfsplus_user_setxattr+0x54/0x6c fs/hfsplus/xattr_user.c:30
__vfs_setxattr+0x388/0x3a4 fs/xattr.c:182
__vfs_setxattr_noperm+0x110/0x528 fs/xattr.c:216
__vfs_setxattr_locked+0x1ec/0x218 fs/xattr.c:277
vfs_setxattr+0x1a8/0x344 fs/xattr.c:309
do_setxattr fs/xattr.c:594 [inline]
setxattr+0x230/0x294 fs/xattr.c:617
path_setxattr+0x17c/0x258 fs/xattr.c:636
__do_sys_setxattr fs/xattr.c:652 [inline]
__se_sys_setxattr fs/xattr.c:648 [inline]
__arm64_sys_setxattr+0xbc/0xd8 fs/xattr.c:648
__invoke_syscall arch/arm64/kernel/syscall.c:38 [inline]
invoke_syscall+0x98/0x2c0 arch/arm64/kernel/syscall.c:52
el0_svc_common+0x138/0x258 arch/arm64/kernel/syscall.c:142
do_el0_svc+0x64/0x218 arch/arm64/kernel/syscall.c:206
el0_svc+0x58/0x168 arch/arm64/kernel/entry-common.c:637
el0t_64_sync_handler+0x84/0xf0 arch/arm64/kernel/entry-common.c:655
el0t_64_sync+0x18c/0x190 arch/arm64/kernel/entry.S:581

other info that might help us debug this:

Chain exists of:
&HFSPLUS_I(inode)->extents_lock --> &tree->tree_lock#2 --> &tree->tree_lock#2/2

Possible unsafe locking scenario:

CPU0 CPU1
---- ----
lock(&tree->tree_lock#2/2);
lock(&tree->tree_lock#2);
lock(&tree->tree_lock#2/2);
lock(&HFSPLUS_I(inode)->extents_lock);

*** DEADLOCK ***

4 locks held by syz-executor.4/15033:
#0: ffff0000d9cd6460 (sb_writers#30){.+.+}-{0:0}, at: mnt_want_write+0x44/0x9c fs/namespace.c:393
#1: ffff0000d71ec680 (&sb->s_type->i_mutex_key#34){+.+.}-{3:3}, at: inode_lock include/linux/fs.h:756 [inline]
#1: ffff0000d71ec680 (&sb->s_type->i_mutex_key#34){+.+.}-{3:3}, at: vfs_setxattr+0x17c/0x344 fs/xattr.c:308
#2: ffff0000c81c40b0 (&tree->tree_lock#2){+.+.}-{3:3}, at: hfsplus_find_init+0x144/0x1bc
#3: ffff0000cf8340b0 (&tree->tree_lock#2/2){+.+.}-{3:3}, at: hfsplus_find_init+0x144/0x1bc

stack backtrace:
CPU: 0 PID: 15033 Comm: syz-executor.4 Not tainted 6.1.19-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 03/02/2023
Call trace:
dump_backtrace+0x1c8/0x1f4 arch/arm64/kernel/stacktrace.c:158
show_stack+0x2c/0x3c arch/arm64/kernel/stacktrace.c:165
__dump_stack lib/dump_stack.c:88 [inline]
dump_stack_lvl+0x108/0x170 lib/dump_stack.c:106
dump_stack+0x1c/0x5c lib/dump_stack.c:113
print_circular_bug+0x150/0x1b8 kernel/locking/lockdep.c:2056
check_noncircular+0x2cc/0x378 kernel/locking/lockdep.c:2178
check_prev_add kernel/locking/lockdep.c:3098 [inline]
check_prevs_add kernel/locking/lockdep.c:3217 [inline]
validate_chain kernel/locking/lockdep.c:3832 [inline]
__lock_acquire+0x3338/0x764c kernel/locking/lockdep.c:5056
lock_acquire+0x300/0x8e4 kernel/locking/lockdep.c:5669
__mutex_lock_common+0x190/0x21a0 kernel/locking/mutex.c:603
__mutex_lock kernel/locking/mutex.c:747 [inline]
mutex_lock_nested+0x38/0x44 kernel/locking/mutex.c:799
hfsplus_file_extend+0x198/0x14cc fs/hfsplus/extents.c:457
hfsplus_bmap_reserve+0xec/0x474 fs/hfsplus/btree.c:358
hfsplus_create_attr+0x1b0/0x568 fs/hfsplus/attributes.c:221
__hfsplus_setxattr+0x990/0x1d10 fs/hfsplus/xattr.c:354
hfsplus_setxattr+0xb4/0xec fs/hfsplus/xattr.c:434
hfsplus_user_setxattr+0x54/0x6c fs/hfsplus/xattr_user.c:30
__vfs_setxattr+0x388/0x3a4 fs/xattr.c:182
__vfs_setxattr_noperm+0x110/0x528 fs/xattr.c:216
__vfs_setxattr_locked+0x1ec/0x218 fs/xattr.c:277
vfs_setxattr+0x1a8/0x344 fs/xattr.c:309
do_setxattr fs/xattr.c:594 [inline]
setxattr+0x230/0x294 fs/xattr.c:617
path_setxattr+0x17c/0x258 fs/xattr.c:636
__do_sys_setxattr fs/xattr.c:652 [inline]
__se_sys_setxattr fs/xattr.c:648 [inline]
__arm64_sys_setxattr+0xbc/0xd8 fs/xattr.c:648
__invoke_syscall arch/arm64/kernel/syscall.c:38 [inline]
invoke_syscall+0x98/0x2c0 arch/arm64/kernel/syscall.c:52
el0_svc_common+0x138/0x258 arch/arm64/kernel/syscall.c:142
do_el0_svc+0x64/0x218 arch/arm64/kernel/syscall.c:206
el0_svc+0x58/0x168 arch/arm64/kernel/entry-common.c:637
el0t_64_sync_handler+0x84/0xf0 arch/arm64/kernel/entry-common.c:655
el0t_64_sync+0x18c/0x190 arch/arm64/kernel/entry.S:581

syzbot

unread,
Jul 30, 2023, 1:08:48 AM7/30/23
to syzkaller...@googlegroups.com
syzbot has found a reproducer for the following issue on:

HEAD commit: 09996673e313 Linux 5.15.123
git tree: linux-5.15.y
console output: https://syzkaller.appspot.com/x/log.txt?x=1106fdf6a80000
kernel config: https://syzkaller.appspot.com/x/.config?x=b234d12d7c90a2e8
dashboard link: https://syzkaller.appspot.com/bug?extid=355de36ace0d0601982f
compiler: Debian clang version 15.0.6, GNU ld (GNU Binutils for Debian) 2.40
userspace arch: arm64
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=110b8236a80000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=13ad3f31a80000

Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/20ccf0af5ae0/disk-09996673.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/3f784a67f3fb/vmlinux-09996673.xz
kernel image: https://storage.googleapis.com/syzbot-assets/27ac27fd1514/Image-09996673.gz.xz
mounted in repro: https://storage.googleapis.com/syzbot-assets/c89089a524c1/mount_0.gz

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

loop0: detected capacity change from 0 to 1024
======================================================
WARNING: possible circular locking dependency detected
5.15.123-syzkaller #0 Not tainted
------------------------------------------------------
syz-executor399/3961 is trying to acquire lock:
ffff0000c8fb07c8 (&HFSPLUS_I(inode)->extents_lock){+.+.}-{3:3}, at: hfsplus_file_extend+0x198/0x14e0 fs/hfsplus/extents.c:457

but task is already holding lock:
ffff0000d6eda0b0 (&tree->tree_lock){+.+.}-{3:3}, at: hfsplus_find_init+0x144/0x1bc

which lock already depends on the new lock.


the existing dependency chain (in reverse order) is:

-> #1 (&tree->tree_lock){+.+.}-{3:3}:
__mutex_lock_common+0x194/0x2154 kernel/locking/mutex.c:596
__mutex_lock kernel/locking/mutex.c:729 [inline]
mutex_lock_nested+0xa4/0xf8 kernel/locking/mutex.c:743
hfsplus_file_truncate+0x6d4/0x9cc fs/hfsplus/extents.c:595
hfsplus_setattr+0x18c/0x25c fs/hfsplus/inode.c:267
notify_change+0xac4/0xd60 fs/attr.c:488
do_truncate+0x1c0/0x28c fs/open.c:65
handle_truncate fs/namei.c:3195 [inline]
do_open fs/namei.c:3542 [inline]
path_openat+0x20e8/0x26f0 fs/namei.c:3672
do_filp_open+0x1a8/0x3b4 fs/namei.c:3699
do_sys_openat2+0x128/0x3d8 fs/open.c:1211
__do_sys_openat2 fs/open.c:1266 [inline]
__se_sys_openat2 fs/open.c:1246 [inline]
__arm64_sys_openat2+0x2e8/0x370 fs/open.c:1246
__invoke_syscall arch/arm64/kernel/syscall.c:38 [inline]
invoke_syscall+0x98/0x2b8 arch/arm64/kernel/syscall.c:52
el0_svc_common+0x138/0x258 arch/arm64/kernel/syscall.c:142
do_el0_svc+0x58/0x14c arch/arm64/kernel/syscall.c:181
el0_svc+0x7c/0x1f0 arch/arm64/kernel/entry-common.c:596
el0t_64_sync_handler+0x84/0xe4 arch/arm64/kernel/entry-common.c:614
el0t_64_sync+0x1a0/0x1a4 arch/arm64/kernel/entry.S:584

-> #0 (&HFSPLUS_I(inode)->extents_lock){+.+.}-{3:3}:
check_prev_add kernel/locking/lockdep.c:3053 [inline]
check_prevs_add kernel/locking/lockdep.c:3172 [inline]
validate_chain kernel/locking/lockdep.c:3787 [inline]
__lock_acquire+0x32cc/0x7620 kernel/locking/lockdep.c:5011
lock_acquire+0x240/0x77c kernel/locking/lockdep.c:5622
__mutex_lock_common+0x194/0x2154 kernel/locking/mutex.c:596
__mutex_lock kernel/locking/mutex.c:729 [inline]
mutex_lock_nested+0xa4/0xf8 kernel/locking/mutex.c:743
hfsplus_file_extend+0x198/0x14e0 fs/hfsplus/extents.c:457
hfsplus_bmap_reserve+0xec/0x474 fs/hfsplus/btree.c:357
hfsplus_rename_cat+0x1ac/0xf30 fs/hfsplus/catalog.c:456
hfsplus_rename+0x120/0x1b0 fs/hfsplus/dir.c:552
vfs_rename+0x8b8/0xd04 fs/namei.c:4742
do_renameat2+0x980/0x1040 fs/namei.c:4892
__do_sys_renameat2 fs/namei.c:4925 [inline]
__se_sys_renameat2 fs/namei.c:4922 [inline]
__arm64_sys_renameat2+0xe0/0xfc fs/namei.c:4922
__invoke_syscall arch/arm64/kernel/syscall.c:38 [inline]
invoke_syscall+0x98/0x2b8 arch/arm64/kernel/syscall.c:52
el0_svc_common+0x138/0x258 arch/arm64/kernel/syscall.c:142
do_el0_svc+0x58/0x14c arch/arm64/kernel/syscall.c:181
el0_svc+0x7c/0x1f0 arch/arm64/kernel/entry-common.c:596
el0t_64_sync_handler+0x84/0xe4 arch/arm64/kernel/entry-common.c:614
el0t_64_sync+0x1a0/0x1a4 arch/arm64/kernel/entry.S:584

other info that might help us debug this:

Possible unsafe locking scenario:

CPU0 CPU1
---- ----
lock(&tree->tree_lock);
lock(&HFSPLUS_I(inode)->extents_lock);
lock(&tree->tree_lock);
lock(&HFSPLUS_I(inode)->extents_lock);

*** DEADLOCK ***

4 locks held by syz-executor399/3961:
#0: ffff0000c8dfe460 (sb_writers#8){.+.+}-{0:0}, at: mnt_want_write+0x44/0x9c fs/namespace.c:377
#1: ffff0000c8fb1e00 (&type->i_mutex_dir_key#6/1){+.+.}-{3:3}, at: inode_lock_nested include/linux/fs.h:822 [inline]
#1: ffff0000c8fb1e00 (&type->i_mutex_dir_key#6/1){+.+.}-{3:3}, at: lock_rename+0xdc/0x198 fs/namei.c:2967
#2: ffff0000c8fb24c0 (&type->i_mutex_dir_key#6){++++}-{3:3}, at: inode_lock_nested include/linux/fs.h:822 [inline]
#2: ffff0000c8fb24c0 (&type->i_mutex_dir_key#6){++++}-{3:3}, at: lock_two_inodes+0xdc/0x158 fs/inode.c:1063
#3: ffff0000d6eda0b0 (&tree->tree_lock){+.+.}-{3:3}, at: hfsplus_find_init+0x144/0x1bc

stack backtrace:
CPU: 1 PID: 3961 Comm: syz-executor399 Not tainted 5.15.123-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 07/12/2023
Call trace:
dump_backtrace+0x0/0x530 arch/arm64/kernel/stacktrace.c:152
show_stack+0x2c/0x3c arch/arm64/kernel/stacktrace.c:216
__dump_stack lib/dump_stack.c:88 [inline]
dump_stack_lvl+0x108/0x170 lib/dump_stack.c:106
dump_stack+0x1c/0x58 lib/dump_stack.c:113
print_circular_bug+0x150/0x1b8 kernel/locking/lockdep.c:2011
check_noncircular+0x2cc/0x378 kernel/locking/lockdep.c:2133
check_prev_add kernel/locking/lockdep.c:3053 [inline]
check_prevs_add kernel/locking/lockdep.c:3172 [inline]
validate_chain kernel/locking/lockdep.c:3787 [inline]
__lock_acquire+0x32cc/0x7620 kernel/locking/lockdep.c:5011
lock_acquire+0x240/0x77c kernel/locking/lockdep.c:5622
__mutex_lock_common+0x194/0x2154 kernel/locking/mutex.c:596
__mutex_lock kernel/locking/mutex.c:729 [inline]
mutex_lock_nested+0xa4/0xf8 kernel/locking/mutex.c:743
hfsplus_file_extend+0x198/0x14e0 fs/hfsplus/extents.c:457
hfsplus_bmap_reserve+0xec/0x474 fs/hfsplus/btree.c:357
hfsplus_rename_cat+0x1ac/0xf30 fs/hfsplus/catalog.c:456
hfsplus_rename+0x120/0x1b0 fs/hfsplus/dir.c:552
vfs_rename+0x8b8/0xd04 fs/namei.c:4742
do_renameat2+0x980/0x1040 fs/namei.c:4892
__do_sys_renameat2 fs/namei.c:4925 [inline]
__se_sys_renameat2 fs/namei.c:4922 [inline]
__arm64_sys_renameat2+0xe0/0xfc fs/namei.c:4922
__invoke_syscall arch/arm64/kernel/syscall.c:38 [inline]
invoke_syscall+0x98/0x2b8 arch/arm64/kernel/syscall.c:52
el0_svc_common+0x138/0x258 arch/arm64/kernel/syscall.c:142
do_el0_svc+0x58/0x14c arch/arm64/kernel/syscall.c:181
el0_svc+0x7c/0x1f0 arch/arm64/kernel/entry-common.c:596
el0t_64_sync_handler+0x84/0xe4 arch/arm64/kernel/entry-common.c:614
el0t_64_sync+0x1a0/0x1a4 arch/arm64/kernel/entry.S:584


---
If you want syzbot to run the reproducer, reply with:
#syz test: git://repo/address.git branch-or-commit-hash
If you attach or paste a git patch, syzbot will apply it before testing.

syzbot

unread,
Aug 11, 2023, 3:33:06 AM8/11/23
to syzkaller...@googlegroups.com
syzbot has found a reproducer for the following issue on:

HEAD commit: 0a4a7855302d Linux 6.1.44
git tree: linux-6.1.y
console output: https://syzkaller.appspot.com/x/log.txt?x=1284b569a80000
kernel config: https://syzkaller.appspot.com/x/.config?x=84028051951135dc
dashboard link: https://syzkaller.appspot.com/bug?extid=a9b05956c6ee2e5563cb
compiler: Debian clang version 15.0.6, GNU ld (GNU Binutils for Debian) 2.40
userspace arch: arm64
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=129a53aba80000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=14b54363a80000

Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/65ab0a44ad34/disk-0a4a7855.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/114c9dfff65d/vmlinux-0a4a7855.xz
kernel image: https://storage.googleapis.com/syzbot-assets/ed2d74d8cece/Image-0a4a7855.gz.xz
mounted in repro: https://storage.googleapis.com/syzbot-assets/2054f1fe855e/mount_0.gz

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

loop0: detected capacity change from 0 to 1024
======================================================
WARNING: possible circular locking dependency detected
6.1.44-syzkaller #0 Not tainted
------------------------------------------------------
syz-executor205/4218 is trying to acquire lock:
ffff0000de1107c8 (&HFSPLUS_I(inode)->extents_lock){+.+.}-{3:3}, at: hfsplus_file_extend+0x198/0x14cc fs/hfsplus/extents.c:457

but task is already holding lock:
ffff0000de0dc0b0 (&tree->tree_lock){+.+.}-{3:3}, at: hfsplus_find_init+0x144/0x1bc

which lock already depends on the new lock.


the existing dependency chain (in reverse order) is:

-> #1 (&tree->tree_lock){+.+.}-{3:3}:
__mutex_lock_common+0x190/0x21a0 kernel/locking/mutex.c:603
__mutex_lock kernel/locking/mutex.c:747 [inline]
mutex_lock_nested+0x38/0x44 kernel/locking/mutex.c:799
hfsplus_file_truncate+0x6d0/0x9b8 fs/hfsplus/extents.c:595
hfsplus_setattr+0x18c/0x25c fs/hfsplus/inode.c:269
notify_change+0xc24/0xec0 fs/attr.c:482
do_truncate+0x1c0/0x28c fs/open.c:65
handle_truncate fs/namei.c:3216 [inline]
do_open fs/namei.c:3561 [inline]
path_openat+0x1fa0/0x2548 fs/namei.c:3714
do_filp_open+0x1bc/0x3cc fs/namei.c:3741
do_sys_openat2+0x128/0x3d8 fs/open.c:1318
__do_sys_openat2 fs/open.c:1375 [inline]
__se_sys_openat2 fs/open.c:1353 [inline]
__arm64_sys_openat2+0x308/0x3b8 fs/open.c:1353
__invoke_syscall arch/arm64/kernel/syscall.c:38 [inline]
invoke_syscall+0x98/0x2c0 arch/arm64/kernel/syscall.c:52
el0_svc_common+0x138/0x258 arch/arm64/kernel/syscall.c:142
do_el0_svc+0x64/0x218 arch/arm64/kernel/syscall.c:206
el0_svc+0x58/0x168 arch/arm64/kernel/entry-common.c:637
el0t_64_sync_handler+0x84/0xf0 arch/arm64/kernel/entry-common.c:655
el0t_64_sync+0x18c/0x190 arch/arm64/kernel/entry.S:581

-> #0 (&HFSPLUS_I(inode)->extents_lock){+.+.}-{3:3}:
check_prev_add kernel/locking/lockdep.c:3098 [inline]
check_prevs_add kernel/locking/lockdep.c:3217 [inline]
validate_chain kernel/locking/lockdep.c:3832 [inline]
__lock_acquire+0x3338/0x764c kernel/locking/lockdep.c:5056
lock_acquire+0x26c/0x7cc kernel/locking/lockdep.c:5669
__mutex_lock_common+0x190/0x21a0 kernel/locking/mutex.c:603
__mutex_lock kernel/locking/mutex.c:747 [inline]
mutex_lock_nested+0x38/0x44 kernel/locking/mutex.c:799
hfsplus_file_extend+0x198/0x14cc fs/hfsplus/extents.c:457
hfsplus_bmap_reserve+0xec/0x474 fs/hfsplus/btree.c:358
hfsplus_rename_cat+0x1ac/0xf30 fs/hfsplus/catalog.c:456
hfsplus_rename+0x120/0x1b0 fs/hfsplus/dir.c:552
vfs_rename+0x8b8/0xd04 fs/namei.c:4785
do_renameat2+0x980/0x1040 fs/namei.c:4935
__do_sys_renameat2 fs/namei.c:4968 [inline]
__se_sys_renameat2 fs/namei.c:4965 [inline]
__arm64_sys_renameat2+0xe0/0xfc fs/namei.c:4965
__invoke_syscall arch/arm64/kernel/syscall.c:38 [inline]
invoke_syscall+0x98/0x2c0 arch/arm64/kernel/syscall.c:52
el0_svc_common+0x138/0x258 arch/arm64/kernel/syscall.c:142
do_el0_svc+0x64/0x218 arch/arm64/kernel/syscall.c:206
el0_svc+0x58/0x168 arch/arm64/kernel/entry-common.c:637
el0t_64_sync_handler+0x84/0xf0 arch/arm64/kernel/entry-common.c:655
el0t_64_sync+0x18c/0x190 arch/arm64/kernel/entry.S:581

other info that might help us debug this:

Possible unsafe locking scenario:

CPU0 CPU1
---- ----
lock(&tree->tree_lock);
lock(&HFSPLUS_I(inode)->extents_lock);
lock(&tree->tree_lock);
lock(&HFSPLUS_I(inode)->extents_lock);

*** DEADLOCK ***

4 locks held by syz-executor205/4218:
#0: ffff0000de0d8460 (sb_writers#8){.+.+}-{0:0}, at: mnt_want_write+0x44/0x9c fs/namespace.c:393
#1: ffff0000de111e00 (&type->i_mutex_dir_key#6/1){+.+.}-{3:3}, at: inode_lock_nested include/linux/fs.h:791 [inline]
#1: ffff0000de111e00 (&type->i_mutex_dir_key#6/1){+.+.}-{3:3}, at: lock_rename+0xdc/0x198 fs/namei.c:2990
#2: ffff0000de1124c0 (&type->i_mutex_dir_key#6){++++}-{3:3}, at: inode_lock_nested include/linux/fs.h:791 [inline]
#2: ffff0000de1124c0 (&type->i_mutex_dir_key#6){++++}-{3:3}, at: lock_two_inodes+0xdc/0x158 fs/inode.c:1143
#3: ffff0000de0dc0b0 (&tree->tree_lock){+.+.}-{3:3}, at: hfsplus_find_init+0x144/0x1bc

stack backtrace:
CPU: 1 PID: 4218 Comm: syz-executor205 Not tainted 6.1.44-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 07/12/2023
Call trace:
dump_backtrace+0x1c8/0x1f4 arch/arm64/kernel/stacktrace.c:158
show_stack+0x2c/0x3c arch/arm64/kernel/stacktrace.c:165
__dump_stack lib/dump_stack.c:88 [inline]
dump_stack_lvl+0x108/0x170 lib/dump_stack.c:106
dump_stack+0x1c/0x58 lib/dump_stack.c:113
print_circular_bug+0x150/0x1b8 kernel/locking/lockdep.c:2056
check_noncircular+0x2cc/0x378 kernel/locking/lockdep.c:2178
check_prev_add kernel/locking/lockdep.c:3098 [inline]
check_prevs_add kernel/locking/lockdep.c:3217 [inline]
validate_chain kernel/locking/lockdep.c:3832 [inline]
__lock_acquire+0x3338/0x764c kernel/locking/lockdep.c:5056
lock_acquire+0x26c/0x7cc kernel/locking/lockdep.c:5669
__mutex_lock_common+0x190/0x21a0 kernel/locking/mutex.c:603
__mutex_lock kernel/locking/mutex.c:747 [inline]
mutex_lock_nested+0x38/0x44 kernel/locking/mutex.c:799
hfsplus_file_extend+0x198/0x14cc fs/hfsplus/extents.c:457
hfsplus_bmap_reserve+0xec/0x474 fs/hfsplus/btree.c:358
hfsplus_rename_cat+0x1ac/0xf30 fs/hfsplus/catalog.c:456
hfsplus_rename+0x120/0x1b0 fs/hfsplus/dir.c:552
vfs_rename+0x8b8/0xd04 fs/namei.c:4785
do_renameat2+0x980/0x1040 fs/namei.c:4935
__do_sys_renameat2 fs/namei.c:4968 [inline]
__se_sys_renameat2 fs/namei.c:4965 [inline]
__arm64_sys_renameat2+0xe0/0xfc fs/namei.c:4965
__invoke_syscall arch/arm64/kernel/syscall.c:38 [inline]
invoke_syscall+0x98/0x2c0 arch/arm64/kernel/syscall.c:52
el0_svc_common+0x138/0x258 arch/arm64/kernel/syscall.c:142
do_el0_svc+0x64/0x218 arch/arm64/kernel/syscall.c:206
el0_svc+0x58/0x168 arch/arm64/kernel/entry-common.c:637
el0t_64_sync_handler+0x84/0xf0 arch/arm64/kernel/entry-common.c:655
el0t_64_sync+0x18c/0x190 arch/arm64/kernel/entry.S:581


---
Reply all
Reply to author
Forward
0 new messages