syzbot


KASAN: slab-use-after-free Read in add_delayed_ref (3)

Status: moderation: reported on 2026/01/19 20:07
Subsystems: btrfs
[Documentation on labels]
Reported-by: syzbot+57896778dbeb96b56b68@syzkaller.appspotmail.com
First crash: 9d01h, last: 9d01h
Similar bugs (2)
Kernel Title Rank 🛈 Repro Cause bisect Fix bisect Count Last Reported Patched Status
upstream KASAN: slab-use-after-free Read in add_delayed_ref btrfs 19 C done 2 467d 467d 0/29 auto-obsoleted due to no activity on 2024/12/13 07:28
upstream KASAN: slab-use-after-free Read in add_delayed_ref (2) btrfs 19 2 303d 306d 0/29 auto-obsoleted due to no activity on 2025/06/25 21:14

Sample crash report:
BTRFS info (device loop0): balance: start -d -m
BTRFS info (device loop0): relocating block group 6881280 flags data|metadata
BTRFS info (device loop0): found 2 extents, stage: move data extents
BTRFS info (device loop0): found 1 extents, stage: update data pointers
BTRFS info (device loop0): relocating block group 5242880 flags data|metadata
==================================================================
BUG: KASAN: slab-use-after-free in do_perf_trace_btrfs_delayed_tree_ref include/trace/events/btrfs.h:850 [inline]
BUG: KASAN: slab-use-after-free in perf_trace_btrfs_delayed_tree_ref+0x299/0x590 include/trace/events/btrfs.h:850
Read of size 8 at addr ffff888040ef94f8 by task syz.0.0/5342

CPU: 0 UID: 0 PID: 5342 Comm: syz.0.0 Not tainted syzkaller #0 PREEMPT(full) 
Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.16.3-debian-1.16.3-2~bpo12+1 04/01/2014
Call Trace:
 <TASK>
 dump_stack_lvl+0xe8/0x150 lib/dump_stack.c:120
 print_address_description mm/kasan/report.c:378 [inline]
 print_report+0xca/0x240 mm/kasan/report.c:482
 kasan_report+0x118/0x150 mm/kasan/report.c:595
 do_perf_trace_btrfs_delayed_tree_ref include/trace/events/btrfs.h:850 [inline]
 perf_trace_btrfs_delayed_tree_ref+0x299/0x590 include/trace/events/btrfs.h:850
 __do_trace_add_delayed_tree_ref include/trace/events/btrfs.h:891 [inline]
 trace_add_delayed_tree_ref include/trace/events/btrfs.h:891 [inline]
 add_delayed_ref+0x1d25/0x1e70 fs/btrfs/delayed-ref.c:1089
 btrfs_free_tree_block+0x2b6/0xc00 fs/btrfs/extent-tree.c:3456
 btrfs_force_cow_block+0xfeb/0x2410 fs/btrfs/ctree.c:566
 btrfs_cow_block+0x3c4/0xa80 fs/btrfs/ctree.c:708
 btrfs_search_slot+0xd23/0x2ce0 fs/btrfs/ctree.c:2130
 relocate_cowonly_block fs/btrfs/relocation.c:2574 [inline]
 relocate_tree_blocks+0x124e/0x1fa0 fs/btrfs/relocation.c:2634
 relocate_block_group+0x76e/0xd70 fs/btrfs/relocation.c:3573
 btrfs_relocate_block_group+0x6b6/0xc70 fs/btrfs/relocation.c:3966
 btrfs_relocate_chunk+0x12f/0x5c0 fs/btrfs/volumes.c:3424
 __btrfs_balance+0x18ff/0x24e0 fs/btrfs/volumes.c:4197
 btrfs_balance+0xac2/0x11b0 fs/btrfs/volumes.c:4571
 btrfs_ioctl_balance+0x3d3/0x610 fs/btrfs/ioctl.c:3525
 vfs_ioctl fs/ioctl.c:51 [inline]
 __do_sys_ioctl fs/ioctl.c:597 [inline]
 __se_sys_ioctl+0xfc/0x170 fs/ioctl.c:583
 do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline]
 do_syscall_64+0xec/0xf80 arch/x86/entry/syscall_64.c:94
 entry_SYSCALL_64_after_hwframe+0x77/0x7f
RIP: 0033:0x7f632278f7c9
Code: ff ff c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 40 00 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 a8 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007f6323659038 EFLAGS: 00000246 ORIG_RAX: 0000000000000010
RAX: ffffffffffffffda RBX: 00007f63229e6090 RCX: 00007f632278f7c9
RDX: 0000200000000180 RSI: 00000000c4009420 RDI: 000000000000000b
RBP: 00007f6322813f91 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 00007f63229e6128 R14: 00007f63229e6090 R15: 00007fffee852978
 </TASK>

Allocated by task 5342:
 kasan_save_stack mm/kasan/common.c:57 [inline]
 kasan_save_track+0x3e/0x80 mm/kasan/common.c:78
 unpoison_slab_object mm/kasan/common.c:340 [inline]
 __kasan_slab_alloc+0x6c/0x80 mm/kasan/common.c:366
 kasan_slab_alloc include/linux/kasan.h:253 [inline]
 slab_post_alloc_hook mm/slub.c:4953 [inline]
 slab_alloc_node mm/slub.c:5263 [inline]
 kmem_cache_alloc_noprof+0x37d/0x710 mm/slub.c:5270
 add_delayed_ref+0x118/0x1e70 fs/btrfs/delayed-ref.c:1017
 btrfs_free_tree_block+0x2b6/0xc00 fs/btrfs/extent-tree.c:3456
 btrfs_force_cow_block+0xfeb/0x2410 fs/btrfs/ctree.c:566
 btrfs_cow_block+0x3c4/0xa80 fs/btrfs/ctree.c:708
 btrfs_search_slot+0xd23/0x2ce0 fs/btrfs/ctree.c:2130
 relocate_cowonly_block fs/btrfs/relocation.c:2574 [inline]
 relocate_tree_blocks+0x124e/0x1fa0 fs/btrfs/relocation.c:2634
 relocate_block_group+0x76e/0xd70 fs/btrfs/relocation.c:3573
 btrfs_relocate_block_group+0x6b6/0xc70 fs/btrfs/relocation.c:3966
 btrfs_relocate_chunk+0x12f/0x5c0 fs/btrfs/volumes.c:3424
 __btrfs_balance+0x18ff/0x24e0 fs/btrfs/volumes.c:4197
 btrfs_balance+0xac2/0x11b0 fs/btrfs/volumes.c:4571
 btrfs_ioctl_balance+0x3d3/0x610 fs/btrfs/ioctl.c:3525
 vfs_ioctl fs/ioctl.c:51 [inline]
 __do_sys_ioctl fs/ioctl.c:597 [inline]
 __se_sys_ioctl+0xfc/0x170 fs/ioctl.c:583
 do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline]
 do_syscall_64+0xec/0xf80 arch/x86/entry/syscall_64.c:94
 entry_SYSCALL_64_after_hwframe+0x77/0x7f

Freed by task 1046:
 kasan_save_stack mm/kasan/common.c:57 [inline]
 kasan_save_track+0x3e/0x80 mm/kasan/common.c:78
 kasan_save_free_info+0x46/0x50 mm/kasan/generic.c:584
 poison_slab_object mm/kasan/common.c:253 [inline]
 __kasan_slab_free+0x5c/0x80 mm/kasan/common.c:285
 kasan_slab_free include/linux/kasan.h:235 [inline]
 slab_free_hook mm/slub.c:2540 [inline]
 slab_free mm/slub.c:6670 [inline]
 kmem_cache_free+0x197/0x620 mm/slub.c:6781
 btrfs_run_delayed_refs_for_head fs/btrfs/extent-tree.c:1985 [inline]
 __btrfs_run_delayed_refs+0x1803/0x3af0 fs/btrfs/extent-tree.c:2048
 btrfs_run_delayed_refs+0xe6/0x3a0 fs/btrfs/extent-tree.c:2160
 flush_space+0x28f/0xd20 fs/btrfs/space-info.c:-1
 do_async_reclaim_metadata_space+0x11e/0x350 fs/btrfs/space-info.c:1185
 btrfs_async_reclaim_metadata_space+0x89/0xe0 fs/btrfs/space-info.c:1252
 process_one_work kernel/workqueue.c:3257 [inline]
 process_scheduled_works+0xad1/0x1770 kernel/workqueue.c:3340
 worker_thread+0x8a0/0xda0 kernel/workqueue.c:3421
 kthread+0x711/0x8a0 kernel/kthread.c:463
 ret_from_fork+0x510/0xa50 arch/x86/kernel/process.c:158
 ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:246

The buggy address belongs to the object at ffff888040ef94d0
 which belongs to the cache btrfs_delayed_ref_node of size 112
The buggy address is located 40 bytes inside of
 freed 112-byte region [ffff888040ef94d0, ffff888040ef9540)

The buggy address belongs to the physical page:
page: refcount:0 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x40ef9
flags: 0x4fff00000000000(node=1|zone=1|lastcpupid=0x7ff)
page_type: f5(slab)
raw: 04fff00000000000 ffff8880411738c0 dead000000000122 0000000000000000
raw: 0000000000000000 0000000080170017 00000000f5000000 0000000000000000
page dumped because: kasan: bad access detected
page_owner tracks the page as allocated
page last allocated via order 0, migratetype Unmovable, gfp_mask 0x52c40(GFP_NOFS|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP), pid 5342, tgid 5340 (syz.0.0), ts 87297097779, free_ts 39618639308
 set_page_owner include/linux/page_owner.h:32 [inline]
 post_alloc_hook+0x234/0x290 mm/page_alloc.c:1857
 prep_new_page mm/page_alloc.c:1865 [inline]
 get_page_from_freelist+0x24e0/0x2580 mm/page_alloc.c:3915
 __alloc_frozen_pages_noprof+0x181/0x370 mm/page_alloc.c:5210
 alloc_pages_mpol+0x232/0x4a0 mm/mempolicy.c:2486
 alloc_slab_page mm/slub.c:3075 [inline]
 allocate_slab+0x86/0x3b0 mm/slub.c:3248
 new_slab mm/slub.c:3302 [inline]
 ___slab_alloc+0xe53/0x1820 mm/slub.c:4656
 __slab_alloc+0x65/0x100 mm/slub.c:4779
 __slab_alloc_node mm/slub.c:4855 [inline]
 slab_alloc_node mm/slub.c:5251 [inline]
 kmem_cache_alloc_noprof+0x40f/0x710 mm/slub.c:5270
 add_delayed_ref+0x118/0x1e70 fs/btrfs/delayed-ref.c:1017
 btrfs_alloc_tree_block+0xcf8/0x1220 fs/btrfs/extent-tree.c:5208
 btrfs_force_cow_block+0x578/0x2410 fs/btrfs/ctree.c:517
 btrfs_cow_block+0x3c4/0xa80 fs/btrfs/ctree.c:708
 btrfs_search_slot+0xd23/0x2ce0 fs/btrfs/ctree.c:2130
 btrfs_update_root+0xea/0xea0 fs/btrfs/root-tree.c:144
 commit_fs_roots+0x56a/0x9a0 fs/btrfs/transaction.c:1531
 btrfs_commit_transaction+0x1014/0x3b10 fs/btrfs/transaction.c:2460
page last free pid 15 tgid 15 stack trace:
 reset_page_owner include/linux/page_owner.h:25 [inline]
 free_pages_prepare mm/page_alloc.c:1406 [inline]
 __free_frozen_pages+0xbc8/0xd30 mm/page_alloc.c:2943
 __tlb_remove_table_free mm/mmu_gather.c:227 [inline]
 tlb_remove_table_rcu+0x85/0x100 mm/mmu_gather.c:290
 rcu_do_batch kernel/rcu/tree.c:2605 [inline]
 rcu_core+0xc8e/0x1720 kernel/rcu/tree.c:2857
 handle_softirqs+0x22b/0x7c0 kernel/softirq.c:622
 run_ksoftirqd+0x36/0x60 kernel/softirq.c:1063
 smpboot_thread_fn+0x542/0xa60 kernel/smpboot.c:160
 kthread+0x711/0x8a0 kernel/kthread.c:463
 ret_from_fork+0x510/0xa50 arch/x86/kernel/process.c:158
 ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:246

Memory state around the buggy address:
 ffff888040ef9380: fb fb fb fb fb fb fb fb fb fb fb fb fc fc fc fc
 ffff888040ef9400: fc fc fc fc fa fb fb fb fb fb fb fb fb fb fb fb
>ffff888040ef9480: fb fb fc fc fc fc fc fc fc fc fa fb fb fb fb fb
                                                                ^
 ffff888040ef9500: fb fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc
 ffff888040ef9580: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 fc fc
==================================================================

Crashes (1):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2026/01/15 19:59 upstream 54e82e93ca93 d1b870e1 .config console log report [disk image (non-bootable)] [vmlinux] [kernel image] ci-snapshot-upstream-root KASAN: slab-use-after-free Read in add_delayed_ref
* Struck through repros no longer work on HEAD.