[syzbot] [btrfs?] WARNING: refcount bug in __btrfs_release_delayed_node

From: syzbot
Date: Mon Jun 26 2023 - 01:12:22 EST


Hello,

syzbot found the following issue on:

HEAD commit: 45a3e24f65e9 Linux 6.4-rc7
git tree: upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=12c15540a80000
kernel config: https://syzkaller.appspot.com/x/.config?x=2cbd298d0aff1140
dashboard link: https://syzkaller.appspot.com/bug?extid=2bf8c3b6bedb88990d40
compiler: gcc (Debian 10.2.1-6) 10.2.1 20210110, GNU ld (GNU Binutils for Debian) 2.35.2

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

Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/872a8054b07c/disk-45a3e24f.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/329227d8d5e9/vmlinux-45a3e24f.xz
kernel image: https://storage.googleapis.com/syzbot-assets/e6e7d7b9074e/bzImage-45a3e24f.xz

IMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by: syzbot+2bf8c3b6bedb88990d40@xxxxxxxxxxxxxxxxxxxxxxxxx

------------[ cut here ]------------
refcount_t: underflow; use-after-free.
WARNING: CPU: 1 PID: 5056 at lib/refcount.c:28 refcount_warn_saturate+0x107/0x1f0 lib/refcount.c:28
Modules linked in:
CPU: 1 PID: 5056 Comm: syz-executor.4 Not tainted 6.4.0-rc7-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 05/27/2023
RIP: 0010:refcount_warn_saturate+0x107/0x1f0 lib/refcount.c:28
Code: 1d c4 8b 51 0a 31 ff 89 de e8 f5 ef 70 fd 84 db 75 a3 e8 0c f4 70 fd 48 c7 c7 c0 d6 a6 8a c6 05 a4 8b 51 0a 01 e8 49 af 38 fd <0f> 0b eb 87 e8 f0 f3 70 fd 0f b6 1d 8d 8b 51 0a 31 ff 89 de e8 c0
RSP: 0018:ffffc900042cfa60 EFLAGS: 00010286
RAX: 0000000000000000 RBX: 0000000000000000 RCX: 0000000000000000
RDX: ffff8880286bbb80 RSI: ffffffff814c03b7 RDI: 0000000000000001
RBP: ffff8880275112f8 R08: 0000000000000001 R09: 0000000000000000
R10: 0000000000000001 R11: 0000000000082828 R12: ffff88802b4cf300
R13: ffff8880275112f8 R14: ffff888027511308 R15: ffff8880275111c8
FS: 0000555556773400(0000) GS:ffff8880b9900000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00007fcf1bad56be CR3: 000000003f591000 CR4: 0000000000350ee0
Call Trace:
<TASK>
__refcount_sub_and_test include/linux/refcount.h:283 [inline]
__refcount_dec_and_test include/linux/refcount.h:315 [inline]
refcount_dec_and_test include/linux/refcount.h:333 [inline]
__btrfs_release_delayed_node.part.0+0xb3b/0xf50 fs/btrfs/delayed-inode.c:263
__btrfs_release_delayed_node fs/btrfs/delayed-inode.c:251 [inline]
btrfs_release_delayed_node fs/btrfs/delayed-inode.c:281 [inline]
btrfs_remove_delayed_node+0x52/0x60 fs/btrfs/delayed-inode.c:1285
btrfs_evict_inode+0x4f4/0xe50 fs/btrfs/inode.c:5336
evict+0x2ed/0x6b0 fs/inode.c:665
dispose_list+0x117/0x1e0 fs/inode.c:698
evict_inodes+0x345/0x440 fs/inode.c:748
generic_shutdown_super+0xaf/0x480 fs/super.c:479
kill_anon_super+0x3a/0x60 fs/super.c:1107
btrfs_kill_super+0x3c/0x50 fs/btrfs/super.c:2144
deactivate_locked_super+0x98/0x160 fs/super.c:331
deactivate_super+0xb1/0xd0 fs/super.c:362
cleanup_mnt+0x2ae/0x3d0 fs/namespace.c:1177
task_work_run+0x16f/0x270 kernel/task_work.c:179
resume_user_mode_work include/linux/resume_user_mode.h:49 [inline]
exit_to_user_mode_loop kernel/entry/common.c:171 [inline]
exit_to_user_mode_prepare+0x210/0x240 kernel/entry/common.c:204
__syscall_exit_to_user_mode_work kernel/entry/common.c:286 [inline]
syscall_exit_to_user_mode+0x1d/0x50 kernel/entry/common.c:297
do_syscall_64+0x46/0xb0 arch/x86/entry/common.c:86
entry_SYSCALL_64_after_hwframe+0x63/0xcd
RIP: 0033:0x7f4b5f28d7f7
Code: ff ff ff f7 d8 64 89 01 48 83 c8 ff c3 66 0f 1f 44 00 00 31 f6 e9 09 00 00 00 66 0f 1f 84 00 00 00 00 00 b8 a6 00 00 00 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 b8 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007ffd5b600188 EFLAGS: 00000246 ORIG_RAX: 00000000000000a6
RAX: 0000000000000000 RBX: 0000000000000000 RCX: 00007f4b5f28d7f7
RDX: 00007ffd5b60025c RSI: 000000000000000a RDI: 00007ffd5b600250
RBP: 00007ffd5b600250 R08: 00000000ffffffff R09: 00007ffd5b600020
R10: 0000555556774893 R11: 0000000000000246 R12: 00007f4b5f2d643b
R13: 00007ffd5b601310 R14: 0000555556774810 R15: 00007ffd5b601350
</TASK>


---
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 syzkaller@xxxxxxxxxxxxxxxx.

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 change 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