  running recovery pass check_extents_to_backpointers (17), currently at delete_dead_snapshots (26)
==================================================================
BUG: KASAN: slab-use-after-free in bch2_copygc+0x105d/0x4510
Read of size 8 at addr ffff8881076963e0 by task bch-copygc/loop/6680

CPU: 0 UID: 0 PID: 6680 Comm: bch-copygc/loop Not tainted 6.16.0-syzkaller-11895-gcca7a0aae895 #0 PREEMPT(full) 
Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.16.2-debian-1.16.2-1 04/01/2014
Call Trace:
 <TASK>
 dump_stack_lvl+0x189/0x250
 print_report+0xca/0x240
 kasan_report+0x118/0x150
 kasan_check_range+0x2b0/0x2c0
 bch2_copygc+0x105d/0x4510
 bch2_copygc_thread+0x97a/0xe00
 kthread+0x711/0x8a0
 ret_from_fork+0x3fc/0x770
 ret_from_fork_asm+0x1a/0x30
 </TASK>

Allocated by task 6680:
 kasan_save_track+0x3e/0x80
 __kasan_kmalloc+0x93/0xb0
 __kvmalloc_node_noprof+0x30d/0x5f0
 bch2_bucket_bitmap_set+0x9a/0x1d0
 check_bucket_backpointer_mismatch+0x1bdf/0x23a0
 bch2_check_bucket_backpointer_mismatch+0x36c/0x690
 __bch2_move_data_phys+0x17a7/0x1c50
 bch2_evacuate_bucket+0x228/0x3a0
 bch2_copygc+0x3be3/0x4510
 bch2_copygc_thread+0x97a/0xe00
 kthread+0x711/0x8a0
 ret_from_fork+0x3fc/0x770
 ret_from_fork_asm+0x1a/0x30

Freed by task 6665:
 kasan_save_track+0x3e/0x80
 kasan_save_free_info+0x46/0x50
 __kasan_slab_free+0x5b/0x80
 kfree+0x18e/0x440
 bch2_check_extents_to_backpointers+0x2840/0x2bc0
 __bch2_run_recovery_passes+0x3bd/0x1060
 bch2_run_recovery_passes+0x184/0x210
 bch2_fs_recovery+0x2690/0x3a50
 bch2_fs_start+0xaaf/0xda0
 bch2_fs_get_tree+0xb39/0x1520
 vfs_get_tree+0x92/0x2b0
 do_new_mount+0x2a2/0x9e0
 __se_sys_mount+0x317/0x410
 do_syscall_64+0xfa/0x3b0
 entry_SYSCALL_64_after_hwframe+0x77/0x7f

The buggy address belongs to the object at ffff8881076963e0
 which belongs to the cache kmalloc-16 of size 16
The buggy address is located 0 bytes inside of
 freed 16-byte region [ffff8881076963e0, ffff8881076963f0)

The buggy address belongs to the physical page:
page: refcount:0 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x107696
anon flags: 0x57ff00000000000(node=1|zone=2|lastcpupid=0x7ff)
page_type: f5(slab)
raw: 057ff00000000000 ffff88801a441640 0000000000000000 0000000000000001
raw: 0000000000000000 0000000080800080 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 6563, tgid 6562 (syz.3.148), ts 87961515747, free_ts 86948415686
 post_alloc_hook+0x240/0x2a0
 get_page_from_freelist+0x21e4/0x22c0
 __alloc_frozen_pages_noprof+0x181/0x370
 alloc_pages_mpol+0x232/0x4a0
 allocate_slab+0x8a/0x370
 ___slab_alloc+0xbeb/0x1410
 __kmalloc_node_track_caller_noprof+0x2f8/0x4e0
 krealloc_noprof+0x124/0x340
 bch2_printbuf_make_room+0x1f5/0x360
 bch2_prt_printf+0x282/0x740
 bch2_sb_validate+0xf73/0x1980
 bch2_write_super+0xd68/0x2d30
 bch2_gc_mark_key+0x9f0/0xd30
 bch2_check_allocations+0x2141/0x57b0
 __bch2_run_recovery_passes+0x3bd/0x1060
 bch2_run_recovery_passes+0x184/0x210
page last free pid 6461 tgid 6459 stack trace:
 __free_frozen_pages+0xbc4/0xd30
 vfree+0x25a/0x400
 snd_pcm_lib_free_pages+0x250/0x2e0
 snd_pcm_release_substream+0x2b7/0x480
 snd_pcm_oss_release+0x144/0x250
 __fput+0x44c/0xa70
 task_work_run+0x1d4/0x260
 do_exit+0x6b5/0x2300
 do_group_exit+0x21c/0x2d0
 get_signal+0x1286/0x1340
 arch_do_signal_or_restart+0x9a/0x750
 exit_to_user_mode_loop+0x75/0x110
 do_syscall_64+0x2bd/0x3b0
 entry_SYSCALL_64_after_hwframe+0x77/0x7f

Memory state around the buggy address:
 ffff888107696280: fa fb fc fc fa fb fc fc fa fb fc fc fa fb fc fc
 ffff888107696300: fa fb fc fc fa fb fc fc fa fb fc fc fa fb fc fc
>ffff888107696380: fa fb fc fc fa fb fc fc 00 00 fc fc fa fb fc fc
                                                       ^
 ffff888107696400: fa fb fc fc 00 00 fc fc 00 00 fc fc fa fb fc fc
 ffff888107696480: 00 00 fc fc fa fb fc fc fa fb fc fc fa fb fc fc
==================================================================
