================================================================== BUG: KASAN: slab-use-after-free in cmd_complete_rsp+0x1b3/0x1e0 net/bluetooth/mgmt.c:1463 Read of size 8 at addr ffff88804ccb0ec0 by task syz.6.228/7116 CPU: 0 UID: 0 PID: 7116 Comm: syz.6.228 Not tainted 6.12.0-rc5-syzkaller-00291-g05b92660cdfe #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+0x116/0x1f0 lib/dump_stack.c:120 print_address_description mm/kasan/report.c:377 [inline] print_report+0xc3/0x620 mm/kasan/report.c:488 kasan_report+0xd9/0x110 mm/kasan/report.c:601 cmd_complete_rsp+0x1b3/0x1e0 net/bluetooth/mgmt.c:1463 mgmt_pending_foreach+0xdf/0x140 net/bluetooth/mgmt_util.c:259 __mgmt_power_off+0x12a/0x2c0 net/bluetooth/mgmt.c:9474 hci_dev_close_sync+0xcbb/0x11b0 net/bluetooth/hci_sync.c:5201 hci_dev_do_close+0x2e/0x90 net/bluetooth/hci_core.c:483 hci_dev_close+0x183/0x1e0 net/bluetooth/hci_core.c:508 hci_sock_ioctl+0x28c/0x880 net/bluetooth/hci_sock.c:1128 sock_do_ioctl+0x116/0x280 net/socket.c:1227 sock_ioctl+0x228/0x6c0 net/socket.c:1346 vfs_ioctl fs/ioctl.c:51 [inline] __do_sys_ioctl fs/ioctl.c:907 [inline] __se_sys_ioctl fs/ioctl.c:893 [inline] __x64_sys_ioctl+0x18f/0x220 fs/ioctl.c:893 do_syscall_x64 arch/x86/entry/common.c:52 [inline] do_syscall_64+0xcd/0x250 arch/x86/entry/common.c:83 entry_SYSCALL_64_after_hwframe+0x77/0x7f RIP: 0033:0x7fe253f7e719 Code: ff ff c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 40 00 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 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:00007fe254cc2038 EFLAGS: 00000246 ORIG_RAX: 0000000000000010 RAX: ffffffffffffffda RBX: 00007fe254135f80 RCX: 00007fe253f7e719 RDX: 0000000000000000 RSI: 00000000400448ca RDI: 0000000000000006 RBP: 00007fe253ff132e R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000 R13: 0000000000000000 R14: 00007fe254135f80 R15: 00007ffc297ff1e8 Allocated by task 7981: kasan_save_stack+0x33/0x60 mm/kasan/common.c:47 kasan_save_track+0x14/0x30 mm/kasan/common.c:68 poison_kmalloc_redzone mm/kasan/common.c:377 [inline] __kasan_kmalloc+0xaa/0xb0 mm/kasan/common.c:394 kmalloc_noprof include/linux/slab.h:878 [inline] kzalloc_noprof include/linux/slab.h:1014 [inline] mgmt_pending_new+0x5b/0x290 net/bluetooth/mgmt_util.c:269 mgmt_pending_add+0x36/0x160 net/bluetooth/mgmt_util.c:296 start_discovery_internal+0x4a1/0x800 net/bluetooth/mgmt.c:5922 hci_mgmt_cmd net/bluetooth/hci_sock.c:1712 [inline] hci_sock_sendmsg+0x1528/0x25e0 net/bluetooth/hci_sock.c:1832 sock_sendmsg_nosec net/socket.c:729 [inline] __sock_sendmsg net/socket.c:744 [inline] sock_write_iter+0x4fe/0x5b0 net/socket.c:1165 new_sync_write fs/read_write.c:590 [inline] vfs_write+0x5ae/0x1150 fs/read_write.c:683 ksys_write+0x1fa/0x260 fs/read_write.c:736 do_syscall_x64 arch/x86/entry/common.c:52 [inline] do_syscall_64+0xcd/0x250 arch/x86/entry/common.c:83 entry_SYSCALL_64_after_hwframe+0x77/0x7f Freed by task 7116: kasan_save_stack+0x33/0x60 mm/kasan/common.c:47 kasan_save_track+0x14/0x30 mm/kasan/common.c:68 kasan_save_free_info+0x3b/0x60 mm/kasan/generic.c:579 poison_slab_object mm/kasan/common.c:247 [inline] __kasan_slab_free+0x51/0x70 mm/kasan/common.c:264 kasan_slab_free include/linux/kasan.h:230 [inline] slab_free_hook mm/slub.c:2342 [inline] slab_free mm/slub.c:4579 [inline] kfree+0x14f/0x4b0 mm/slub.c:4727 start_discovery_complete+0x146/0x220 net/bluetooth/mgmt.c:5860 _hci_cmd_sync_cancel_entry.constprop.0+0x6c/0x1d0 net/bluetooth/hci_sync.c:645 hci_cmd_sync_dequeue+0x178/0x1f0 net/bluetooth/hci_sync.c:890 cmd_complete_rsp+0x46/0x1e0 net/bluetooth/mgmt.c:1461 mgmt_pending_foreach+0xdf/0x140 net/bluetooth/mgmt_util.c:259 __mgmt_power_off+0x12a/0x2c0 net/bluetooth/mgmt.c:9474 hci_dev_close_sync+0xcbb/0x11b0 net/bluetooth/hci_sync.c:5201 hci_dev_do_close+0x2e/0x90 net/bluetooth/hci_core.c:483 hci_dev_close+0x183/0x1e0 net/bluetooth/hci_core.c:508 hci_sock_ioctl+0x28c/0x880 net/bluetooth/hci_sock.c:1128 sock_do_ioctl+0x116/0x280 net/socket.c:1227 sock_ioctl+0x228/0x6c0 net/socket.c:1346 vfs_ioctl fs/ioctl.c:51 [inline] __do_sys_ioctl fs/ioctl.c:907 [inline] __se_sys_ioctl fs/ioctl.c:893 [inline] __x64_sys_ioctl+0x18f/0x220 fs/ioctl.c:893 do_syscall_x64 arch/x86/entry/common.c:52 [inline] do_syscall_64+0xcd/0x250 arch/x86/entry/common.c:83 entry_SYSCALL_64_after_hwframe+0x77/0x7f The buggy address belongs to the object at ffff88804ccb0e80 which belongs to the cache kmalloc-96 of size 96 The buggy address is located 64 bytes inside of freed 96-byte region [ffff88804ccb0e80, ffff88804ccb0ee0) The buggy address belongs to the physical page: page: refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x4ccb0 flags: 0xfff00000000000(node=0|zone=1|lastcpupid=0x7ff) page_type: f5(slab) raw: 00fff00000000000 ffff88801b042280 dead000000000100 dead000000000122 raw: 0000000000000000 0000000000200020 00000001f5000000 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 0x52820(GFP_ATOMIC|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP), pid 758, tgid 758 (kworker/u32:5), ts 61136884495, free_ts 61135049638 set_page_owner include/linux/page_owner.h:32 [inline] post_alloc_hook+0x2d1/0x350 mm/page_alloc.c:1537 prep_new_page mm/page_alloc.c:1545 [inline] get_page_from_freelist+0x101e/0x3070 mm/page_alloc.c:3457 __alloc_pages_noprof+0x223/0x25a0 mm/page_alloc.c:4733 alloc_pages_mpol_noprof+0x2c9/0x610 mm/mempolicy.c:2265 alloc_slab_page mm/slub.c:2412 [inline] allocate_slab mm/slub.c:2578 [inline] new_slab+0x2ba/0x3f0 mm/slub.c:2631 ___slab_alloc+0xdac/0x1880 mm/slub.c:3818 __slab_alloc.constprop.0+0x56/0xb0 mm/slub.c:3908 __slab_alloc_node mm/slub.c:3961 [inline] slab_alloc_node mm/slub.c:4122 [inline] __kmalloc_cache_noprof+0x2b4/0x300 mm/slub.c:4290 kmalloc_noprof include/linux/slab.h:878 [inline] kzalloc_noprof include/linux/slab.h:1014 [inline] fib6_tables_dump+0xc8/0x370 net/ipv6/ip6_fib.c:490 fib6_dump+0x48/0x60 net/ipv6/fib6_notifier.c:39 fib_net_dump net/core/fib_notifier.c:71 [inline] register_fib_notifier+0x120/0x470 net/core/fib_notifier.c:109 nsim_fib_create+0x937/0xc90 drivers/net/netdevsim/fib.c:1596 nsim_dev_reload_create drivers/net/netdevsim/dev.c:1483 [inline] nsim_dev_reload_up+0x3f6/0x860 drivers/net/netdevsim/dev.c:988 devlink_reload+0x31a/0x7c0 net/devlink/dev.c:474 devlink_pernet_pre_exit+0x1a1/0x2b0 net/devlink/core.c:509 ops_pre_exit_list net/core/net_namespace.c:163 [inline] cleanup_net+0x488/0xb40 net/core/net_namespace.c:606 page last free pid 758 tgid 758 stack trace: reset_page_owner include/linux/page_owner.h:25 [inline] free_pages_prepare mm/page_alloc.c:1108 [inline] free_unref_page+0x5f4/0xdc0 mm/page_alloc.c:2638 selinux_genfs_get_sid security/selinux/hooks.c:1348 [inline] inode_doinit_with_dentry+0xac4/0x12c0 security/selinux/hooks.c:1546 selinux_d_instantiate+0x26/0x30 security/selinux/hooks.c:6331 security_d_instantiate+0x142/0x1a0 security/security.c:4063 d_instantiate+0x5c/0x90 fs/dcache.c:1892 __debugfs_create_file+0x240/0x660 fs/debugfs/inode.c:448 debugfs_create_mode_unsafe fs/debugfs/file.c:519 [inline] debugfs_create_bool+0x70/0xa0 fs/debugfs/file.c:955 nsim_fib_debugfs_init drivers/net/netdevsim/fib.c:1542 [inline] nsim_fib_create+0x318/0xc90 drivers/net/netdevsim/fib.c:1565 nsim_dev_reload_create drivers/net/netdevsim/dev.c:1483 [inline] nsim_dev_reload_up+0x3f6/0x860 drivers/net/netdevsim/dev.c:988 devlink_reload+0x31a/0x7c0 net/devlink/dev.c:474 devlink_pernet_pre_exit+0x1a1/0x2b0 net/devlink/core.c:509 ops_pre_exit_list net/core/net_namespace.c:163 [inline] cleanup_net+0x488/0xb40 net/core/net_namespace.c:606 process_one_work+0x9c5/0x1ba0 kernel/workqueue.c:3229 process_scheduled_works kernel/workqueue.c:3310 [inline] worker_thread+0x6c8/0xf00 kernel/workqueue.c:3391 kthread+0x2c1/0x3a0 kernel/kthread.c:389 ret_from_fork+0x45/0x80 arch/x86/kernel/process.c:147 Memory state around the buggy address: ffff88804ccb0d80: 00 00 00 00 00 00 00 00 00 fc fc fc fc fc fc fc ffff88804ccb0e00: fa fb fb fb fb fb fb fb fb fb fb fb fc fc fc fc >ffff88804ccb0e80: fa fb fb fb fb fb fb fb fb fb fb fb fc fc fc fc ^ ffff88804ccb0f00: fa fb fb fb fb fb fb fb fb fb fb fb fc fc fc fc ffff88804ccb0f80: 00 00 00 00 00 00 00 00 00 00 fc fc fc fc fc fc ==================================================================