syzbot


possible deadlock in hfsplus_block_allocate

Status: upstream: reported on 2023/01/02 02:59
Subsystems: hfsplus
[Documentation on labels]
Reported-by: syzbot+0d184e6fc44e1e30a674@syzkaller.appspotmail.com
First crash: 474d, last: 457d
Similar bugs (4)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
linux-6.1 possible deadlock in hfsplus_block_allocate 25 15d 386d 0/3 upstream: reported on 2023/03/30 21:16
upstream possible deadlock in hfsplus_block_allocate hfs C done 190 7d15h 507d 0/26 upstream: reported C repro on 2022/11/29 13:38
linux-4.19 possible deadlock in hfsplus_block_allocate hfsplus 2 477d 484d 0/1 upstream: reported on 2022/12/22 13:15
linux-5.15 possible deadlock in hfsplus_block_allocate 18 31d 392d 0/3 upstream: reported on 2023/03/24 22:08

Sample crash report:
9pnet: p9_errstr2errno: server reported unknown error ÿïàÒ’ÿÿ
IPv6: ADDRCONF(NETDEV_CHANGE): vcan0: link becomes ready
======================================================
WARNING: possible circular locking dependency detected
ISO 9660 Extensions: Microsoft Joliet Level 0
4.14.303-syzkaller #0 Not tainted
------------------------------------------------------
syz-executor.4/10657 is trying to acquire lock:
 (&sbi->alloc_mutex){+.+.}, at: [<ffffffff81d456e2>] hfsplus_block_allocate+0xd2/0x910 fs/hfsplus/bitmap.c:35

but task is already holding lock:
 (&HFSPLUS_I(inode)->extents_lock){+.+.}, at: [<ffffffff81d2d0c8>] 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
       cont_expand_zero fs/buffer.c:2424 [inline]
       cont_write_begin+0x296/0x740 fs/buffer.c:2487
       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]
       aio_write+0x2ed/0x560 fs/aio.c:1553
       io_submit_one fs/aio.c:1641 [inline]
       do_io_submit+0x847/0x1570 fs/aio.c:1709
       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]
       new_sync_write fs/read_write.c:469 [inline]
       __vfs_write+0x44c/0x630 fs/read_write.c:482
       vfs_write+0x17f/0x4d0 fs/read_write.c:544
       SYSC_write fs/read_write.c:590 [inline]
       SyS_write+0xf2/0x210 fs/read_write.c:582
       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 ***

4 locks held by syz-executor.4/10657:
 #0:  (&f->f_pos_lock){+.+.}, at: [<ffffffff818d8e0b>] __fdget_pos+0x1fb/0x2b0 fs/file.c:819
 #1:  (sb_writers#14){.+.+}, at: [<ffffffff81872918>] file_start_write include/linux/fs.h:2714 [inline]
 #1:  (sb_writers#14){.+.+}, at: [<ffffffff81872918>] vfs_write+0x3d8/0x4d0 fs/read_write.c:543
 #2:  (&sb->s_type->i_mutex_key#25){+.+.}, at: [<ffffffff81693e49>] inode_lock include/linux/fs.h:719 [inline]
 #2:  (&sb->s_type->i_mutex_key#25){+.+.}, at: [<ffffffff81693e49>] generic_file_write_iter+0x99/0x650 mm/filemap.c:3205
 #3:  (&HFSPLUS_I(inode)->extents_lock){+.+.}, at: [<ffffffff81d2d0c8>] hfsplus_file_extend+0x188/0xef0 fs/hfsplus/extents.c:452

stack backtrace:
CPU: 1 PID: 10657 Comm: syz-executor.4 Not tainted 4.14.303-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/12/2023
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]
 new_sync_write fs/read_write.c:469 [inline]
 __vfs_write+0x44c/0x630 fs/read_write.c:482
 vfs_write+0x17f/0x4d0 fs/read_write.c:544
 SYSC_write fs/read_write.c:590 [inline]
 SyS_write+0xf2/0x210 fs/read_write.c:582
 do_syscall_64+0x1d5/0x640 arch/x86/entry/common.c:292
 entry_SYSCALL_64_after_hwframe+0x5e/0xd3
RIP: 0033:0x7f961ac640c9
RSP: 002b:00007f96191d6168 EFLAGS: 00000246 ORIG_RAX: 0000000000000001
RAX: ffffffffffffffda RBX: 00007f961ad83f80 RCX: 00007f961ac640c9
RDX: 00000000000ffe00 RSI: 0000000020004200 RDI: 0000000000000004
RBP: 00007f961acbfae9 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 00007ffc7052466f R14: 00007f96191d6300 R15: 0000000000022000
IPv6: ADDRCONF(NETDEV_CHANGE): bond0: link becomes ready
A link change request failed with some changes committed already. Interface bond0 may have been left with an inconsistent configuration, please check.
9pnet: p9_errstr2errno: server reported unknown error ÿïàÒ’ÿÿ
rock: corrupted directory entry. extent=32, offset=2044, size=237
IPv6: ADDRCONF(NETDEV_CHANGE): vcan0: link becomes ready
IPv6: ADDRCONF(NETDEV_CHANGE): bond0: link becomes ready
9pnet: p9_errstr2errno: server reported unknown error ÿïàÒ’ÿÿ
IPv6: ADDRCONF(NETDEV_CHANGE): vxcan0: link becomes ready
IPv6: ADDRCONF(NETDEV_CHANGE): vxcan1: link becomes ready
overlayfs: fs on './file0' does not support file handles, falling back to index=off.
9pnet: p9_errstr2errno: server reported unknown error ÿïàÒ’ÿÿ
ISOFS: Interleaved files not (yet) supported.
ISOFS: File unit size != 0 for ISO file (1856).
IPv6: ADDRCONF(NETDEV_CHANGE): vcan0: link becomes ready
IPv6: ADDRCONF(NETDEV_CHANGE): bond0: link becomes ready
ISO 9660 Extensions: Microsoft Joliet Level 0
rock: corrupted directory entry. extent=32, offset=2044, size=237
IPv6: ADDRCONF(NETDEV_CHANGE): vxcan0: link becomes ready
IPv6: ADDRCONF(NETDEV_CHANGE): vxcan1: link becomes ready
overlayfs: fs on './file0' does not support file handles, falling back to index=off.
ISOFS: Interleaved files not (yet) supported.
ISOFS: File unit size != 0 for ISO file (1856).
unregister_netdevice: waiting for ip6gre0 to become free. Usage count = -1
IPv6: ADDRCONF(NETDEV_CHANGE): vcan0: link becomes ready
IPv6: ADDRCONF(NETDEV_CHANGE): bond0: link becomes ready
ISO 9660 Extensions: Microsoft Joliet Level 0
rock: corrupted directory entry. extent=32, offset=2044, size=237
IPv6: ADDRCONF(NETDEV_CHANGE): vxcan0: link becomes ready
IPv6: ADDRCONF(NETDEV_CHANGE): vxcan1: link becomes ready
UDF-fs: INFO Mounting volume 'LinuxUDF', timestamp 2022/11/22 14:59 (1000)
overlayfs: fs on './file0' does not support file handles, falling back to index=off.
ISOFS: Interleaved files not (yet) supported.
ISOFS: File unit size != 0 for ISO file (1856).
UDF-fs: INFO Mounting volume 'LinuxUDF', timestamp 2022/11/22 14:59 (1000)
UDF-fs: INFO Mounting volume 'LinuxUDF', timestamp 2022/11/22 14:59 (1000)
UDF-fs: INFO Mounting volume 'LinuxUDF', timestamp 2022/11/22 14:59 (1000)
UDF-fs: INFO Mounting volume 'LinuxUDF', timestamp 2022/11/22 14:59 (1000)
UDF-fs: INFO Mounting volume 'LinuxUDF', timestamp 2022/11/22 14:59 (1000)
UDF-fs: INFO Mounting volume 'LinuxUDF', timestamp 2022/11/22 14:59 (1000)
UDF-fs: INFO Mounting volume 'LinuxUDF', timestamp 2022/11/22 14:59 (1000)

Crashes (2):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2023/01/18 19:22 linux-4.14.y 97205fccccdc 4620c2d9 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-4-14 possible deadlock in hfsplus_block_allocate
2023/01/02 02:58 linux-4.14.y c4215ee4771b ab32d508 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-4-14 possible deadlock in hfsplus_block_allocate
* Struck through repros no longer work on HEAD.