================================================================== BUG: KASAN: slab-use-after-free in btrfs_open_devices+0xb8/0xc0 fs/btrfs/volumes.c:1281 Read of size 4 at addr ffff888042f1c530 by task syz-executor.3/8068 CPU: 0 PID: 8068 Comm: syz-executor.3 Not tainted 6.5.0-rc5-next-20230807-syzkaller #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 07/12/2023 Call Trace: __dump_stack lib/dump_stack.c:88 [inline] dump_stack_lvl+0xd9/0x1b0 lib/dump_stack.c:106 print_address_description mm/kasan/report.c:364 [inline] print_report+0xc4/0x620 mm/kasan/report.c:475 kasan_report+0xda/0x110 mm/kasan/report.c:588 btrfs_open_devices+0xb8/0xc0 fs/btrfs/volumes.c:1281 btrfs_mount_root+0x681/0xda0 fs/btrfs/super.c:1505 legacy_get_tree+0x109/0x220 fs/fs_context.c:611 vfs_get_tree+0x88/0x350 fs/super.c:1544 fc_mount fs/namespace.c:1112 [inline] vfs_kern_mount.part.0+0xcb/0x170 fs/namespace.c:1142 vfs_kern_mount+0x3f/0x60 fs/namespace.c:1129 btrfs_mount+0x292/0xb10 fs/btrfs/super.c:1578 legacy_get_tree+0x109/0x220 fs/fs_context.c:611 vfs_get_tree+0x88/0x350 fs/super.c:1544 do_new_mount fs/namespace.c:3335 [inline] path_mount+0x1492/0x1ed0 fs/namespace.c:3662 do_mount fs/namespace.c:3675 [inline] __do_sys_mount fs/namespace.c:3884 [inline] __se_sys_mount fs/namespace.c:3861 [inline] __x64_sys_mount+0x293/0x310 fs/namespace.c:3861 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x38/0xb0 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x63/0xcd RIP: 0033:0x7fb1ace7e1ea Code: d8 64 89 02 48 c7 c0 ff ff ff ff eb a6 e8 de 09 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 b0 ff ff ff f7 d8 64 89 01 48 RSP: 002b:00007fb1adb98ee8 EFLAGS: 00000202 ORIG_RAX: 00000000000000a5 RAX: ffffffffffffffda RBX: 00007fb1adb98f80 RCX: 00007fb1ace7e1ea RDX: 00000000200051c0 RSI: 0000000020005200 RDI: 00007fb1adb98f40 RBP: 00000000200051c0 R08: 00007fb1adb98f80 R09: 0000000001000008 R10: 0000000001000008 R11: 0000000000000202 R12: 0000000020005200 R13: 00007fb1adb98f40 R14: 00000000000051ab R15: 0000000020000280 Allocated by task 8066: kasan_save_stack+0x33/0x50 mm/kasan/common.c:45 kasan_set_track+0x25/0x30 mm/kasan/common.c:52 ____kasan_kmalloc mm/kasan/common.c:374 [inline] __kasan_kmalloc+0xa2/0xb0 mm/kasan/common.c:383 kmalloc include/linux/slab.h:599 [inline] kzalloc include/linux/slab.h:720 [inline] alloc_fs_devices+0x54/0x2b0 fs/btrfs/volumes.c:375 device_list_add.constprop.0+0x3eb/0x1db0 fs/btrfs/volumes.c:807 btrfs_scan_one_device+0x1b7/0x2a0 fs/btrfs/volumes.c:1405 btrfs_mount_root+0x4a8/0xda0 fs/btrfs/super.c:1482 legacy_get_tree+0x109/0x220 fs/fs_context.c:611 vfs_get_tree+0x88/0x350 fs/super.c:1544 fc_mount fs/namespace.c:1112 [inline] vfs_kern_mount.part.0+0xcb/0x170 fs/namespace.c:1142 vfs_kern_mount+0x3f/0x60 fs/namespace.c:1129 btrfs_mount+0x292/0xb10 fs/btrfs/super.c:1578 legacy_get_tree+0x109/0x220 fs/fs_context.c:611 vfs_get_tree+0x88/0x350 fs/super.c:1544 do_new_mount fs/namespace.c:3335 [inline] path_mount+0x1492/0x1ed0 fs/namespace.c:3662 do_mount fs/namespace.c:3675 [inline] __do_sys_mount fs/namespace.c:3884 [inline] __se_sys_mount fs/namespace.c:3861 [inline] __x64_sys_mount+0x293/0x310 fs/namespace.c:3861 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x38/0xb0 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x63/0xcd Freed by task 8066: kasan_save_stack+0x33/0x50 mm/kasan/common.c:45 kasan_set_track+0x25/0x30 mm/kasan/common.c:52 kasan_save_free_info+0x2b/0x40 mm/kasan/generic.c:522 ____kasan_slab_free mm/kasan/common.c:236 [inline] ____kasan_slab_free+0x15e/0x1b0 mm/kasan/common.c:200 kasan_slab_free include/linux/kasan.h:164 [inline] slab_free_hook mm/slub.c:1800 [inline] slab_free_freelist_hook+0x114/0x1e0 mm/slub.c:1826 slab_free mm/slub.c:3809 [inline] __kmem_cache_free+0xb8/0x2f0 mm/slub.c:3822 btrfs_close_devices+0x4cd/0x610 fs/btrfs/volumes.c:1207 open_ctree+0x1c1/0x5710 fs/btrfs/disk-io.c:3612 btrfs_fill_super fs/btrfs/super.c:1158 [inline] btrfs_mount_root+0x976/0xda0 fs/btrfs/super.c:1520 legacy_get_tree+0x109/0x220 fs/fs_context.c:611 vfs_get_tree+0x88/0x350 fs/super.c:1544 fc_mount fs/namespace.c:1112 [inline] vfs_kern_mount.part.0+0xcb/0x170 fs/namespace.c:1142 vfs_kern_mount+0x3f/0x60 fs/namespace.c:1129 btrfs_mount+0x292/0xb10 fs/btrfs/super.c:1578 legacy_get_tree+0x109/0x220 fs/fs_context.c:611 vfs_get_tree+0x88/0x350 fs/super.c:1544 do_new_mount fs/namespace.c:3335 [inline] path_mount+0x1492/0x1ed0 fs/namespace.c:3662 do_mount fs/namespace.c:3675 [inline] __do_sys_mount fs/namespace.c:3884 [inline] __se_sys_mount fs/namespace.c:3861 [inline] __x64_sys_mount+0x293/0x310 fs/namespace.c:3861 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x38/0xb0 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x63/0xcd Last potentially related work creation: kasan_save_stack+0x33/0x50 mm/kasan/common.c:45 __kasan_record_aux_stack+0xbc/0xd0 mm/kasan/generic.c:492 insert_work+0x4a/0x330 kernel/workqueue.c:1559 __queue_work+0x5f5/0x1040 kernel/workqueue.c:1720 call_timer_fn+0x1a0/0x580 kernel/time/timer.c:1700 expire_timers kernel/time/timer.c:1746 [inline] __run_timers+0x585/0xb10 kernel/time/timer.c:2022 run_timer_softirq+0x58/0xd0 kernel/time/timer.c:2035 __do_softirq+0x218/0x965 kernel/softirq.c:553 Second to last potentially related work creation: kasan_save_stack+0x33/0x50 mm/kasan/common.c:45 __kasan_record_aux_stack+0xbc/0xd0 mm/kasan/generic.c:492 __call_rcu_common.constprop.0+0x9a/0x790 kernel/rcu/tree.c:2653 fib6_info_release include/net/ip6_fib.h:337 [inline] fib6_info_release include/net/ip6_fib.h:334 [inline] ip6_route_add+0x12f/0x150 net/ipv6/route.c:3846 addrconf_prefix_route+0x300/0x510 net/ipv6/addrconf.c:2434 add_v4_addrs+0x6be/0x9d0 net/ipv6/addrconf.c:3206 addrconf_gre_config net/ipv6/addrconf.c:3480 [inline] addrconf_init_auto_addrs+0x18a/0x810 net/ipv6/addrconf.c:3498 addrconf_notify+0xe65/0x1920 net/ipv6/addrconf.c:3679 notifier_call_chain+0xb6/0x3b0 kernel/notifier.c:93 call_netdevice_notifiers_info+0xb9/0x130 net/core/dev.c:1970 call_netdevice_notifiers_extack net/core/dev.c:2008 [inline] call_netdevice_notifiers net/core/dev.c:2022 [inline] __dev_notify_flags+0x12d/0x2e0 net/core/dev.c:8633 dev_change_flags+0x122/0x170 net/core/dev.c:8671 do_setlink+0x1a2a/0x3fa0 net/core/rtnetlink.c:2866 __rtnl_newlink+0xc04/0x18c0 net/core/rtnetlink.c:3654 rtnl_newlink+0x67/0xa0 net/core/rtnetlink.c:3701 rtnetlink_rcv_msg+0x439/0xd30 net/core/rtnetlink.c:6427 netlink_rcv_skb+0x16b/0x440 net/netlink/af_netlink.c:2575 netlink_unicast_kernel net/netlink/af_netlink.c:1344 [inline] netlink_unicast+0x539/0x800 net/netlink/af_netlink.c:1370 netlink_sendmsg+0x93c/0xe40 net/netlink/af_netlink.c:1939 sock_sendmsg_nosec net/socket.c:727 [inline] sock_sendmsg+0xd9/0x180 net/socket.c:750 __sys_sendto+0x255/0x340 net/socket.c:2136 __do_sys_sendto net/socket.c:2148 [inline] __se_sys_sendto net/socket.c:2144 [inline] __x64_sys_sendto+0xe0/0x1b0 net/socket.c:2144 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x38/0xb0 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x63/0xcd The buggy address belongs to the object at ffff888042f1c400 which belongs to the cache kmalloc-512 of size 512 The buggy address is located 304 bytes inside of freed 512-byte region [ffff888042f1c400, ffff888042f1c600) The buggy address belongs to the physical page: page:ffffea00010bc700 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x42f1c head:ffffea00010bc700 order:2 entire_mapcount:0 nr_pages_mapped:0 pincount:0 anon flags: 0xfff00000010200(slab|head|node=0|zone=1|lastcpupid=0x7ff) page_type: 0xffffffff() raw: 00fff00000010200 ffff888012841c80 0000000000000000 dead000000000001 raw: 0000000000000000 0000000000100010 00000001ffffffff 0000000000000000 page dumped because: kasan: bad access detected page_owner tracks the page as allocated page last allocated via order 2, migratetype Unmovable, gfp_mask 0xd20c0(__GFP_IO|__GFP_FS|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_NOMEMALLOC), pid 5069, tgid 5069 (syz-executor.0), ts 114153002894, free_ts 12697676609 set_page_owner include/linux/page_owner.h:31 [inline] post_alloc_hook+0x2d2/0x350 mm/page_alloc.c:1567 prep_new_page mm/page_alloc.c:1574 [inline] get_page_from_freelist+0x10d7/0x31b0 mm/page_alloc.c:3253 __alloc_pages+0x1d0/0x4a0 mm/page_alloc.c:4509 alloc_pages+0x1a9/0x270 mm/mempolicy.c:2298 alloc_slab_page mm/slub.c:1870 [inline] allocate_slab+0x24e/0x380 mm/slub.c:2017 new_slab mm/slub.c:2070 [inline] ___slab_alloc+0x8bc/0x1570 mm/slub.c:3223 __slab_alloc.constprop.0+0x56/0xa0 mm/slub.c:3322 __slab_alloc_node mm/slub.c:3375 [inline] slab_alloc_node mm/slub.c:3468 [inline] __kmem_cache_alloc_node+0x137/0x350 mm/slub.c:3517 __do_kmalloc_node mm/slab_common.c:1022 [inline] __kmalloc+0x4f/0x100 mm/slab_common.c:1036 kmalloc include/linux/slab.h:603 [inline] kzalloc include/linux/slab.h:720 [inline] fib6_info_alloc+0x40/0x100 net/ipv6/ip6_fib.c:155 ip6_route_info_create+0x337/0x1b70 net/ipv6/route.c:3747 addrconf_f6i_alloc+0x396/0x670 net/ipv6/route.c:4570 ipv6_add_addr+0x4c2/0x2010 net/ipv6/addrconf.c:1114 add_addr+0xe0/0x350 net/ipv6/addrconf.c:3139 add_v4_addrs+0x68d/0x9d0 net/ipv6/addrconf.c:3204 addrconf_gre_config net/ipv6/addrconf.c:3480 [inline] addrconf_init_auto_addrs+0x18a/0x810 net/ipv6/addrconf.c:3498 page last free stack trace: reset_page_owner include/linux/page_owner.h:24 [inline] free_pages_prepare mm/page_alloc.c:1158 [inline] free_unref_page_prepare+0x508/0xb90 mm/page_alloc.c:2380 free_unref_page+0x33/0x3b0 mm/page_alloc.c:2475 free_contig_range+0xb6/0x190 mm/page_alloc.c:6424 destroy_args+0x78c/0x9b0 mm/debug_vm_pgtable.c:1028 debug_vm_pgtable+0x2363/0x40a0 mm/debug_vm_pgtable.c:1408 do_one_initcall+0x117/0x630 init/main.c:1232 do_initcall_level init/main.c:1294 [inline] do_initcalls init/main.c:1310 [inline] do_basic_setup init/main.c:1329 [inline] kernel_init_freeable+0x5bd/0x8f0 init/main.c:1546 kernel_init+0x1c/0x2a0 init/main.c:1437 ret_from_fork+0x2c/0x70 arch/x86/kernel/process.c:145 ret_from_fork_asm+0x11/0x20 arch/x86/entry/entry_64.S:304 Memory state around the buggy address: ffff888042f1c400: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ffff888042f1c480: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb >ffff888042f1c500: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ^ ffff888042f1c580: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ffff888042f1c600: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc ==================================================================