BTRFS error (device loop5): open_ctree failed
REISERFS (device loop0): checking transaction log (loop0)
BTRFS: device fsid 5ac8a51e-da3a-4998-8e66-e1df06b87bc8 devid 1 transid 8 /dev/loop2
REISERFS (device loop0): Using r5 hash to sort names
======================================================
WARNING: possible circular locking dependency detected
4.14.301-syzkaller #0 Not tainted
------------------------------------------------------
syz-executor.0/9620 is trying to acquire lock:
 (sb_writers#14){.+.+}, at: [<ffffffff818e201d>] sb_start_write include/linux/fs.h:1551 [inline]
 (sb_writers#14){.+.+}, at: [<ffffffff818e201d>] mnt_want_write_file+0xfd/0x3b0 fs/namespace.c:497

but task is already holding lock:
 (&sbi->lock){+.+.}, at: [<ffffffff81b3fb55>] reiserfs_write_lock+0x75/0xf0 fs/reiserfs/lock.c:27

which lock already depends on the new lock.


the existing dependency chain (in reverse order) is:

-> #2 (&sbi->lock){+.+.}:
       __mutex_lock_common kernel/locking/mutex.c:756 [inline]
       __mutex_lock+0xc4/0x1310 kernel/locking/mutex.c:893
       reiserfs_write_lock+0x75/0xf0 fs/reiserfs/lock.c:27
       reiserfs_lookup+0x130/0x400 fs/reiserfs/namei.c:363
       lookup_real fs/namei.c:1555 [inline]
       __lookup_hash fs/namei.c:1575 [inline]
       __lookup_hash+0x1bb/0x270 fs/namei.c:1563
       filename_create+0x156/0x3f0 fs/namei.c:3677
       user_path_create fs/namei.c:3734 [inline]
       SYSC_mkdirat fs/namei.c:3866 [inline]
       SyS_mkdirat+0x95/0x270 fs/namei.c:3858
       do_syscall_64+0x1d5/0x640 arch/x86/entry/common.c:292
       entry_SYSCALL_64_after_hwframe+0x5e/0xd3

-> #1 (&type->i_mutex_dir_key#9/1){+.+.}:
       down_write_nested+0x36/0x90 kernel/locking/rwsem.c:172
       inode_lock_nested include/linux/fs.h:754 [inline]
       filename_create+0x12a/0x3f0 fs/namei.c:3676
       user_path_create fs/namei.c:3734 [inline]
       SYSC_mkdirat fs/namei.c:3866 [inline]
       SyS_mkdirat+0x95/0x270 fs/namei.c:3858
       do_syscall_64+0x1d5/0x640 arch/x86/entry/common.c:292
       entry_SYSCALL_64_after_hwframe+0x5e/0xd3

-> #0 (sb_writers#14){.+.+}:
       lock_acquire+0x170/0x3f0 kernel/locking/lockdep.c:3998
       percpu_down_read_preempt_disable include/linux/percpu-rwsem.h:36 [inline]
       percpu_down_read include/linux/percpu-rwsem.h:59 [inline]
       __sb_start_write+0x64/0x260 fs/super.c:1342
       sb_start_write include/linux/fs.h:1551 [inline]
       mnt_want_write_file+0xfd/0x3b0 fs/namespace.c:497
       reiserfs_ioctl+0x18e/0x8b0 fs/reiserfs/ioctl.c:110
       vfs_ioctl fs/ioctl.c:46 [inline]
       file_ioctl fs/ioctl.c:500 [inline]
       do_vfs_ioctl+0x75a/0xff0 fs/ioctl.c:684
       SYSC_ioctl fs/ioctl.c:701 [inline]
       SyS_ioctl+0x7f/0xb0 fs/ioctl.c:692
       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:

Chain exists of:
  sb_writers#14 --> &type->i_mutex_dir_key#9/1 --> &sbi->lock

 Possible unsafe locking scenario:

       CPU0                    CPU1
       ----                    ----
  lock(&sbi->lock);
                               lock(&type->i_mutex_dir_key#9/1);
                               lock(&sbi->lock);
  lock(sb_writers#14);

 *** DEADLOCK ***

1 lock held by syz-executor.0/9620:
 #0:  (&sbi->lock){+.+.}, at: [<ffffffff81b3fb55>] reiserfs_write_lock+0x75/0xf0 fs/reiserfs/lock.c:27

stack backtrace:
CPU: 1 PID: 9620 Comm: syz-executor.0 Not tainted 4.14.301-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
 percpu_down_read_preempt_disable include/linux/percpu-rwsem.h:36 [inline]
 percpu_down_read include/linux/percpu-rwsem.h:59 [inline]
 __sb_start_write+0x64/0x260 fs/super.c:1342
 sb_start_write include/linux/fs.h:1551 [inline]
 mnt_want_write_file+0xfd/0x3b0 fs/namespace.c:497
 reiserfs_ioctl+0x18e/0x8b0 fs/reiserfs/ioctl.c:110
 vfs_ioctl fs/ioctl.c:46 [inline]
 file_ioctl fs/ioctl.c:500 [inline]
 do_vfs_ioctl+0x75a/0xff0 fs/ioctl.c:684
 SYSC_ioctl fs/ioctl.c:701 [inline]
 SyS_ioctl+0x7f/0xb0 fs/ioctl.c:692
 do_syscall_64+0x1d5/0x640 arch/x86/entry/common.c:292
 entry_SYSCALL_64_after_hwframe+0x5e/0xd3
RIP: 0033:0x7fadb712f0d9
RSP: 002b:00007fadb56a1168 EFLAGS: 00000246 ORIG_RAX: 0000000000000010
RAX: ffffffffffffffda RBX: 00007fadb724ef80 RCX: 00007fadb712f0d9
RDX: 0000000000000000 RSI: 0000000040087602 RDI: 0000000000000003
RBP: 00007fadb718aae9 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 00007ffeafcb6c1f R14: 00007fadb56a1300 R15: 0000000000022000
BTRFS error (device loop2): unsupported checksum algorithm 1
BTRFS error (device loop2): superblock checksum mismatch
EXT4-fs (loop1): mounted filesystem without journal. Opts: ,errors=continue
BTRFS error (device loop2): open_ctree failed
EXT4-fs error (device loop1): ext4_mb_generate_buddy:754: group 0, block bitmap and bg descriptor inconsistent: 25 vs 150994969 free clusters
EXT4-fs (loop1): Delayed block allocation failed for inode 15 at logical offset 0 with max blocks 1 with error 28
EXT4-fs (loop1): This should not happen!! Data will be lost

EXT4-fs (loop1): Total free blocks count 0
XFS (loop3): Superblock has unknown read-only compatible features (0x8) enabled.
EXT4-fs (loop1): Free/Dirty block details
EXT4-fs (loop1): free_blocks=2415919104
XFS (loop3): Attempted to mount read-only compatible filesystem read-write.
EXT4-fs (loop1): dirty_blocks=16
XFS (loop3): Filesystem can only be safely mounted read only.
EXT4-fs (loop1): Block reservation details
EXT4-fs (loop1): i_reserved_data_blocks=1
XFS (loop3): SB validate failed with error -22.
audit: type=1326 audit(1670803067.581:4): auid=4294967295 uid=0 gid=0 ses=4294967295 pid=9720 comm="syz-executor.5" exe="/root/syz-executor.5" sig=31 arch=c000003e syscall=202 compat=0 ip=0x7f63b658d0d9 code=0x0
EXT4-fs (loop1): mounted filesystem without journal. Opts: ,errors=continue
EXT4-fs error (device loop1): ext4_mb_generate_buddy:754: group 0, block bitmap and bg descriptor inconsistent: 25 vs 150994969 free clusters
EXT4-fs (loop1): Delayed block allocation failed for inode 15 at logical offset 0 with max blocks 1 with error 28
EXT4-fs (loop1): This should not happen!! Data will be lost

EXT4-fs (loop1): Total free blocks count 0
EXT4-fs (loop1): Free/Dirty block details
EXT4-fs (loop1): free_blocks=2415919104
EXT4-fs (loop1): dirty_blocks=16
EXT4-fs (loop1): Block reservation details
EXT4-fs (loop1): i_reserved_data_blocks=1
EXT4-fs (loop1): mounted filesystem without journal. Opts: ,errors=continue
EXT4-fs error (device loop1): ext4_mb_generate_buddy:754: group 0, block bitmap and bg descriptor inconsistent: 25 vs 150994969 free clusters
EXT4-fs (loop1): Delayed block allocation failed for inode 15 at logical offset 0 with max blocks 1 with error 28
EXT4-fs (loop1): This should not happen!! Data will be lost

EXT4-fs (loop1): Total free blocks count 0
EXT4-fs (loop1): Free/Dirty block details
EXT4-fs (loop1): free_blocks=2415919104
EXT4-fs (loop1): dirty_blocks=16
EXT4-fs (loop1): Block reservation details
EXT4-fs (loop1): i_reserved_data_blocks=1
REISERFS (device loop4): found reiserfs format "3.6" with non-standard journal
REISERFS (device loop4): using ordered data mode
EXT4-fs (loop1): mounted filesystem without journal. Opts: ,errors=continue
EXT4-fs error (device loop1): ext4_mb_generate_buddy:754: group 0, block bitmap and bg descriptor inconsistent: 25 vs 150994969 free clusters
reiserfs: using flush barriers
EXT4-fs (loop1): Delayed block allocation failed for inode 15 at logical offset 0 with max blocks 1 with error 28
EXT4-fs (loop1): This should not happen!! Data will be lost

REISERFS (device loop4): journal params: device loop4, size 512, journal first block 18, max trans len 256, max batch 225, max commit age 30, max trans age 30
EXT4-fs (loop1): Total free blocks count 0
EXT4-fs (loop1): Free/Dirty block details
EXT4-fs (loop1): free_blocks=2415919104
EXT4-fs (loop1): dirty_blocks=16
REISERFS (device loop4): checking transaction log (loop4)
EXT4-fs (loop1): Block reservation details
EXT4-fs (loop1): i_reserved_data_blocks=1
REISERFS (device loop4): Using r5 hash to sort names
REISERFS (device loop4): Created .reiserfs_priv - reserved for xattr storage.
x_tables: ip6_tables: TCPOPTSTRIP target: only valid in mangle table, not filter
autofs4:pid:9928:check_dev_ioctl_version: ioctl control interface version mismatch: kernel(1.1), user(7.1), cmd(0xc0189375)
NFQUEUE: number of total queues is 0
autofs4:pid:9928:validate_dev_ioctl: invalid device control module version supplied for cmd(0xc0189375)
autofs4:pid:9955:check_dev_ioctl_version: ioctl control interface version mismatch: kernel(1.1), user(1.139771547), cmd(0xc0189375)
autofs4:pid:9955:validate_dev_ioctl: invalid device control module version supplied for cmd(0xc0189375)
IPVS: ftp: loaded support on port[0] = 21
audit: type=1326 audit(1670803071.057:5): auid=4294967295 uid=0 gid=0 ses=4294967295 pid=10249 comm="syz-executor.5" exe="/root/syz-executor.5" sig=31 arch=c000003e syscall=202 compat=0 ip=0x7f63b658d0d9 code=0x0
IPVS: ftp: loaded support on port[0] = 21
EXT4-fs (loop2): mounted filesystem without journal. Opts: ,errors=continue
EXT4-fs error (device loop2): ext4_find_dest_de:1877: inode #12: block 32: comm syz-executor.2: bad entry in directory: directory entry overrun - offset=0, inode=12, rec_len=2316, name_len=0, size=2048
EXT4-fs error (device loop2): ext4_find_dest_de:1877: inode #12: block 32: comm syz-executor.2: bad entry in directory: directory entry overrun - offset=0, inode=12, rec_len=2316, name_len=0, size=2048
audit: type=1326 audit(1670803074.103:6): auid=4294967295 uid=0 gid=0 ses=4294967295 pid=10547 comm="syz-executor.0" exe="/root/syz-executor.0" sig=31 arch=c000003e syscall=202 compat=0 ip=0x7fadb712f0d9 code=0x0
autofs4:pid:10656:check_dev_ioctl_version: ioctl control interface version mismatch: kernel(1.1), user(768.1), cmd(0xc0189375)
autofs4:pid:10656:validate_dev_ioctl: invalid device control module version supplied for cmd(0xc0189375)