================================================================== BUG: KASAN: slab-out-of-bounds in __bch2_alloc_to_v4+0x7b/0x8b0 fs/bcachefs/alloc_background.c:388 Read of size 64 at addr ffff888054c95728 by task kworker/u4:3/43 CPU: 0 UID: 0 PID: 43 Comm: kworker/u4:3 Not tainted 6.16.0-rc4-syzkaller-00049-gb4911fb0b060 #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 Workqueue: btree_update btree_interior_update_work Call Trace: dump_stack_lvl+0x189/0x250 lib/dump_stack.c:120 print_address_description mm/kasan/report.c:408 [inline] print_report+0xd2/0x2b0 mm/kasan/report.c:521 kasan_report+0x118/0x150 mm/kasan/report.c:634 check_region_inline mm/kasan/generic.c:-1 [inline] kasan_check_range+0x2b0/0x2c0 mm/kasan/generic.c:189 __asan_memcpy+0x29/0x70 mm/kasan/shadow.c:105 __bch2_alloc_to_v4+0x7b/0x8b0 fs/bcachefs/alloc_background.c:388 bch2_alloc_to_v4 fs/bcachefs/alloc_background.h:236 [inline] bch2_trigger_alloc+0x323/0x4090 fs/bcachefs/alloc_background.c:871 run_one_trans_trigger fs/bcachefs/btree_trans_commit.c:-1 [inline] bch2_trans_commit_run_triggers fs/bcachefs/btree_trans_commit.c:554 [inline] __bch2_trans_commit+0xa84/0x8870 fs/bcachefs/btree_trans_commit.c:1023 bch2_trans_commit fs/bcachefs/btree_update.h:241 [inline] btree_update_nodes_written fs/bcachefs/btree_update_interior.c:729 [inline] btree_interior_update_work+0x1082/0x27d0 fs/bcachefs/btree_update_interior.c:867 process_one_work kernel/workqueue.c:3238 [inline] process_scheduled_works+0xade/0x17b0 kernel/workqueue.c:3321 worker_thread+0x8a0/0xda0 kernel/workqueue.c:3402 kthread+0x70e/0x8a0 kernel/kthread.c:464 ret_from_fork+0x3fc/0x770 arch/x86/kernel/process.c:148 ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:245 Allocated by task 5321: kasan_save_stack mm/kasan/common.c:47 [inline] kasan_save_track+0x3e/0x80 mm/kasan/common.c:68 poison_kmalloc_redzone mm/kasan/common.c:377 [inline] __kasan_kmalloc+0x93/0xb0 mm/kasan/common.c:394 kasan_kmalloc include/linux/kasan.h:260 [inline] __do_kmalloc_node mm/slub.c:4328 [inline] __kmalloc_noprof+0x27a/0x4f0 mm/slub.c:4340 kmalloc_noprof include/linux/slab.h:909 [inline] bch2_journal_key_insert+0x50/0x140 fs/bcachefs/btree_journal_iter.c:342 do_bch2_trans_commit_to_journal_replay+0x127/0xd70 fs/bcachefs/btree_trans_commit.c:966 __bch2_trans_commit+0x1b67/0x8870 fs/bcachefs/btree_trans_commit.c:1030 bch2_trans_commit fs/bcachefs/btree_update.h:241 [inline] bch2_gc_alloc_done fs/bcachefs/btree_gc.c:951 [inline] bch2_check_allocations+0x2ee0/0x57b0 fs/bcachefs/btree_gc.c:1100 bch2_run_recovery_pass fs/bcachefs/recovery_passes.c:484 [inline] __bch2_run_recovery_passes+0x392/0x1010 fs/bcachefs/recovery_passes.c:539 bch2_run_recovery_passes+0x184/0x210 fs/bcachefs/recovery_passes.c:610 bch2_fs_recovery+0x2690/0x3a50 fs/bcachefs/recovery.c:1005 bch2_fs_start+0xa99/0xd90 fs/bcachefs/super.c:1212 bch2_fs_get_tree+0xafc/0x14f0 fs/bcachefs/fs.c:2490 vfs_get_tree+0x92/0x2b0 fs/super.c:1804 do_new_mount+0x24a/0xa40 fs/namespace.c:3902 do_mount fs/namespace.c:4239 [inline] __do_sys_mount fs/namespace.c:4450 [inline] __se_sys_mount+0x317/0x410 fs/namespace.c:4427 do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline] do_syscall_64+0xfa/0x3b0 arch/x86/entry/syscall_64.c:94 entry_SYSCALL_64_after_hwframe+0x77/0x7f The buggy address belongs to the object at ffff888054c95700 which belongs to the cache kmalloc-96 of size 96 The buggy address is located 40 bytes inside of allocated 88-byte region [ffff888054c95700, ffff888054c95758) The buggy address belongs to the physical page: page: refcount:0 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x54c95 flags: 0x4fff00000000000(node=1|zone=1|lastcpupid=0x7ff) page_type: f5(slab) raw: 04fff00000000000 ffff88801a441280 dead000000000100 dead000000000122 raw: 0000000000000000 0000000000200020 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 0x252800(GFP_NOWAIT|__GFP_NORETRY|__GFP_COMP|__GFP_THISNODE), pid 5321, tgid 5320 (syz.0.0), ts 76121298862, free_ts 0 set_page_owner include/linux/page_owner.h:32 [inline] post_alloc_hook+0x240/0x2a0 mm/page_alloc.c:1704 prep_new_page mm/page_alloc.c:1712 [inline] get_page_from_freelist+0x21e4/0x22c0 mm/page_alloc.c:3669 __alloc_frozen_pages_noprof+0x181/0x370 mm/page_alloc.c:4959 alloc_slab_page mm/slub.c:2453 [inline] allocate_slab+0x65/0x3b0 mm/slub.c:2619 new_slab mm/slub.c:2673 [inline] ___slab_alloc+0xbfc/0x1480 mm/slub.c:3859 __slab_alloc mm/slub.c:3949 [inline] __slab_alloc_node mm/slub.c:4024 [inline] slab_alloc_node mm/slub.c:4185 [inline] __do_kmalloc_node mm/slub.c:4327 [inline] __kmalloc_node_noprof+0x2fd/0x4e0 mm/slub.c:4334 kmalloc_array_node_noprof include/linux/slab.h:1020 [inline] alloc_slab_obj_exts+0x39/0xa0 mm/slub.c:1992 __memcg_slab_post_alloc_hook+0x31e/0x7f0 mm/memcontrol.c:3177 memcg_slab_post_alloc_hook mm/slub.c:2180 [inline] slab_post_alloc_hook mm/slub.c:4158 [inline] slab_alloc_node mm/slub.c:4197 [inline] kmem_cache_alloc_noprof+0x2bf/0x3c0 mm/slub.c:4204 __bkey_cached_alloc fs/bcachefs/btree_key_cache.c:136 [inline] bkey_cached_alloc fs/bcachefs/btree_key_cache.c:162 [inline] btree_key_cache_create fs/bcachefs/btree_key_cache.c:231 [inline] btree_key_cache_fill+0x45b/0x3010 fs/bcachefs/btree_key_cache.c:344 bch2_btree_path_traverse_cached+0xc5d/0x10d0 fs/bcachefs/btree_key_cache.c:399 bch2_btree_path_traverse_one+0x372/0x21d0 fs/bcachefs/btree_iter.c:1179 bch2_btree_path_traverse fs/bcachefs/btree_iter.h:250 [inline] bch2_trans_update_get_key_cache+0x557/0xf20 fs/bcachefs/btree_update.c:476 bch2_trans_update_ip+0x958/0x1db0 fs/bcachefs/btree_update.c:524 bch2_trans_update fs/bcachefs/btree_update.h:123 [inline] bch2_alloc_write_key fs/bcachefs/btree_gc.c:941 [inline] bch2_gc_alloc_done fs/bcachefs/btree_gc.c:951 [inline] bch2_check_allocations+0x3f4d/0x57b0 fs/bcachefs/btree_gc.c:1100 bch2_run_recovery_pass fs/bcachefs/recovery_passes.c:484 [inline] __bch2_run_recovery_passes+0x392/0x1010 fs/bcachefs/recovery_passes.c:539 page_owner free stack trace missing Memory state around the buggy address: ffff888054c95600: 00 00 00 00 00 00 00 00 00 fc fc fc fc fc fc fc ffff888054c95680: fa fb fb fb fb fb fb fb fb fb fb fb fc fc fc fc >ffff888054c95700: 00 00 00 00 00 00 00 00 00 00 00 fc fc fc fc fc ^ ffff888054c95780: 00 00 00 00 00 00 00 00 00 00 00 00 fc fc fc fc ffff888054c95800: 00 00 00 00 00 00 00 00 00 00 00 00 fc fc fc fc ==================================================================