[v5.15] possible deadlock in hfs_extend_file (2)

0 views
Skip to first unread message

syzbot

unread,
Oct 23, 2023, 2:25:52 PM10/23/23
to syzkaller...@googlegroups.com
Hello,

syzbot found the following issue on:

HEAD commit: 00c03985402e Linux 5.15.136
git tree: linux-5.15.y
console output: https://syzkaller.appspot.com/x/log.txt?x=1409270b680000
kernel config: https://syzkaller.appspot.com/x/.config?x=44f1119854f35733
dashboard link: https://syzkaller.appspot.com/bug?extid=ae98efb2630f621f5a9a
compiler: Debian clang version 15.0.6, GNU ld (GNU Binutils for Debian) 2.40
userspace arch: arm64

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

Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/8b6792bef09d/disk-00c03985.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/d63de1cd585e/vmlinux-00c03985.xz
kernel image: https://storage.googleapis.com/syzbot-assets/90e251933a79/Image-00c03985.gz.xz

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

hfs: unable to locate alternate MDB
hfs: continuing without an alternate MDB
======================================================
WARNING: possible circular locking dependency detected
5.15.136-syzkaller #0 Not tainted
------------------------------------------------------
syz-executor.0/5608 is trying to acquire lock:
ffff0000dad60778 (&HFS_I(tree->inode)->extents_lock){+.+.}-{3:3}, at: hfs_extend_file+0xe4/0x10e4 fs/hfs/extent.c:397

but task is already holding lock:
ffff0000ced840b0 (&tree->tree_lock/1){+.+.}-{3:3}, at: hfs_find_init+0x148/0x1c8

which lock already depends on the new lock.


the existing dependency chain (in reverse order) is:

-> #1 (&tree->tree_lock/1){+.+.}-{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
hfs_find_init+0x148/0x1c8
hfs_ext_read_extent fs/hfs/extent.c:200 [inline]
hfs_get_block+0x290/0x9fc fs/hfs/extent.c:366
block_read_full_page+0x2a0/0xc4c fs/buffer.c:2290
hfs_readpage+0x28/0x38 fs/hfs/inode.c:39
do_read_cache_page+0x60c/0x950
read_cache_page+0x68/0x84 mm/filemap.c:3565
read_mapping_page include/linux/pagemap.h:515 [inline]
__hfs_bnode_create+0x3fc/0x880 fs/hfs/bnode.c:297
hfs_bnode_find+0x200/0xc88 fs/hfs/bnode.c:346
hfs_brec_find+0x130/0x498 fs/hfs/bfind.c:126
hfs_brec_read+0x30/0x120 fs/hfs/bfind.c:165
hfs_cat_find_brec+0x124/0x3cc fs/hfs/catalog.c:194
hfs_fill_super+0xe00/0x13b4 fs/hfs/super.c:419
mount_bdev+0x274/0x370 fs/super.c:1387
hfs_mount+0x44/0x58 fs/hfs/super.c:456
legacy_get_tree+0xd4/0x16c fs/fs_context.c:611
vfs_get_tree+0x90/0x274 fs/super.c:1517
do_new_mount+0x25c/0x8c4 fs/namespace.c:2994
path_mount+0x594/0x101c fs/namespace.c:3324
do_mount fs/namespace.c:3337 [inline]
__do_sys_mount fs/namespace.c:3545 [inline]
__se_sys_mount fs/namespace.c:3522 [inline]
__arm64_sys_mount+0x510/0x5e0 fs/namespace.c:3522
__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:608
el0t_64_sync_handler+0x84/0xe4 arch/arm64/kernel/entry-common.c:626
el0t_64_sync+0x1a0/0x1a4 arch/arm64/kernel/entry.S:584

-> #0 (&HFS_I(tree->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
hfs_extend_file+0xe4/0x10e4 fs/hfs/extent.c:397
hfs_bmap_reserve+0xd0/0x3b4 fs/hfs/btree.c:231
__hfs_ext_write_extent+0x1a0/0x468 fs/hfs/extent.c:121
__hfs_ext_cache_extent+0x84/0x754 fs/hfs/extent.c:174
hfs_ext_read_extent fs/hfs/extent.c:202 [inline]
hfs_extend_file+0x278/0x10e4 fs/hfs/extent.c:401
hfs_get_block+0x3ac/0x9fc fs/hfs/extent.c:353
__block_write_begin_int+0x3ec/0x1608 fs/buffer.c:2012
__block_write_begin fs/buffer.c:2062 [inline]
block_write_begin fs/buffer.c:2122 [inline]
cont_write_begin+0x538/0x710 fs/buffer.c:2471
hfs_write_begin+0xa8/0xf8 fs/hfs/inode.c:59
pagecache_write_begin+0xa0/0xc0 mm/filemap.c:3599
cont_expand_zero fs/buffer.c:2398 [inline]
cont_write_begin+0x26c/0x710 fs/buffer.c:2461
hfs_write_begin+0xa8/0xf8 fs/hfs/inode.c:59
pagecache_write_begin+0xa0/0xc0 mm/filemap.c:3599
hfs_file_truncate+0x1a4/0xea4 fs/hfs/extent.c:494
hfs_inode_setattr+0x3a8/0x5c8 fs/hfs/inode.c:654
notify_change+0xa34/0xcf8 fs/attr.c:505
do_truncate+0x1c0/0x28c fs/open.c:65
do_sys_ftruncate+0x288/0x31c fs/open.c:193
__do_sys_ftruncate fs/open.c:204 [inline]
__se_sys_ftruncate fs/open.c:202 [inline]
__arm64_sys_ftruncate+0x60/0x74 fs/open.c:202
__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:608
el0t_64_sync_handler+0x84/0xe4 arch/arm64/kernel/entry-common.c:626
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/1);
lock(&HFS_I(tree->inode)->extents_lock);
lock(&tree->tree_lock/1);
lock(&HFS_I(tree->inode)->extents_lock);

*** DEADLOCK ***

4 locks held by syz-executor.0/5608:
#0: ffff0000da248460 (sb_writers#26){.+.+}-{0:0}, at: do_sys_ftruncate+0x214/0x31c fs/open.c:190
#1: ffff0000dad61628 (&sb->s_type->i_mutex_key#32){+.+.}-{3:3}, at: inode_lock include/linux/fs.h:787 [inline]
#1: ffff0000dad61628 (&sb->s_type->i_mutex_key#32){+.+.}-{3:3}, at: do_truncate+0x1ac/0x28c fs/open.c:63
#2: ffff0000dad61478 (&HFS_I(inode)->extents_lock){+.+.}-{3:3}, at: hfs_extend_file+0xe4/0x10e4 fs/hfs/extent.c:397
#3: ffff0000ced840b0 (&tree->tree_lock/1){+.+.}-{3:3}, at: hfs_find_init+0x148/0x1c8

stack backtrace:
CPU: 0 PID: 5608 Comm: syz-executor.0 Not tainted 5.15.136-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 09/06/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
hfs_extend_file+0xe4/0x10e4 fs/hfs/extent.c:397
hfs_bmap_reserve+0xd0/0x3b4 fs/hfs/btree.c:231
__hfs_ext_write_extent+0x1a0/0x468 fs/hfs/extent.c:121
__hfs_ext_cache_extent+0x84/0x754 fs/hfs/extent.c:174
hfs_ext_read_extent fs/hfs/extent.c:202 [inline]
hfs_extend_file+0x278/0x10e4 fs/hfs/extent.c:401
hfs_get_block+0x3ac/0x9fc fs/hfs/extent.c:353
__block_write_begin_int+0x3ec/0x1608 fs/buffer.c:2012
__block_write_begin fs/buffer.c:2062 [inline]
block_write_begin fs/buffer.c:2122 [inline]
cont_write_begin+0x538/0x710 fs/buffer.c:2471
hfs_write_begin+0xa8/0xf8 fs/hfs/inode.c:59
pagecache_write_begin+0xa0/0xc0 mm/filemap.c:3599
cont_expand_zero fs/buffer.c:2398 [inline]
cont_write_begin+0x26c/0x710 fs/buffer.c:2461
hfs_write_begin+0xa8/0xf8 fs/hfs/inode.c:59
pagecache_write_begin+0xa0/0xc0 mm/filemap.c:3599
hfs_file_truncate+0x1a4/0xea4 fs/hfs/extent.c:494
hfs_inode_setattr+0x3a8/0x5c8 fs/hfs/inode.c:654
notify_change+0xa34/0xcf8 fs/attr.c:505
do_truncate+0x1c0/0x28c fs/open.c:65
do_sys_ftruncate+0x288/0x31c fs/open.c:193
__do_sys_ftruncate fs/open.c:204 [inline]
__se_sys_ftruncate fs/open.c:202 [inline]
__arm64_sys_ftruncate+0x60/0x74 fs/open.c:202
__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:608
el0t_64_sync_handler+0x84/0xe4 arch/arm64/kernel/entry-common.c:626
el0t_64_sync+0x1a0/0x1a4 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.

If the bug is already fixed, let syzbot know by replying with:
#syz fix: exact-commit-title

If you want to overwrite bug's subsystems, reply with:
#syz set subsystems: new-subsystem
(See the list of subsystem names on the web dashboard)

If the bug is a duplicate of another bug, reply with:
#syz dup: exact-subject-of-another-report

If you want to undo deduplication, reply with:
#syz undup

syzbot

unread,
Jan 31, 2024, 1:25:18 PMJan 31
to syzkaller...@googlegroups.com
Auto-closing this bug as obsolete.
Crashes did not happen for a while, no reproducer and no activity.
Reply all
Reply to author
Forward
0 new messages