[hfsplus?] possible deadlock in hfsplus_block_allocate

6 views
Skip to first unread message

syzbot

unread,
Jan 1, 2023, 9:59:35 PM1/1/23
to syzkaller...@googlegroups.com
Hello,

syzbot found the following issue on:

HEAD commit: c4215ee4771b Linux 4.14.302
git tree: linux-4.14.y
console output: https://syzkaller.appspot.com/x/log.txt?x=11abcf6c480000
kernel config: https://syzkaller.appspot.com/x/.config?x=4a9988fe055c9527
dashboard link: https://syzkaller.appspot.com/bug?extid=0d184e6fc44e1e30a674
compiler: gcc version 10.2.1 20210110 (Debian 10.2.1-6)

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

Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/c93ba055d204/disk-c4215ee4.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/bfbc929a33c1/vmlinux-c4215ee4.xz
kernel image: https://storage.googleapis.com/syzbot-assets/444658051770/bzImage-c4215ee4.xz

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

======================================================
WARNING: possible circular locking dependency detected
4.14.302-syzkaller #0 Not tainted
------------------------------------------------------
syz-executor.3/15374 is trying to acquire lock:
(&sbi->alloc_mutex){+.+.}, at: [<ffffffff81d456c2>] hfsplus_block_allocate+0xd2/0x910 fs/hfsplus/bitmap.c:35

but task is already holding lock:
(&HFSPLUS_I(inode)->extents_lock){+.+.}, at: [<ffffffff81d2d0a8>] hfsplus_file_extend+0x188/0xef0 fs/hfsplus/extents.c:452

which lock already depends on the new lock.


the existing dependency chain (in reverse order) is:

-> #1 (&HFSPLUS_I(inode)->extents_lock){+.+.}:
__mutex_lock_common kernel/locking/mutex.c:756 [inline]
__mutex_lock+0xc4/0x1310 kernel/locking/mutex.c:893
hfsplus_get_block+0x1f9/0x820 fs/hfsplus/extents.c:260
block_read_full_page+0x25e/0x8d0 fs/buffer.c:2316
do_read_cache_page+0x38e/0xc10 mm/filemap.c:2713
read_mapping_page include/linux/pagemap.h:398 [inline]
hfsplus_block_allocate+0x189/0x910 fs/hfsplus/bitmap.c:37
hfsplus_file_extend+0x421/0xef0 fs/hfsplus/extents.c:463
hfsplus_get_block+0x15b/0x820 fs/hfsplus/extents.c:245
__block_write_begin_int+0x35c/0x11d0 fs/buffer.c:2038
__block_write_begin fs/buffer.c:2088 [inline]
block_write_begin+0x58/0x270 fs/buffer.c:2147
cont_write_begin+0x4a3/0x740 fs/buffer.c:2497
hfsplus_write_begin+0x87/0x130 fs/hfsplus/inode.c:53
generic_perform_write+0x1d5/0x430 mm/filemap.c:3055
__generic_file_write_iter+0x227/0x590 mm/filemap.c:3180
generic_file_write_iter+0x36f/0x650 mm/filemap.c:3208
call_write_iter include/linux/fs.h:1780 [inline]
do_iter_readv_writev+0x4cf/0x5f0 fs/read_write.c:675
do_iter_write+0x152/0x550 fs/read_write.c:954
vfs_writev+0x125/0x290 fs/read_write.c:999
do_writev+0xfc/0x2c0 fs/read_write.c:1034
do_syscall_64+0x1d5/0x640 arch/x86/entry/common.c:292
entry_SYSCALL_64_after_hwframe+0x5e/0xd3

-> #0 (&sbi->alloc_mutex){+.+.}:
lock_acquire+0x170/0x3f0 kernel/locking/lockdep.c:3998
__mutex_lock_common kernel/locking/mutex.c:756 [inline]
__mutex_lock+0xc4/0x1310 kernel/locking/mutex.c:893
hfsplus_block_allocate+0xd2/0x910 fs/hfsplus/bitmap.c:35
hfsplus_file_extend+0x421/0xef0 fs/hfsplus/extents.c:463
hfsplus_get_block+0x15b/0x820 fs/hfsplus/extents.c:245
__block_write_begin_int+0x35c/0x11d0 fs/buffer.c:2038
__block_write_begin fs/buffer.c:2088 [inline]
block_write_begin+0x58/0x270 fs/buffer.c:2147
cont_write_begin+0x4a3/0x740 fs/buffer.c:2497
hfsplus_write_begin+0x87/0x130 fs/hfsplus/inode.c:53
generic_perform_write+0x1d5/0x430 mm/filemap.c:3055
__generic_file_write_iter+0x227/0x590 mm/filemap.c:3180
generic_file_write_iter+0x36f/0x650 mm/filemap.c:3208
call_write_iter include/linux/fs.h:1780 [inline]
do_iter_readv_writev+0x4cf/0x5f0 fs/read_write.c:675
do_iter_write+0x152/0x550 fs/read_write.c:954
vfs_writev+0x125/0x290 fs/read_write.c:999
do_pwritev fs/read_write.c:1088 [inline]
SYSC_pwritev2 fs/read_write.c:1147 [inline]
SyS_pwritev2+0x195/0x230 fs/read_write.c:1138
do_syscall_64+0x1d5/0x640 arch/x86/entry/common.c:292
entry_SYSCALL_64_after_hwframe+0x5e/0xd3

other info that might help us debug this:

Possible unsafe locking scenario:

CPU0 CPU1
---- ----
lock(&HFSPLUS_I(inode)->extents_lock);
lock(&sbi->alloc_mutex);
lock(&HFSPLUS_I(inode)->extents_lock);
lock(&sbi->alloc_mutex);

*** DEADLOCK ***

3 locks held by syz-executor.3/15374:
#0: (sb_writers#18){.+.+}, at: [<ffffffff8186f678>] file_start_write include/linux/fs.h:2714 [inline]
#0: (sb_writers#18){.+.+}, at: [<ffffffff8186f678>] vfs_writev+0x208/0x290 fs/read_write.c:998
#1: (&sb->s_type->i_mutex_key#25){+.+.}, at: [<ffffffff816940f9>] inode_lock include/linux/fs.h:719 [inline]
#1: (&sb->s_type->i_mutex_key#25){+.+.}, at: [<ffffffff816940f9>] generic_file_write_iter+0x99/0x650 mm/filemap.c:3205
#2: (&HFSPLUS_I(inode)->extents_lock){+.+.}, at: [<ffffffff81d2d0a8>] hfsplus_file_extend+0x188/0xef0 fs/hfsplus/extents.c:452

stack backtrace:
CPU: 1 PID: 15374 Comm: syz-executor.3 Not tainted 4.14.302-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 10/26/2022
Call Trace:
__dump_stack lib/dump_stack.c:17 [inline]
dump_stack+0x1b2/0x281 lib/dump_stack.c:58
print_circular_bug.constprop.0.cold+0x2d7/0x41e kernel/locking/lockdep.c:1258
check_prev_add kernel/locking/lockdep.c:1905 [inline]
check_prevs_add kernel/locking/lockdep.c:2022 [inline]
validate_chain kernel/locking/lockdep.c:2464 [inline]
__lock_acquire+0x2e0e/0x3f20 kernel/locking/lockdep.c:3491
lock_acquire+0x170/0x3f0 kernel/locking/lockdep.c:3998
__mutex_lock_common kernel/locking/mutex.c:756 [inline]
__mutex_lock+0xc4/0x1310 kernel/locking/mutex.c:893
hfsplus_block_allocate+0xd2/0x910 fs/hfsplus/bitmap.c:35
hfsplus_file_extend+0x421/0xef0 fs/hfsplus/extents.c:463
hfsplus_get_block+0x15b/0x820 fs/hfsplus/extents.c:245
__block_write_begin_int+0x35c/0x11d0 fs/buffer.c:2038
__block_write_begin fs/buffer.c:2088 [inline]
block_write_begin+0x58/0x270 fs/buffer.c:2147
cont_write_begin+0x4a3/0x740 fs/buffer.c:2497
hfsplus_write_begin+0x87/0x130 fs/hfsplus/inode.c:53
generic_perform_write+0x1d5/0x430 mm/filemap.c:3055
__generic_file_write_iter+0x227/0x590 mm/filemap.c:3180
generic_file_write_iter+0x36f/0x650 mm/filemap.c:3208
call_write_iter include/linux/fs.h:1780 [inline]
do_iter_readv_writev+0x4cf/0x5f0 fs/read_write.c:675
do_iter_write+0x152/0x550 fs/read_write.c:954
vfs_writev+0x125/0x290 fs/read_write.c:999
do_pwritev fs/read_write.c:1088 [inline]
SYSC_pwritev2 fs/read_write.c:1147 [inline]
SyS_pwritev2+0x195/0x230 fs/read_write.c:1138
do_syscall_64+0x1d5/0x640 arch/x86/entry/common.c:292
entry_SYSCALL_64_after_hwframe+0x5e/0xd3
RIP: 0033:0x7f6f47fe00a9
RSP: 002b:00007f6f46552168 EFLAGS: 00000246 ORIG_RAX: 0000000000000148
RAX: ffffffffffffffda RBX: 00007f6f480fff80 RCX: 00007f6f47fe00a9
RDX: 0000000000000001 RSI: 0000000020000100 RDI: 0000000000000004
RBP: 00007f6f4803bae9 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000002328 R11: 0000000000000246 R12: 0000000000000000
R13: 00007ffe40586baf R14: 00007f6f46552300 R15: 0000000000022000
unregister_netdevice: waiting for ip6gre0 to become free. Usage count = -1
attempt to access beyond end of device
loop3: rw=0, want=201326594, limit=1024
Buffer I/O error on dev loop3, logical block 100663296, async page read
attempt to access beyond end of device
loop3: rw=0, want=201326594, limit=1024
Buffer I/O error on dev loop3, logical block 100663296, async page read
EXT4-fs (loop5): mounted filesystem without journal. Opts: ,errors=continue
device team_slave_0 entered promiscuous mode
device team_slave_1 entered promiscuous mode
device team0 entered promiscuous mode
device team_slave_0 entered promiscuous mode
device team_slave_1 entered promiscuous mode
device team_slave_0 left promiscuous mode
device team_slave_1 left promiscuous mode
device team0 left promiscuous mode
device team_slave_0 left promiscuous mode
device team_slave_1 left promiscuous mode
netlink: 28 bytes leftover after parsing attributes in process `syz-executor.4'.
netlink: 28 bytes leftover after parsing attributes in process `syz-executor.4'.
overlayfs: unrecognized mount option "nfs_export=off" or missing value
netlink: 16 bytes leftover after parsing attributes in process `syz-executor.1'.
======================================================
WARNING: the mand mount option is being deprecated and
will be removed in v5.15!
======================================================
netlink: 8 bytes leftover after parsing attributes in process `syz-executor.1'.
netlink: 28 bytes leftover after parsing attributes in process `syz-executor.4'.
FAT-fs (loop0): Directory bread(block 64) failed
FAT-fs (loop0): Directory bread(block 65) failed
FAT-fs (loop0): Directory bread(block 66) failed
netlink: 16 bytes leftover after parsing attributes in process `syz-executor.1'.
netlink: 8 bytes leftover after parsing attributes in process `syz-executor.1'.
FAT-fs (loop0): Directory bread(block 67) failed
FAT-fs (loop0): Directory bread(block 68) failed
FAT-fs (loop0): Directory bread(block 69) failed
FAT-fs (loop0): Directory bread(block 70) failed
FAT-fs (loop0): Directory bread(block 71) failed
FAT-fs (loop0): Directory bread(block 72) failed
FAT-fs (loop0): Directory bread(block 73) failed
audit: type=1800 audit(1672628327.885:2): pid=15759 uid=0 auid=4294967295 ses=4294967295 op="collect_data" cause="failed(directio)" comm="syz-executor.0" name="file2" dev="loop0" ino=4 res=0
netlink: 16 bytes leftover after parsing attributes in process `syz-executor.1'.
netlink: 8 bytes leftover after parsing attributes in process `syz-executor.1'.
netlink: 28 bytes leftover after parsing attributes in process `syz-executor.4'.


---
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.
Reply all
Reply to author
Forward
0 new messages