syzbot


possible deadlock in hfsplus_block_free

Status: upstream: reported on 2022/12/01 19:36
Subsystems: hfsplus
[Documentation on labels]
Reported-by: syzbot+29adb337e20196ce447a@syzkaller.appspotmail.com
First crash: 483d, last: 398d
Similar bugs (4)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
linux-4.19 possible deadlock in hfsplus_block_free hfsplus 20 389d 480d 0/1 upstream: reported on 2022/12/04 19:32
upstream possible deadlock in hfsplus_block_free hfs C inconclusive 220 9d23h 485d 0/26 upstream: reported C repro on 2022/11/29 08:32
linux-5.15 possible deadlock in hfsplus_block_free 20 157d 360d 0/3 auto-obsoleted due to no activity on 2024/01/31 18:41
linux-6.1 possible deadlock in hfsplus_block_free 27 83d 347d 0/3 upstream: reported on 2023/04/16 21:54

Sample crash report:
L1TF CPU bug present and SMT on, data leak possible. See CVE-2018-3646 and https://www.kernel.org/doc/html/latest/admin-guide/hw-vuln/l1tf.html for details.
autofs4:pid:9636:validate_dev_ioctl: invalid path supplied for cmd(0xc0189375)
======================================================
WARNING: possible circular locking dependency detected
4.14.306-syzkaller #0 Not tainted
------------------------------------------------------
syz-executor.1/9617 is trying to acquire lock:
 (&sbi->alloc_mutex){+.+.}, at: [<ffffffff81d462e7>] hfsplus_block_free+0xc7/0x560 fs/hfsplus/bitmap.c:182

but task is already holding lock:
 (&tree->tree_lock/1){+.+.}, at: [<ffffffff81d40761>] hfsplus_find_init+0x161/0x220 fs/hfsplus/bfind.c:33

which lock already depends on the new lock.


the existing dependency chain (in reverse order) is:

-> #2 (&tree->tree_lock/1){+.+.}:
       __mutex_lock_common kernel/locking/mutex.c:756 [inline]
       __mutex_lock+0xc4/0x1310 kernel/locking/mutex.c:893
       hfsplus_find_init+0x161/0x220 fs/hfsplus/bfind.c:33
       hfsplus_ext_read_extent+0x15f/0x9e0 fs/hfsplus/extents.c:216
       hfsplus_get_block+0x23e/0x820 fs/hfsplus/extents.c:268
       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]
       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

-> #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]
       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

-> #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_free+0xc7/0x560 fs/hfsplus/bitmap.c:182
       hfsplus_free_extents+0x320/0x440 fs/hfsplus/extents.c:371
       hfsplus_file_truncate+0xbc0/0xe80 fs/hfsplus/extents.c:585
       hfsplus_file_release+0xbc/0x1e0 fs/hfsplus/inode.c:234
       __fput+0x25f/0x7a0 fs/file_table.c:210
       task_work_run+0x11f/0x190 kernel/task_work.c:113
       tracehook_notify_resume include/linux/tracehook.h:191 [inline]
       exit_to_usermode_loop+0x1ad/0x200 arch/x86/entry/common.c:164
       prepare_exit_to_usermode arch/x86/entry/common.c:199 [inline]
       syscall_return_slowpath arch/x86/entry/common.c:270 [inline]
       do_syscall_64+0x4a3/0x640 arch/x86/entry/common.c:297
       entry_SYSCALL_64_after_hwframe+0x5e/0xd3

other info that might help us debug this:

Chain exists of:
  &sbi->alloc_mutex --> &HFSPLUS_I(inode)->extents_lock --> &tree->tree_lock/1

 Possible unsafe locking scenario:

       CPU0                    CPU1
       ----                    ----
  lock(&tree->tree_lock/1);
                               lock(&HFSPLUS_I(inode)->extents_lock);
                               lock(&tree->tree_lock/1);
  lock(&sbi->alloc_mutex);

 *** DEADLOCK ***

3 locks held by syz-executor.1/9617:
 #0:  (&sb->s_type->i_mutex_key#21){+.+.}, at: [<ffffffff81d28dd4>] inode_lock include/linux/fs.h:719 [inline]
 #0:  (&sb->s_type->i_mutex_key#21){+.+.}, at: [<ffffffff81d28dd4>] hfsplus_file_release+0xb4/0x1e0 fs/hfsplus/inode.c:233
 #1:  (&hip->extents_lock){+.+.}, at: [<ffffffff81d2eb0a>] hfsplus_file_truncate+0x1ba/0xe80 fs/hfsplus/extents.c:571
 #2:  (&tree->tree_lock/1){+.+.}, at: [<ffffffff81d40761>] hfsplus_find_init+0x161/0x220 fs/hfsplus/bfind.c:33

stack backtrace:
CPU: 1 PID: 9617 Comm: syz-executor.1 Not tainted 4.14.306-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 02/16/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_free+0xc7/0x560 fs/hfsplus/bitmap.c:182
 hfsplus_free_extents+0x320/0x440 fs/hfsplus/extents.c:371
 hfsplus_file_truncate+0xbc0/0xe80 fs/hfsplus/extents.c:585
 hfsplus_file_release+0xbc/0x1e0 fs/hfsplus/inode.c:234
 __fput+0x25f/0x7a0 fs/file_table.c:210
 task_work_run+0x11f/0x190 kernel/task_work.c:113
 tracehook_notify_resume include/linux/tracehook.h:191 [inline]
 exit_to_usermode_loop+0x1ad/0x200 arch/x86/entry/common.c:164
 prepare_exit_to_usermode arch/x86/entry/common.c:199 [inline]
 syscall_return_slowpath arch/x86/entry/common.c:270 [inline]
 do_syscall_64+0x4a3/0x640 arch/x86/entry/common.c:297
 entry_SYSCALL_64_after_hwframe+0x5e/0xd3
RIP: 0033:0x7fee2a7bbfab
RSP: 002b:00007ffe1d6e5aa0 EFLAGS: 00000293 ORIG_RAX: 0000000000000003
RAX: 0000000000000000 RBX: 0000000000000005 RCX: 00007fee2a7bbfab
RDX: 00007fee2a37ed10 RSI: ffffffffffffffff RDI: 0000000000000004
RBP: 00007fee2a92b980 R08: 0000000000000000 R09: 00007fee2a37e000
R10: 00007fee2a37ed18 R11: 0000000000000293 R12: 000000000003b8cb
R13: 00007ffe1d6e5ba0 R14: 00007fee2a929f80 R15: 0000000000000032
netlink: 24 bytes leftover after parsing attributes in process `syz-executor.4'.
netlink: 24 bytes leftover after parsing attributes in process `syz-executor.4'.
hfsplus: unable to parse mount options
netlink: 24 bytes leftover after parsing attributes in process `syz-executor.4'.
hfsplus: unable to parse mount options
netlink: 24 bytes leftover after parsing attributes in process `syz-executor.4'.
device bridge1 entered promiscuous mode
print_req_error: I/O error, dev loop1, sector 0
IPv6: ADDRCONF(NETDEV_UP): bridge1: link is not ready
EXT4-fs (sda1): re-mounted. Opts: 
XFS (loop0): Superblock has unknown incompatible features (0x8) enabled.
XFS (loop0): Filesystem can not be safely mounted by this kernel.
XFS (loop0): SB validate failed with error -22.
EXT4-fs (sda1): re-mounted. Opts: 
device bridge1 entered promiscuous mode
IPv6: ADDRCONF(NETDEV_UP): bridge1: link is not ready
EXT4-fs (sda1): re-mounted. Opts: 
EXT4-fs (sda1): re-mounted. Opts: 
device bridge1 entered promiscuous mode
IPv6: ADDRCONF(NETDEV_UP): bridge1: link is not ready
XFS (loop0): Superblock has unknown incompatible features (0x8) enabled.
XFS (loop0): Filesystem can not be safely mounted by this kernel.
XFS (loop0): SB validate failed with error -22.
device bridge1 entered promiscuous mode
IPv6: ADDRCONF(NETDEV_UP): bridge1: link is not ready
XFS (loop0): Superblock has unknown incompatible features (0x8) enabled.
XFS (loop0): Filesystem can not be safely mounted by this kernel.
XFS (loop0): SB validate failed with error -22.
XFS (loop0): Superblock has unknown incompatible features (0x8) enabled.
XFS (loop0): Filesystem can not be safely mounted by this kernel.
XFS (loop0): SB validate failed with error -22.
EXT4-fs (sda1): re-mounted. Opts: 
EXT4-fs (sda1): re-mounted. Opts: 
EXT4-fs (sda1): re-mounted. Opts: 
EXT4-fs (sda1): re-mounted. Opts: 
XFS (loop0): Superblock has unknown incompatible features (0x8) enabled.
XFS (loop0): Filesystem can not be safely mounted by this kernel.
XFS (loop0): SB validate failed with error -22.
EXT4-fs (loop0): mounting ext2 file system using the ext4 subsystem
EXT4-fs (loop0): orphan cleanup on readonly fs
EXT4-fs error (device loop0): ext4_validate_block_bitmap:405: comm syz-executor.0: bg 0: block 18: invalid block bitmap
EXT4-fs error (device loop0) in ext4_free_blocks:5010: Corrupt filesystem
EXT4-fs (loop0): 1 truncate cleaned up
EXT4-fs (loop0): mounted filesystem without journal. Opts: ,errors=continue
EXT4-fs error (device loop0): ext4_map_blocks:612: inode #2: block 3: comm syz-executor.0: lblock 0 mapped to illegal pblock 3 (length 1)
======================================================
WARNING: the mand mount option is being deprecated and
         will be removed in v5.15!
======================================================
audit: type=1400 audit(1677270933.009:2): apparmor="DENIED" operation="change_onexec" info="label not found" error=-2 profile="unconfined" name="=!" pid=10383 comm="syz-executor.0"
audit: type=1400 audit(1677270933.099:3): apparmor="DENIED" operation="change_onexec" info="label not found" error=-2 profile="unconfined" name="=!" pid=10393 comm="syz-executor.0"
audit: type=1400 audit(1677270933.179:4): apparmor="DENIED" operation="change_onexec" info="label not found" error=-2 profile="unconfined" name="=!" pid=10404 comm="syz-executor.0"
audit: type=1400 audit(1677270933.249:5): apparmor="DENIED" operation="change_onexec" info="label not found" error=-2 profile="unconfined" name="=!" pid=10420 comm="syz-executor.0"
BTRFS: device fsid a6a605fc-d5f1-4e66-8595-3726e2b761d6 devid 1 transid 8 /dev/loop2
BTRFS error (device loop2): unsupported checksum algorithm 3
BTRFS error (device loop2): superblock checksum mismatch
F2FS-fs (loop5): Mismatch valid blocks 0 vs. 2
F2FS-fs (loop5): Failed to initialize F2FS segment manager
F2FS-fs (loop5): Mismatch valid blocks 0 vs. 2
F2FS-fs (loop5): Failed to initialize F2FS segment manager
BTRFS error (device loop2): open_ctree failed
netlink: 4 bytes leftover after parsing attributes in process `syz-executor.0'.
unregister_netdevice: waiting for ip6gre0 to become free. Usage count = -1
netlink: 4 bytes leftover after parsing attributes in process `syz-executor.0'.
F2FS-fs (loop5): Mismatch valid blocks 0 vs. 2
F2FS-fs (loop5): Failed to initialize F2FS segment manager
F2FS-fs (loop5): Mismatch valid blocks 0 vs. 2
F2FS-fs (loop5): Failed to initialize F2FS segment manager
netlink: 4 bytes leftover after parsing attributes in process `syz-executor.0'.
F2FS-fs (loop5): Mismatch valid blocks 0 vs. 2
F2FS-fs (loop5): Failed to initialize F2FS segment manager
BTRFS: device fsid 5ac8a51e-da3a-4998-8e66-e1df06b87bc8 devid 1 transid 8 /dev/loop1
BTRFS error (device loop1): unsupported checksum algorithm 1
BTRFS error (device loop1): superblock checksum mismatch
BTRFS error (device loop1): open_ctree failed

Crashes (10):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2023/02/24 20:35 linux-4.14.y 1e61bd26fa2c ee50e71c .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-4-14 possible deadlock in hfsplus_block_free
2023/02/19 23:47 linux-4.14.y a8ad60f2af58 bcdf85f8 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-4-14 possible deadlock in hfsplus_block_free
2023/02/05 12:08 linux-4.14.y 3949d1610004 be607b78 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-4-14 possible deadlock in hfsplus_block_free
2023/01/14 16:51 linux-4.14.y c4215ee4771b a63719e7 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-4-14 possible deadlock in hfsplus_block_free
2023/01/10 08:37 linux-4.14.y c4215ee4771b 48bc529a .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-4-14 possible deadlock in hfsplus_block_free
2023/01/06 13:17 linux-4.14.y c4215ee4771b 1dac8c7a .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-4-14 possible deadlock in hfsplus_block_free
2022/12/31 05:08 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_free
2022/12/07 18:52 linux-4.14.y 179ef7fe8677 d88f3abb .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-4-14 possible deadlock in hfsplus_block_free
2022/12/04 07:05 linux-4.14.y 179ef7fe8677 e080de16 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-4-14 possible deadlock in hfsplus_block_free
2022/12/01 19:36 linux-4.14.y 179ef7fe8677 e080de16 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-4-14 possible deadlock in hfsplus_block_free
* Struck through repros no longer work on HEAD.