node offset 8/24 bset u64s 375 bset byte offset 184: keys out of order: u64s 11 type alloc_v4 0:32:0 len 0 ver 0 > u64s 11 type alloc_v4 0:2:0 len 0 ver 0, fixing bcachefs (loop0): btree_node_read_work: rewriting btree node at btree=alloc level=0 SPOS_MAX due to error ================================================================== BUG: KASAN: use-after-free in bch2_btree_node_read_done+0xfbe/0x5e90 fs/bcachefs/btree_io.c:1087 Read of size 8 at addr ffff8880427b0010 by task syz.0.15/5837 CPU: 0 UID: 0 PID: 5837 Comm: syz.0.15 Not tainted 6.13.0-rc7-syzkaller-g619f0b6fad52 #0 Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.16.3-debian-1.16.3-2~bpo12+1 04/01/2014 Call Trace: __dump_stack lib/dump_stack.c:94 [inline] dump_stack_lvl+0x241/0x360 lib/dump_stack.c:120 print_address_description mm/kasan/report.c:378 [inline] print_report+0x169/0x550 mm/kasan/report.c:489 kasan_report+0x143/0x180 mm/kasan/report.c:602 bch2_btree_node_read_done+0xfbe/0x5e90 fs/bcachefs/btree_io.c:1087 btree_node_read_work+0x68b/0x1260 fs/bcachefs/btree_io.c:1323 bch2_btree_node_read+0x2433/0x29f0 __bch2_btree_root_read fs/bcachefs/btree_io.c:1749 [inline] bch2_btree_root_read+0x617/0x7a0 fs/bcachefs/btree_io.c:1771 read_btree_roots+0x296/0x840 fs/bcachefs/recovery.c:523 bch2_fs_recovery+0x2585/0x39d0 fs/bcachefs/recovery.c:853 bch2_fs_start+0x356/0x5b0 fs/bcachefs/super.c:1037 bch2_fs_get_tree+0xd68/0x1710 fs/bcachefs/fs.c:2170 vfs_get_tree+0x90/0x2b0 fs/super.c:1814 do_new_mount+0x2be/0xb40 fs/namespace.c:3511 do_mount fs/namespace.c:3851 [inline] __do_sys_mount fs/namespace.c:4061 [inline] __se_sys_mount+0x2d6/0x3c0 fs/namespace.c:4038 do_syscall_x64 arch/x86/entry/common.c:52 [inline] do_syscall_64+0xf3/0x230 arch/x86/entry/common.c:83 entry_SYSCALL_64_after_hwframe+0x77/0x7f RIP: 0033:0x7f193cf7ffba Code: d8 64 89 02 48 c7 c0 ff ff ff ff eb a6 e8 de 1a 00 00 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 40 00 49 89 ca b8 a5 00 00 00 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:00007f193dd7de68 EFLAGS: 00000246 ORIG_RAX: 00000000000000a5 RAX: ffffffffffffffda RBX: 00007f193dd7def0 RCX: 00007f193cf7ffba RDX: 00000000200000c0 RSI: 0000000020000180 RDI: 00007f193dd7deb0 RBP: 00000000200000c0 R08: 00007f193dd7def0 R09: 0000000000000010 R10: 0000000000000010 R11: 0000000000000246 R12: 0000000020000180 R13: 00007f193dd7deb0 R14: 0000000000005943 R15: 0000000020000480 The buggy address belongs to the physical page: page: refcount:0 mapcount:0 mapping:0000000000000000 index:0xffff8880427b3758 pfn:0x427b0 flags: 0x4fff00000000000(node=1|zone=1|lastcpupid=0x7ff) page_type: f0(buddy) raw: 04fff00000000000 ffffea000109fb08 ffffea000102fa08 0000000000000000 raw: ffff8880427b3758 0000000000000002 00000000f0000000 0000000000000000 page dumped because: kasan: bad access detected page_owner tracks the page as freed page last allocated via order 2, migratetype Reclaimable, gfp_mask 0xd20d0(__GFP_IO|__GFP_FS|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_NOMEMALLOC|__GFP_RECLAIMABLE), pid 4731, tgid 4731 (udevd), ts 27726229927, free_ts 67054770584 set_page_owner include/linux/page_owner.h:32 [inline] post_alloc_hook+0x1f3/0x230 mm/page_alloc.c:1558 prep_new_page mm/page_alloc.c:1566 [inline] get_page_from_freelist+0x365c/0x37a0 mm/page_alloc.c:3476 __alloc_pages_noprof+0x292/0x710 mm/page_alloc.c:4753 alloc_pages_mpol_noprof+0x3e1/0x780 mm/mempolicy.c:2269 alloc_slab_page+0x6a/0x110 mm/slub.c:2423 allocate_slab+0x5a/0x2b0 mm/slub.c:2589 new_slab mm/slub.c:2642 [inline] ___slab_alloc+0xc27/0x14a0 mm/slub.c:3830 __slab_alloc+0x58/0xa0 mm/slub.c:3920 __slab_alloc_node mm/slub.c:3995 [inline] slab_alloc_node mm/slub.c:4156 [inline] kmem_cache_alloc_lru_noprof+0x26c/0x390 mm/slub.c:4187 alloc_inode+0x87/0x1a0 fs/inode.c:338 iget_locked+0xf1/0x5a0 fs/inode.c:1487 kernfs_get_inode+0x51/0x760 fs/kernfs/inode.c:251 kernfs_iop_lookup+0x266/0x390 fs/kernfs/dir.c:1214 __lookup_slow+0x28c/0x3f0 fs/namei.c:1791 lookup_slow+0x53/0x70 fs/namei.c:1808 walk_component+0x2e1/0x410 fs/namei.c:2112 page last free pid 1093 tgid 1093 stack trace: reset_page_owner include/linux/page_owner.h:25 [inline] free_pages_prepare mm/page_alloc.c:1127 [inline] free_unref_page+0xd3f/0x1010 mm/page_alloc.c:2659 __slab_free+0x2c2/0x380 mm/slub.c:4524 qlink_free mm/kasan/quarantine.c:163 [inline] qlist_free_all+0x9a/0x140 mm/kasan/quarantine.c:179 kasan_quarantine_reduce+0x14f/0x170 mm/kasan/quarantine.c:286 __kasan_slab_alloc+0x23/0x80 mm/kasan/common.c:329 kasan_slab_alloc include/linux/kasan.h:250 [inline] slab_post_alloc_hook mm/slub.c:4119 [inline] slab_alloc_node mm/slub.c:4168 [inline] kmem_cache_alloc_node_noprof+0x1d9/0x380 mm/slub.c:4220 __alloc_skb+0x1c3/0x440 net/core/skbuff.c:668 alloc_skb include/linux/skbuff.h:1323 [inline] nlmsg_new include/net/netlink.h:1018 [inline] inet_netconf_notify_devconf+0x15a/0x220 net/ipv4/devinet.c:2162 __devinet_sysctl_unregister net/ipv4/devinet.c:2657 [inline] devinet_sysctl_unregister net/ipv4/devinet.c:2681 [inline] inetdev_destroy net/ipv4/devinet.c:342 [inline] inetdev_event+0x87b/0x1550 net/ipv4/devinet.c:1663 notifier_call_chain+0x1a5/0x3f0 kernel/notifier.c:85 call_netdevice_notifiers_extack net/core/dev.c:2064 [inline] call_netdevice_notifiers net/core/dev.c:2078 [inline] unregister_netdevice_many_notify+0xedd/0x1da0 net/core/dev.c:11545 cleanup_net+0x75d/0xd50 net/core/net_namespace.c:643 process_one_work kernel/workqueue.c:3236 [inline] process_scheduled_works+0xa66/0x1840 kernel/workqueue.c:3317 worker_thread+0x870/0xd30 kernel/workqueue.c:3398 kthread+0x2f0/0x390 kernel/kthread.c:389 ret_from_fork+0x4b/0x80 arch/x86/kernel/process.c:147 Memory state around the buggy address: ffff8880427aff00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ffff8880427aff80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 >ffff8880427b0000: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ^ ffff8880427b0080: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ffff8880427b0100: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ==================================================================