syzbot


KASAN: use-after-free Read in flush_space

Status: upstream: reported on 2025/10/21 07:43
Reported-by: syzbot+62ea0b38466b32838d94@syzkaller.appspotmail.com
First crash: 1d17h, last: 1d17h

Sample crash report:
BTRFS info (device loop5): chunk_block_rsv: size 0 reserved 0
BTRFS info (device loop5): delayed_block_rsv: size 0 reserved 0
BTRFS info (device loop5): delayed_refs_rsv: size 0 reserved 0
==================================================================
BUG: KASAN: use-after-free in flush_space+0x951/0xc50 fs/btrfs/space-info.c:701
Read of size 8 at addr ffff888078d198a0 by task kworker/u4:9/4589

CPU: 1 PID: 4589 Comm: kworker/u4:9 Not tainted syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 10/02/2025
Workqueue: events_unbound btrfs_async_reclaim_metadata_space
Call Trace:
 <TASK>
 dump_stack_lvl+0x168/0x230 lib/dump_stack.c:106
 print_address_description+0x60/0x2d0 mm/kasan/report.c:248
 __kasan_report mm/kasan/report.c:434 [inline]
 kasan_report+0xdf/0x130 mm/kasan/report.c:451
 flush_space+0x951/0xc50 fs/btrfs/space-info.c:701
 btrfs_async_reclaim_metadata_space+0x26f/0x330 fs/btrfs/space-info.c:953
 process_one_work+0x863/0x1000 kernel/workqueue.c:2310
 worker_thread+0xaa8/0x12a0 kernel/workqueue.c:2457
 kthread+0x436/0x520 kernel/kthread.c:334
 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:287
 </TASK>

Allocated by task 4816:
 kasan_save_stack mm/kasan/common.c:38 [inline]
 kasan_set_track mm/kasan/common.c:46 [inline]
 set_alloc_info mm/kasan/common.c:434 [inline]
 ____kasan_kmalloc mm/kasan/common.c:513 [inline]
 __kasan_kmalloc+0xb5/0xf0 mm/kasan/common.c:522
 kmalloc include/linux/slab.h:607 [inline]
 kzalloc include/linux/slab.h:738 [inline]
 create_space_info+0x57/0x610 fs/btrfs/space-info.c:191
 open_ctree+0x2183/0x3250 fs/btrfs/disk-io.c:3550
 btrfs_fill_super+0x1c2/0x2e0 fs/btrfs/super.c:1387
 btrfs_mount_root+0x857/0x8c0 fs/btrfs/super.c:1751
 legacy_get_tree+0xe6/0x180 fs/fs_context.c:611
 vfs_get_tree+0x88/0x270 fs/super.c:1530
 fc_mount fs/namespace.c:1005 [inline]
 vfs_kern_mount+0xba/0x150 fs/namespace.c:1035
 btrfs_mount+0x2d7/0xa50 fs/btrfs/super.c:1811
 legacy_get_tree+0xe6/0x180 fs/fs_context.c:611
 vfs_get_tree+0x88/0x270 fs/super.c:1530
 do_new_mount+0x24a/0xa40 fs/namespace.c:3034
 do_mount fs/namespace.c:3377 [inline]
 __do_sys_mount fs/namespace.c:3585 [inline]
 __se_sys_mount+0x2d6/0x3c0 fs/namespace.c:3562
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x4c/0xa0 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x66/0xd0

Freed by task 4411:
 kasan_save_stack mm/kasan/common.c:38 [inline]
 kasan_set_track+0x4b/0x70 mm/kasan/common.c:46
 kasan_set_free_info+0x1f/0x40 mm/kasan/generic.c:360
 ____kasan_slab_free+0xd5/0x110 mm/kasan/common.c:366
 kasan_slab_free include/linux/kasan.h:230 [inline]
 slab_free_hook mm/slub.c:1710 [inline]
 slab_free_freelist_hook+0xea/0x170 mm/slub.c:1736
 slab_free mm/slub.c:3504 [inline]
 kfree+0xef/0x2a0 mm/slub.c:4564
 kobject_cleanup lib/kobject.c:713 [inline]
 kobject_release lib/kobject.c:744 [inline]
 kref_put include/linux/kref.h:65 [inline]
 kobject_put+0x21d/0x460 lib/kobject.c:761
 btrfs_free_block_groups+0xb98/0xcc0 fs/btrfs/block-group.c:4018
 close_ctree+0x706/0x8c0 fs/btrfs/disk-io.c:4528
 generic_shutdown_super+0x130/0x300 fs/super.c:475
 kill_anon_super+0x36/0x70 fs/super.c:1089
 btrfs_kill_super+0x3d/0x50 fs/btrfs/super.c:2390
 deactivate_locked_super+0x93/0xf0 fs/super.c:335
 cleanup_mnt+0x418/0x4d0 fs/namespace.c:1148
 task_work_run+0x125/0x1a0 kernel/task_work.c:188
 tracehook_notify_resume include/linux/tracehook.h:189 [inline]
 exit_to_user_mode_loop+0x10f/0x130 kernel/entry/common.c:181
 exit_to_user_mode_prepare+0xee/0x180 kernel/entry/common.c:214
 __syscall_exit_to_user_mode_work kernel/entry/common.c:296 [inline]
 syscall_exit_to_user_mode+0x16/0x40 kernel/entry/common.c:307
 do_syscall_64+0x58/0xa0 arch/x86/entry/common.c:86
 entry_SYSCALL_64_after_hwframe+0x66/0xd0

The buggy address belongs to the object at ffff888078d19800
 which belongs to the cache kmalloc-1k of size 1024
The buggy address is located 160 bytes inside of
 1024-byte region [ffff888078d19800, ffff888078d19c00)
The buggy address belongs to the page:
page:ffffea0001e34600 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x78d18
head:ffffea0001e34600 order:3 compound_mapcount:0 compound_pincount:0
flags: 0xfff00000010200(slab|head|node=0|zone=1|lastcpupid=0x7ff)
raw: 00fff00000010200 ffffea0000697a00 0000000500000005 ffff888016841dc0
raw: 0000000000000000 0000000000100010 00000001ffffffff 0000000000000000
page dumped because: kasan: bad access detected
page_owner tracks the page as allocated
page last allocated via order 3, migratetype Unmovable, gfp_mask 0xd20c0(__GFP_IO|__GFP_FS|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_NOMEMALLOC), pid 4185, ts 71351480326, free_ts 70775664870
 prep_new_page mm/page_alloc.c:2426 [inline]
 get_page_from_freelist+0x1b77/0x1c60 mm/page_alloc.c:4192
 __alloc_pages+0x1e1/0x470 mm/page_alloc.c:5487
 alloc_slab_page mm/slub.c:1780 [inline]
 allocate_slab mm/slub.c:1917 [inline]
 new_slab+0xc0/0x4b0 mm/slub.c:1980
 ___slab_alloc+0x81e/0xdf0 mm/slub.c:3013
 __slab_alloc mm/slub.c:3100 [inline]
 slab_alloc_node mm/slub.c:3191 [inline]
 __kmalloc_node+0x200/0x3b0 mm/slub.c:4456
 kmalloc_node include/linux/slab.h:630 [inline]
 kzalloc_node include/linux/slab.h:749 [inline]
 qdisc_alloc+0x8d/0xb10 net/sched/sch_generic.c:888
 qdisc_create_dflt+0x5f/0x430 net/sched/sch_generic.c:950
 attach_one_default_qdisc net/sched/sch_generic.c:1113 [inline]
 netdev_for_each_tx_queue include/linux/netdevice.h:2379 [inline]
 attach_default_qdiscs net/sched/sch_generic.c:1131 [inline]
 dev_activate+0x331/0x12b0 net/sched/sch_generic.c:1190
 __dev_open+0x32c/0x420 net/core/dev.c:1546
 __dev_change_flags+0x20a/0x6a0 net/core/dev.c:8853
 dev_change_flags+0x82/0x1a0 net/core/dev.c:8924
 do_setlink+0xc01/0x3980 net/core/rtnetlink.c:2779
 __rtnl_newlink net/core/rtnetlink.c:3450 [inline]
 rtnl_newlink+0x1419/0x17d0 net/core/rtnetlink.c:3572
 rtnetlink_rcv_msg+0x9b9/0xe60 net/core/rtnetlink.c:5650
 netlink_rcv_skb+0x1e0/0x430 net/netlink/af_netlink.c:2507
 netlink_unicast_kernel net/netlink/af_netlink.c:1318 [inline]
 netlink_unicast+0x774/0x920 net/netlink/af_netlink.c:1344
page last free stack trace:
 reset_page_owner include/linux/page_owner.h:24 [inline]
 free_pages_prepare mm/page_alloc.c:1340 [inline]
 free_pcp_prepare mm/page_alloc.c:1391 [inline]
 free_unref_page_prepare+0x637/0x6c0 mm/page_alloc.c:3317
 free_unref_page+0x94/0x280 mm/page_alloc.c:3396
 free_slab mm/slub.c:2020 [inline]
 discard_slab mm/slub.c:2026 [inline]
 __unfreeze_partials+0x1a5/0x200 mm/slub.c:2512
 put_cpu_partial+0x12d/0x190 mm/slub.c:2592
 qlist_free_all+0x35/0x90 mm/kasan/quarantine.c:176
 kasan_quarantine_reduce+0x150/0x160 mm/kasan/quarantine.c:283
 __kasan_slab_alloc+0x2f/0xd0 mm/kasan/common.c:444
 kasan_slab_alloc include/linux/kasan.h:254 [inline]
 slab_post_alloc_hook+0x4c/0x380 mm/slab.h:519
 slab_alloc_node mm/slub.c:3225 [inline]
 slab_alloc mm/slub.c:3233 [inline]
 kmem_cache_alloc_trace+0x103/0x2a0 mm/slub.c:3250
 kmalloc include/linux/slab.h:607 [inline]
 kzalloc include/linux/slab.h:738 [inline]
 ____ip_mc_inc_group+0x2ad/0xac0 net/ipv4/igmp.c:1452
 __ip_mc_inc_group net/ipv4/igmp.c:1487 [inline]
 ip_mc_inc_group net/ipv4/igmp.c:1493 [inline]
 ip_mc_up+0x121/0x2f0 net/ipv4/igmp.c:1792
 inetdev_event+0xe02/0x1360 net/ipv4/devinet.c:1586
 notifier_call_chain kernel/notifier.c:83 [inline]
 raw_notifier_call_chain+0xcb/0x160 kernel/notifier.c:391
 call_netdevice_notifiers_extack net/core/dev.c:2061 [inline]
 call_netdevice_notifiers net/core/dev.c:2075 [inline]
 __dev_notify_flags+0x178/0x2d0 net/core/dev.c:-1
 dev_change_flags+0xe3/0x1a0 net/core/dev.c:8929
 do_setlink+0xc01/0x3980 net/core/rtnetlink.c:2779

Memory state around the buggy address:
 ffff888078d19780: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
 ffff888078d19800: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff888078d19880: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                               ^
 ffff888078d19900: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff888078d19980: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================

Crashes (1):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2025/10/21 07:42 linux-5.15.y ac56c046adf4 9832ed61 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan KASAN: use-after-free Read in flush_space
* Struck through repros no longer work on HEAD.