kobject_add_internal failed for hci0:201 with -EEXIST, don't try to register things with the same name in the same directory. Bluetooth: hci0: failed to register connection device ================================================================== BUG: KASAN: use-after-free in l2cap_connect_cfm+0x752/0x1270 net/bluetooth/l2cap_core.c:8289 Read of size 8 at addr ffff88807497b488 by task kworker/u5:7/4184 CPU: 1 PID: 4184 Comm: kworker/u5:7 Not tainted 5.15.178-syzkaller #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 12/27/2024 Workqueue: hci0 hci_rx_work Call Trace: __dump_stack lib/dump_stack.c:88 [inline] dump_stack_lvl+0x1e3/0x2d0 lib/dump_stack.c:106 print_address_description+0x63/0x3b0 mm/kasan/report.c:248 __kasan_report mm/kasan/report.c:434 [inline] kasan_report+0x16b/0x1c0 mm/kasan/report.c:451 l2cap_connect_cfm+0x752/0x1270 net/bluetooth/l2cap_core.c:8289 hci_connect_cfm include/net/bluetooth/hci_core.h:1505 [inline] le_conn_complete_evt+0xd02/0x1500 net/bluetooth/hci_event.c:5432 hci_le_conn_complete_evt net/bluetooth/hci_event.c:5457 [inline] hci_le_meta_evt+0x28c/0x3f50 net/bluetooth/hci_event.c:6178 hci_event_packet+0xc41/0x1550 net/bluetooth/hci_event.c:6527 hci_rx_work+0x237/0xa10 net/bluetooth/hci_core.c:5160 process_one_work+0x8a1/0x10c0 kernel/workqueue.c:2310 worker_thread+0xaca/0x1280 kernel/workqueue.c:2457 kthread+0x3f6/0x4f0 kernel/kthread.c:334 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:287 Allocated by task 4184: kasan_save_stack mm/kasan/common.c:38 [inline] kasan_set_track mm/kasan/common.c:46 [inline] set_alloc_info mm/kasan/common.c:434 [inline] ____kasan_kmalloc+0xba/0xf0 mm/kasan/common.c:513 kasan_kmalloc include/linux/kasan.h:264 [inline] kmem_cache_alloc_trace+0x143/0x290 mm/slub.c:3247 kmalloc include/linux/slab.h:591 [inline] kzalloc include/linux/slab.h:721 [inline] l2cap_chan_create+0x4c/0x730 net/bluetooth/l2cap_core.c:469 l2cap_sock_alloc+0x13c/0x1f0 net/bluetooth/l2cap_sock.c:1876 l2cap_sock_new_connection_cb+0xca/0x1c0 net/bluetooth/l2cap_sock.c:1476 l2cap_connect_cfm+0x36b/0x1270 net/bluetooth/l2cap_core.c:8272 hci_connect_cfm include/net/bluetooth/hci_core.h:1505 [inline] le_conn_complete_evt+0xd02/0x1500 net/bluetooth/hci_event.c:5432 hci_le_conn_complete_evt net/bluetooth/hci_event.c:5457 [inline] hci_le_meta_evt+0x28c/0x3f50 net/bluetooth/hci_event.c:6178 hci_event_packet+0xc41/0x1550 net/bluetooth/hci_event.c:6527 hci_rx_work+0x237/0xa10 net/bluetooth/hci_core.c:5160 process_one_work+0x8a1/0x10c0 kernel/workqueue.c:2310 worker_thread+0xaca/0x1280 kernel/workqueue.c:2457 kthread+0x3f6/0x4f0 kernel/kthread.c:334 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:287 Freed by task 5411: kasan_save_stack mm/kasan/common.c:38 [inline] kasan_set_track+0x4b/0x80 mm/kasan/common.c:46 kasan_set_free_info+0x1f/0x40 mm/kasan/generic.c:360 ____kasan_slab_free+0xd8/0x120 mm/kasan/common.c:366 kasan_slab_free include/linux/kasan.h:230 [inline] slab_free_hook mm/slub.c:1705 [inline] slab_free_freelist_hook+0xdd/0x160 mm/slub.c:1731 slab_free mm/slub.c:3499 [inline] kfree+0xf1/0x270 mm/slub.c:4559 l2cap_sock_cleanup_listen+0xe9/0x270 net/bluetooth/l2cap_sock.c:1459 l2cap_sock_release+0x59/0x1d0 net/bluetooth/l2cap_sock.c:1419 __sock_release net/socket.c:649 [inline] sock_close+0xcd/0x230 net/socket.c:1336 __fput+0x3fe/0x8e0 fs/file_table.c:280 task_work_run+0x129/0x1a0 kernel/task_work.c:188 tracehook_notify_resume include/linux/tracehook.h:189 [inline] exit_to_user_mode_loop+0x106/0x130 kernel/entry/common.c:181 exit_to_user_mode_prepare+0xb1/0x140 kernel/entry/common.c:214 __syscall_exit_to_user_mode_work kernel/entry/common.c:296 [inline] syscall_exit_to_user_mode+0x5d/0x240 kernel/entry/common.c:307 do_syscall_64+0x47/0xb0 arch/x86/entry/common.c:86 entry_SYSCALL_64_after_hwframe+0x66/0xd0 Last potentially related work creation: kasan_save_stack+0x36/0x60 mm/kasan/common.c:38 kasan_record_aux_stack+0xba/0x100 mm/kasan/generic.c:348 __call_rcu kernel/rcu/tree.c:3007 [inline] call_rcu+0x1c4/0xa70 kernel/rcu/tree.c:3087 qdisc_put net/sched/sch_generic.c:1044 [inline] shutdown_scheduler_queue net/sched/sch_generic.c:1097 [inline] netdev_for_each_tx_queue include/linux/netdevice.h:2379 [inline] dev_shutdown+0x18a/0x6d0 net/sched/sch_generic.c:1405 unregister_netdevice_many+0xac3/0x18f0 net/core/dev.c:11095 unregister_netdevice_queue+0x2e6/0x350 net/core/dev.c:11035 unregister_netdevice include/linux/netdevice.h:3012 [inline] __tun_detach+0x6b6/0x1600 drivers/net/tun.c:686 tun_detach drivers/net/tun.c:702 [inline] tun_chr_close+0x104/0x1b0 drivers/net/tun.c:3440 __fput+0x3fe/0x8e0 fs/file_table.c:280 task_work_run+0x129/0x1a0 kernel/task_work.c:188 tracehook_notify_resume include/linux/tracehook.h:189 [inline] exit_to_user_mode_loop+0x106/0x130 kernel/entry/common.c:181 exit_to_user_mode_prepare+0xb1/0x140 kernel/entry/common.c:214 __syscall_exit_to_user_mode_work kernel/entry/common.c:296 [inline] syscall_exit_to_user_mode+0x5d/0x240 kernel/entry/common.c:307 do_syscall_64+0x47/0xb0 arch/x86/entry/common.c:86 entry_SYSCALL_64_after_hwframe+0x66/0xd0 The buggy address belongs to the object at ffff88807497b000 which belongs to the cache kmalloc-2k of size 2048 The buggy address is located 1160 bytes inside of 2048-byte region [ffff88807497b000, ffff88807497b800) The buggy address belongs to the page: page:ffffea0001d25e00 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x74978 head:ffffea0001d25e00 order:3 compound_mapcount:0 compound_pincount:0 flags: 0xfff00000010200(slab|head|node=0|zone=1|lastcpupid=0x7ff) raw: 00fff00000010200 dead000000000100 dead000000000122 ffff888017442000 raw: 0000000000000000 0000000080080008 00000001ffffffff 0000000000000000 page dumped because: kasan: bad access detected page_owner tracks the page as allocated page last allocated via order 3, migratetype Unmovable, gfp_mask 0xd20c0(__GFP_IO|__GFP_FS|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_NOMEMALLOC), pid 4167, ts 61788742344, free_ts 61416758453 prep_new_page mm/page_alloc.c:2426 [inline] get_page_from_freelist+0x3b78/0x3d40 mm/page_alloc.c:4192 __alloc_pages+0x272/0x700 mm/page_alloc.c:5465 alloc_slab_page mm/slub.c:1775 [inline] allocate_slab mm/slub.c:1912 [inline] new_slab+0xbb/0x4b0 mm/slub.c:1975 ___slab_alloc+0x6f6/0xe10 mm/slub.c:3008 __slab_alloc mm/slub.c:3095 [inline] slab_alloc_node mm/slub.c:3186 [inline] __kmalloc_node+0x1fa/0x390 mm/slub.c:4451 kmalloc_node include/linux/slab.h:614 [inline] kvmalloc_node+0x80/0x140 mm/util.c:619 kvmalloc include/linux/mm.h:805 [inline] kvmalloc_array include/linux/mm.h:823 [inline] kvcalloc include/linux/mm.h:828 [inline] ip_set_net_init+0x8b/0x140 net/netfilter/ipset/ip_set_core.c:2380 ops_init+0x35d/0x610 net/core/net_namespace.c:138 setup_net+0x3ab/0xad0 net/core/net_namespace.c:333 copy_net_ns+0x392/0x5d0 net/core/net_namespace.c:486 create_new_namespaces+0x425/0x7a0 kernel/nsproxy.c:110 unshare_nsproxy_namespaces+0x11e/0x170 kernel/nsproxy.c:226 ksys_unshare+0x531/0xa40 kernel/fork.c:3099 __do_sys_unshare kernel/fork.c:3173 [inline] __se_sys_unshare kernel/fork.c:3171 [inline] __x64_sys_unshare+0x34/0x40 kernel/fork.c:3171 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x3b/0xb0 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x66/0xd0 page last free stack trace: reset_page_owner include/linux/page_owner.h:24 [inline] free_pages_prepare mm/page_alloc.c:1340 [inline] free_pcp_prepare mm/page_alloc.c:1391 [inline] free_unref_page_prepare+0xc34/0xcf0 mm/page_alloc.c:3317 free_unref_page+0x95/0x2d0 mm/page_alloc.c:3396 put_page include/linux/mm.h:1247 [inline] __skb_frag_unref include/linux/skbuff.h:3231 [inline] skb_release_data+0x411/0x8a0 net/core/skbuff.c:672 skb_release_all net/core/skbuff.c:742 [inline] __kfree_skb+0x4c/0x60 net/core/skbuff.c:756 sk_eat_skb include/net/sock.h:2732 [inline] tcp_recvmsg_locked+0x1629/0x29b0 net/ipv4/tcp.c:2517 tcp_recvmsg+0x24e/0x7f0 net/ipv4/tcp.c:2563 inet_recvmsg+0x157/0x280 net/ipv4/af_inet.c:868 sock_recvmsg_nosec net/socket.c:966 [inline] sock_recvmsg net/socket.c:984 [inline] sock_read_iter+0x353/0x480 net/socket.c:1057 call_read_iter include/linux/fs.h:2168 [inline] new_sync_read fs/read_write.c:404 [inline] vfs_read+0xa93/0xe10 fs/read_write.c:485 ksys_read+0x1a2/0x2c0 fs/read_write.c:623 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x3b/0xb0 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x66/0xd0 Memory state around the buggy address: ffff88807497b380: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ffff88807497b400: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb >ffff88807497b480: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ^ ffff88807497b500: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ffff88807497b580: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ==================================================================