WARNING in btrfs_block_rsv_release

From: Sanan Hasanov
Date: Tue Sep 12 2023 - 19:03:12 EST


Good day, dear maintainers,

We found a bug using a modified kernel configuration file used by syzbot.

We enhanced the coverage of the configuration file using our tool, klocalizer.

Kernel Branch: 6.3.0-next-20230426
Kernel Config: https://drive.google.com/file/d/1Y_qd41rAEHHmgd0soinXzReeRKvUEq6m/view?usp=sharing
Reproducer: https://drive.google.com/file/d/1ydCeL6Dr0aawrcj3vSzoqhBJFozeE8PK/view?usp=sharing
Thank you!

Best regards,
Sanan Hasanov

------------[ cut here ]------------
WARNING: CPU: 1 PID: 7400 at fs/btrfs/space-info.h:197 btrfs_space_info_update_bytes_may_use fs/btrfs/space-info.h:197 [inline]
WARNING: CPU: 1 PID: 7400 at fs/btrfs/space-info.h:197 btrfs_space_info_free_bytes_may_use fs/btrfs/space-info.h:229 [inline]
WARNING: CPU: 1 PID: 7400 at fs/btrfs/space-info.h:197 block_rsv_release_bytes fs/btrfs/block-rsv.c:153 [inline]
WARNING: CPU: 1 PID: 7400 at fs/btrfs/space-info.h:197 btrfs_block_rsv_release+0x6c6/0x890 fs/btrfs/block-rsv.c:297
Modules linked in:
CPU: 1 PID: 7400 Comm: syz-executor.1 Not tainted 6.3.0-next-20230426 #1
Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.15.0-1 04/01/2014
RIP: 0010:btrfs_space_info_update_bytes_may_use fs/btrfs/space-info.h:197 [inline]
RIP: 0010:btrfs_space_info_free_bytes_may_use fs/btrfs/space-info.h:229 [inline]
RIP: 0010:block_rsv_release_bytes fs/btrfs/block-rsv.c:153 [inline]
RIP: 0010:btrfs_block_rsv_release+0x6c6/0x890 fs/btrfs/block-rsv.c:297
Code: 3c 02 00 0f 85 c7 01 00 00 48 8b 04 24 4c 89 ee 48 8b 58 60 48 89 df e8 88 9b 05 fe 4c 39 eb 0f 83 79 ff ff ff e8 ba 9f 05 fe <0f> 0b 31 db e9 73 ff ff ff e8 ac 9f 05 fe 48 8b 04 24 be ff ff ff
RSP: 0018:ffffc9000f457af8 EFLAGS: 00010293
RAX: 0000000000000000 RBX: 00000000000df000 RCX: 0000000000000000
RDX: ffff888116420000 RSI: ffffffff837be876 RDI: 0000000000000006
RBP: ffff8881151d8000 R08: 0000000000000006 R09: 00000000000df000
R10: 00000000000e0000 R11: 0000000000000001 R12: 00000000000e0000
R13: 00000000000e0000 R14: ffff888064cf2060 R15: 0000000000000000
FS: 0000555556a26980(0000) GS:ffff888119c80000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00007f493c197878 CR3: 0000000058101000 CR4: 0000000000350ee0
Call Trace:
<TASK>
btrfs_release_global_block_rsv+0x26/0x2e0 fs/btrfs/block-rsv.c:440
btrfs_free_block_groups+0xa0c/0x11d0 fs/btrfs/block-group.c:4278
close_ctree+0x550/0xda0 fs/btrfs/disk-io.c:4649
generic_shutdown_super+0x158/0x480 fs/super.c:500
kill_anon_super+0x3a/0x60 fs/super.c:1107
btrfs_kill_super+0x3c/0x50 fs/btrfs/super.c:2133
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+0x168/0x260 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/0x80 arch/x86/entry/common.c:86
entry_SYSCALL_64_after_hwframe+0x63/0xcd
RIP: 0033:0x7fbdbe69173b
Code: ff ff ff f7 d8 64 89 01 48 83 c8 ff c3 66 90 f3 0f 1e fa 31 f6 e9 05 00 00 00 0f 1f 44 00 00 f3 0f 1e fa 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:00007ffc3fd6bce8 EFLAGS: 00000246 ORIG_RAX: 00000000000000a6
RAX: 0000000000000000 RBX: 0000000000000000 RCX: 00007fbdbe69173b
RDX: 00007fbdbe628c20 RSI: 000000000000000a RDI: 00007ffc3fd6bdb0
RBP: 00007ffc3fd6bdb0 R08: 00007fbdbe6fb54e R09: 00007ffc3fd6bb70
R10: 00000000fffffffb R11: 0000000000000246 R12: 00007fbdbe6fb527
R13: 00007ffc3fd6ce50 R14: 0000555556a27d90 R15: 0000000000000032
</TASK>
irq event stamp: 687881
hardirqs last enabled at (687891): [<ffffffff8165e22e>] __up_console_sem+0xae/0xc0 kernel/printk/printk.c:347
hardirqs last disabled at (687900): [<ffffffff8165e213>] __up_console_sem+0x93/0xc0 kernel/printk/printk.c:345
softirqs last enabled at (687718): [<ffffffff814b94bd>] invoke_softirq kernel/softirq.c:445 [inline]
softirqs last enabled at (687718): [<ffffffff814b94bd>] __irq_exit_rcu+0x11d/0x190 kernel/softirq.c:650
softirqs last disabled at (687703): [<ffffffff814b94bd>] invoke_softirq kernel/softirq.c:445 [inline]
softirqs last disabled at (687703): [<ffffffff814b94bd>] __irq_exit_rcu+0x11d/0x190 kernel/softirq.c:650
---[ end trace 0000000000000000 ]---
------------[ cut here ]------------
WARNING: CPU: 1 PID: 7400 at fs/btrfs/space-info.h:197 btrfs_space_info_update_bytes_may_use fs/btrfs/space-info.h:197 [inline]
WARNING: CPU: 1 PID: 7400 at fs/btrfs/space-info.h:197 btrfs_space_info_free_bytes_may_use fs/btrfs/space-info.h:229 [inline]
WARNING: CPU: 1 PID: 7400 at fs/btrfs/space-info.h:197 block_rsv_release_bytes fs/btrfs/block-rsv.c:153 [inline]
WARNING: CPU: 1 PID: 7400 at fs/btrfs/space-info.h:197 btrfs_block_rsv_release+0x6c6/0x890 fs/btrfs/block-rsv.c:297
Modules linked in:
CPU: 1 PID: 7400 Comm: syz-executor.1 Tainted: G W 6.3.0-next-20230426 #1
Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.15.0-1 04/01/2014
RIP: 0010:btrfs_space_info_update_bytes_may_use fs/btrfs/space-info.h:197 [inline]
RIP: 0010:btrfs_space_info_free_bytes_may_use fs/btrfs/space-info.h:229 [inline]
RIP: 0010:block_rsv_release_bytes fs/btrfs/block-rsv.c:153 [inline]
RIP: 0010:btrfs_block_rsv_release+0x6c6/0x890 fs/btrfs/block-rsv.c:297
Code: 3c 02 00 0f 85 c7 01 00 00 48 8b 04 24 4c 89 ee 48 8b 58 60 48 89 df e8 88 9b 05 fe 4c 39 eb 0f 83 79 ff ff ff e8 ba 9f 05 fe <0f> 0b 31 db e9 73 ff ff ff e8 ac 9f 05 fe 48 8b 04 24 be ff ff ff
RSP: 0018:ffffc9000f457af8 EFLAGS: 00010293
RAX: 0000000000000000 RBX: 00000000000df000 RCX: 0000000000000000
RDX: ffff888116420000 RSI: ffffffff837be876 RDI: 0000000000000006
RBP: ffff88804e3b8000 R08: 0000000000000006 R09: 00000000000df000
R10: 00000000000e0000 R11: 0000000000000001 R12: 00000000000e0000
R13: 00000000000e0000 R14: ffff888041a5f860 R15: 0000000000000000
FS: 0000555556a26980(0000) GS:ffff888119c80000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00007f6d86215d78 CR3: 0000000058101000 CR4: 0000000000350ee0
Call Trace:
<TASK>
btrfs_release_global_block_rsv+0x26/0x2e0 fs/btrfs/block-rsv.c:440
btrfs_free_block_groups+0xa0c/0x11d0 fs/btrfs/block-group.c:4278
close_ctree+0x550/0xda0 fs/btrfs/disk-io.c:4649
generic_shutdown_super+0x158/0x480 fs/super.c:500
kill_anon_super+0x3a/0x60 fs/super.c:1107
btrfs_kill_super+0x3c/0x50 fs/btrfs/super.c:2133
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+0x168/0x260 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/0x80 arch/x86/entry/common.c:86
entry_SYSCALL_64_after_hwframe+0x63/0xcd
RIP: 0033:0x7fbdbe69173b
Code: ff ff ff f7 d8 64 89 01 48 83 c8 ff c3 66 90 f3 0f 1e fa 31 f6 e9 05 00 00 00 0f 1f 44 00 00 f3 0f 1e fa 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:00007ffc3fd6bce8 EFLAGS: 00000246 ORIG_RAX: 00000000000000a6
RAX: 0000000000000000 RBX: 0000000000000000 RCX: 00007fbdbe69173b
RDX: 00007fbdbe628c20 RSI: 000000000000000a RDI: 00007ffc3fd6bdb0
RBP: 00007ffc3fd6bdb0 R08: 00007fbdbe6fb54e R09: 00007ffc3fd6bb70
R10: 00000000fffffffb R11: 0000000000000246 R12: 00007fbdbe6fb527
R13: 00007ffc3fd6ce50 R14: 0000555556a27d90 R15: 0000000000000032
</TASK>
irq event stamp: 698649
hardirqs last enabled at (698659): [<ffffffff8165e22e>] __up_console_sem+0xae/0xc0 kernel/printk/printk.c:347
hardirqs last disabled at (698670): [<ffffffff8165e213>] __up_console_sem+0x93/0xc0 kernel/printk/printk.c:345
softirqs last enabled at (698296): [<ffffffff814b94bd>] invoke_softirq kernel/softirq.c:445 [inline]
softirqs last enabled at (698296): [<ffffffff814b94bd>] __irq_exit_rcu+0x11d/0x190 kernel/softirq.c:650
softirqs last disabled at (698181): [<ffffffff814b94bd>] invoke_softirq kernel/softirq.c:445 [inline]
softirqs last disabled at (698181): [<ffffffff814b94bd>] __irq_exit_rcu+0x11d/0x190 kernel/softirq.c:650
---[ end trace 0000000000000000 ]---
------------[ cut here ]------------
WARNING: CPU: 3 PID: 7400 at fs/btrfs/space-info.h:197 btrfs_space_info_update_bytes_may_use fs/btrfs/space-info.h:197 [inline]
WARNING: CPU: 3 PID: 7400 at fs/btrfs/space-info.h:197 btrfs_space_info_free_bytes_may_use fs/btrfs/space-info.h:229 [inline]
WARNING: CPU: 3 PID: 7400 at fs/btrfs/space-info.h:197 block_rsv_release_bytes fs/btrfs/block-rsv.c:153 [inline]
WARNING: CPU: 3 PID: 7400 at fs/btrfs/space-info.h:197 btrfs_block_rsv_release+0x6c6/0x890 fs/btrfs/block-rsv.c:297
Modules linked in:
CPU: 3 PID: 7400 Comm: syz-executor.1 Tainted: G W 6.3.0-next-20230426 #1
Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.15.0-1 04/01/2014
RIP: 0010:btrfs_space_info_update_bytes_may_use fs/btrfs/space-info.h:197 [inline]
RIP: 0010:btrfs_space_info_free_bytes_may_use fs/btrfs/space-info.h:229 [inline]
RIP: 0010:block_rsv_release_bytes fs/btrfs/block-rsv.c:153 [inline]
RIP: 0010:btrfs_block_rsv_release+0x6c6/0x890 fs/btrfs/block-rsv.c:297
Code: 3c 02 00 0f 85 c7 01 00 00 48 8b 04 24 4c 89 ee 48 8b 58 60 48 89 df e8 88 9b 05 fe 4c 39 eb 0f 83 79 ff ff ff e8 ba 9f 05 fe <0f> 0b 31 db e9 73 ff ff ff e8 ac 9f 05 fe 48 8b 04 24 be ff ff ff
RSP: 0018:ffffc9000f457af8 EFLAGS: 00010293
RAX: 0000000000000000 RBX: 00000000000df000 RCX: 0000000000000000
RDX: ffff888116420000 RSI: ffffffff837be876 RDI: 0000000000000006
RBP: ffff888112680000 R08: 0000000000000006 R09: 00000000000df000
R10: 00000000000e0000 R11: 0000000000000001 R12: 00000000000e0000
R13: 00000000000e0000 R14: ffff888064033060 R15: 0000000000000000
FS: 0000555556a26980(0000) GS:ffff888119d80000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00007fca667985f8 CR3: 0000000058101000 CR4: 0000000000350ee0
Call Trace:
<TASK>
btrfs_release_global_block_rsv+0x26/0x2e0 fs/btrfs/block-rsv.c:440
btrfs_free_block_groups+0xa0c/0x11d0 fs/btrfs/block-group.c:4278
close_ctree+0x550/0xda0 fs/btrfs/disk-io.c:4649
generic_shutdown_super+0x158/0x480 fs/super.c:500
kill_anon_super+0x3a/0x60 fs/super.c:1107
btrfs_kill_super+0x3c/0x50 fs/btrfs/super.c:2133
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+0x168/0x260 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/0x80 arch/x86/entry/common.c:86
entry_SYSCALL_64_after_hwframe+0x63/0xcd
RIP: 0033:0x7fbdbe69173b
Code: ff ff ff f7 d8 64 89 01 48 83 c8 ff c3 66 90 f3 0f 1e fa 31 f6 e9 05 00 00 00 0f 1f 44 00 00 f3 0f 1e fa 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:00007ffc3fd6bce8 EFLAGS: 00000246 ORIG_RAX: 00000000000000a6
RAX: 0000000000000000 RBX: 0000000000000000 RCX: 00007fbdbe69173b
RDX: 00007fbdbe628c20 RSI: 000000000000000a RDI: 00007ffc3fd6bdb0
RBP: 00007ffc3fd6bdb0 R08: 00007fbdbe6fb54e R09: 00007ffc3fd6bb70
R10: 00000000fffffffb R11: 0000000000000246 R12: 00007fbdbe6fb527
R13: 00007ffc3fd6ce50 R14: 0000555556a27d90 R15: 0000000000000032
</TASK>
irq event stamp: 709525
hardirqs last enabled at (709535): [<ffffffff8165e22e>] __up_console_sem+0xae/0xc0 kernel/printk/printk.c:347
hardirqs last disabled at (709544): [<ffffffff8165e213>] __up_console_sem+0x93/0xc0 kernel/printk/printk.c:345
softirqs last enabled at (709404): [<ffffffff814b94bd>] invoke_softirq kernel/softirq.c:445 [inline]
softirqs last enabled at (709404): [<ffffffff814b94bd>] __irq_exit_rcu+0x11d/0x190 kernel/softirq.c:650
softirqs last disabled at (709235): [<ffffffff814b94bd>] invoke_softirq kernel/softirq.c:445 [inline]
softirqs last disabled at (709235): [<ffffffff814b94bd>] __irq_exit_rcu+0x11d/0x190 kernel/softirq.c:650
---[ end trace 0000000000000000 ]---