syzbot


KASAN: use-after-free Read in l2cap_sock_new_connection_cb

Status: upstream: reported on 2024/11/01 14:54
Reported-by: syzbot+2ee072e03ed03586a60e@syzkaller.appspotmail.com
First crash: 223d, last: 98d
Similar bugs (2)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
linux-5.15 KASAN: use-after-free Read in l2cap_sock_new_connection_cb 1 21d 21d 0/3 upstream: reported on 2025/05/22 11:53
upstream KASAN: slab-use-after-free Read in l2cap_sock_new_connection_cb bluetooth 41 3d00h 234d 0/28 upstream: reported on 2024/10/21 08:46

Sample crash report:
 </TASK>
kobject_add_internal failed for hci2:201 with -EEXIST, don't try to register things with the same name in the same directory.
Bluetooth: hci2: failed to register connection device
==================================================================
BUG: KASAN: use-after-free in l2cap_sock_new_connection_cb+0x1ef/0x2c0 net/bluetooth/l2cap_sock.c:1517
Read of size 8 at addr ffff88807a7ba540 by task kworker/u5:2/4260

CPU: 0 PID: 4260 Comm: kworker/u5:2 Not tainted 6.1.128-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 12/27/2024
Workqueue: hci2 hci_rx_work
Call Trace:
 <TASK>
 __dump_stack lib/dump_stack.c:88 [inline]
 dump_stack_lvl+0x1e3/0x2cb lib/dump_stack.c:106
 print_address_description mm/kasan/report.c:316 [inline]
 print_report+0x15f/0x4f0 mm/kasan/report.c:427
 kasan_report+0x136/0x160 mm/kasan/report.c:531
 l2cap_sock_new_connection_cb+0x1ef/0x2c0 net/bluetooth/l2cap_sock.c:1517
 l2cap_connect_cfm+0x339/0x10a0 net/bluetooth/l2cap_core.c:8319
 hci_connect_cfm+0x15c/0x220 include/net/bluetooth/hci_core.h:1809
 le_conn_complete_evt+0xd8c/0x1350 net/bluetooth/hci_event.c:5864
 hci_le_conn_complete_evt+0x188/0x410 net/bluetooth/hci_event.c:5890
 hci_event_func net/bluetooth/hci_event.c:7370 [inline]
 hci_event_packet+0xa40/0x1510 net/bluetooth/hci_event.c:7425
 hci_rx_work+0x3a6/0xd10 net/bluetooth/hci_core.c:4086
 process_one_work+0x917/0x1260 kernel/workqueue.c:2292
 worker_thread+0xa47/0x1200 kernel/workqueue.c:2439
 kthread+0x28d/0x320 kernel/kthread.c:376
 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:295
 </TASK>

Allocated by task 4260:
 kasan_save_stack mm/kasan/common.c:45 [inline]
 kasan_set_track+0x4b/0x70 mm/kasan/common.c:52
 ____kasan_kmalloc mm/kasan/common.c:374 [inline]
 __kasan_kmalloc+0x97/0xb0 mm/kasan/common.c:383
 kasan_kmalloc include/linux/kasan.h:211 [inline]
 __do_kmalloc_node mm/slab_common.c:936 [inline]
 __kmalloc+0xb2/0x230 mm/slab_common.c:949
 kmalloc include/linux/slab.h:568 [inline]
 sk_prot_alloc+0xe0/0x200 net/core/sock.c:2050
 sk_alloc+0x36/0x350 net/core/sock.c:2103
 bt_sock_alloc+0x37/0x130 net/bluetooth/af_bluetooth.c:148
 l2cap_sock_alloc net/bluetooth/l2cap_sock.c:1911 [inline]
 l2cap_sock_new_connection_cb+0xd8/0x2c0 net/bluetooth/l2cap_sock.c:1502
 l2cap_connect_cfm+0x339/0x10a0 net/bluetooth/l2cap_core.c:8319
 hci_connect_cfm+0x15c/0x220 include/net/bluetooth/hci_core.h:1809
 le_conn_complete_evt+0xd8c/0x1350 net/bluetooth/hci_event.c:5864
 hci_le_conn_complete_evt+0x188/0x410 net/bluetooth/hci_event.c:5890
 hci_event_func net/bluetooth/hci_event.c:7370 [inline]
 hci_event_packet+0xa40/0x1510 net/bluetooth/hci_event.c:7425
 hci_rx_work+0x3a6/0xd10 net/bluetooth/hci_core.c:4086
 process_one_work+0x917/0x1260 kernel/workqueue.c:2292
 worker_thread+0xa47/0x1200 kernel/workqueue.c:2439
 kthread+0x28d/0x320 kernel/kthread.c:376
 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:295

Freed by task 4664:
 kasan_save_stack mm/kasan/common.c:45 [inline]
 kasan_set_track+0x4b/0x70 mm/kasan/common.c:52
 kasan_save_free_info+0x27/0x40 mm/kasan/generic.c:516
 ____kasan_slab_free+0xd6/0x120 mm/kasan/common.c:236
 kasan_slab_free include/linux/kasan.h:177 [inline]
 slab_free_hook mm/slub.c:1724 [inline]
 slab_free_freelist_hook mm/slub.c:1750 [inline]
 slab_free mm/slub.c:3661 [inline]
 __kmem_cache_free+0x25c/0x3c0 mm/slub.c:3674
 sk_prot_free net/core/sock.c:2086 [inline]
 __sk_destruct+0x473/0x5f0 net/core/sock.c:2172
 l2cap_sock_cleanup_listen+0xd9/0x270 net/bluetooth/l2cap_sock.c:1482
 l2cap_sock_release+0x59/0x1d0 net/bluetooth/l2cap_sock.c:1445
 __sock_release net/socket.c:654 [inline]
 sock_close+0xcd/0x230 net/socket.c:1400
 __fput+0x3f6/0x8d0 fs/file_table.c:320
 task_work_run+0x246/0x300 kernel/task_work.c:203
 get_signal+0x15d0/0x17a0 kernel/signal.c:2648
 arch_do_signal_or_restart+0xb0/0x1a10 arch/x86/kernel/signal.c:871
 exit_to_user_mode_loop+0x6a/0x100 kernel/entry/common.c:174
 exit_to_user_mode_prepare+0xb1/0x140 kernel/entry/common.c:210
 __syscall_exit_to_user_mode_work kernel/entry/common.c:292 [inline]
 syscall_exit_to_user_mode+0x60/0x270 kernel/entry/common.c:303
 do_syscall_64+0x47/0xb0 arch/x86/entry/common.c:87
 entry_SYSCALL_64_after_hwframe+0x68/0xd2

The buggy address belongs to the object at ffff88807a7ba000
 which belongs to the cache kmalloc-2k of size 2048
The buggy address is located 1344 bytes inside of
 2048-byte region [ffff88807a7ba000, ffff88807a7ba800)

The buggy address belongs to the physical page:
page:ffffea0001e9ee00 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x7a7b8
head:ffffea0001e9ee00 order:3 compound_mapcount:0 compound_pincount:0
flags: 0xfff00000010200(slab|head|node=0|zone=1|lastcpupid=0x7ff)
raw: 00fff00000010200 0000000000000000 dead000000000001 ffff888017c42000
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 22, tgid 22 (kworker/1:0), ts 74098639275, free_ts 74082508530
 set_page_owner include/linux/page_owner.h:31 [inline]
 post_alloc_hook+0x18d/0x1b0 mm/page_alloc.c:2532
 prep_new_page mm/page_alloc.c:2539 [inline]
 get_page_from_freelist+0x3731/0x38d0 mm/page_alloc.c:4328
 __alloc_pages+0x28d/0x770 mm/page_alloc.c:5605
 alloc_slab_page+0x6a/0x150 mm/slub.c:1794
 allocate_slab mm/slub.c:1939 [inline]
 new_slab+0x84/0x2d0 mm/slub.c:1992
 ___slab_alloc+0xc20/0x1270 mm/slub.c:3180
 __slab_alloc mm/slub.c:3279 [inline]
 slab_alloc_node mm/slub.c:3364 [inline]
 __kmem_cache_alloc_node+0x19f/0x260 mm/slub.c:3437
 __do_kmalloc_node mm/slab_common.c:935 [inline]
 __kmalloc_node_track_caller+0xa0/0x220 mm/slab_common.c:956
 kmalloc_reserve net/core/skbuff.c:446 [inline]
 __alloc_skb+0x12a/0x2c0 net/core/skbuff.c:515
 alloc_skb include/linux/skbuff.h:1271 [inline]
 alloc_skb_with_frags+0xa4/0x740 net/core/skbuff.c:6162
 sock_alloc_send_pskb+0x915/0xa50 net/core/sock.c:2750
 sock_alloc_send_skb include/net/sock.h:1926 [inline]
 mld_newpack+0x1c0/0xa90 net/ipv6/mcast.c:1748
 add_grhead net/ipv6/mcast.c:1851 [inline]
 add_grec+0x1492/0x19a0 net/ipv6/mcast.c:1989
 mld_send_cr net/ipv6/mcast.c:2115 [inline]
 mld_ifc_work+0x68f/0xc90 net/ipv6/mcast.c:2653
 process_one_work+0x917/0x1260 kernel/workqueue.c:2292
 worker_thread+0xa47/0x1200 kernel/workqueue.c:2439
page last free stack trace:
 reset_page_owner include/linux/page_owner.h:24 [inline]
 free_pages_prepare mm/page_alloc.c:1459 [inline]
 free_pcp_prepare mm/page_alloc.c:1509 [inline]
 free_unref_page_prepare+0x12a6/0x15b0 mm/page_alloc.c:3384
 free_unref_page+0x33/0x3e0 mm/page_alloc.c:3479
 free_slab mm/slub.c:2031 [inline]
 discard_slab mm/slub.c:2037 [inline]
 __unfreeze_partials+0x1b7/0x210 mm/slub.c:2586
 put_cpu_partial+0x17b/0x250 mm/slub.c:2662
 qlink_free mm/kasan/quarantine.c:168 [inline]
 qlist_free_all+0x76/0xe0 mm/kasan/quarantine.c:187
 kasan_quarantine_reduce+0x156/0x170 mm/kasan/quarantine.c:294
 __kasan_slab_alloc+0x1f/0x70 mm/kasan/common.c:305
 kasan_slab_alloc include/linux/kasan.h:201 [inline]
 slab_post_alloc_hook+0x52/0x3a0 mm/slab.h:737
 slab_alloc_node mm/slub.c:3398 [inline]
 kmem_cache_alloc_node+0x136/0x310 mm/slub.c:3443
 alloc_task_struct_node kernel/fork.c:172 [inline]
 dup_task_struct+0x57/0x6d0 kernel/fork.c:981
 copy_process+0x637/0x40a0 kernel/fork.c:2096
 kernel_clone+0x222/0x920 kernel/fork.c:2681
 user_mode_thread+0x12e/0x190 kernel/fork.c:2757
 call_usermodehelper_exec_sync kernel/umh.c:136 [inline]
 call_usermodehelper_exec_work+0x93/0x220 kernel/umh.c:167
 process_one_work+0x917/0x1260 kernel/workqueue.c:2292
 worker_thread+0xa47/0x1200 kernel/workqueue.c:2439

Memory state around the buggy address:
 ffff88807a7ba400: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff88807a7ba480: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff88807a7ba500: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                                           ^
 ffff88807a7ba580: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff88807a7ba600: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================

Crashes (7):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2025/02/17 05:32 linux-6.1.y 0cbb5f65e52f 40a34ec9 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan KASAN: use-after-free Read in l2cap_sock_new_connection_cb
2025/02/15 12:18 linux-6.1.y 0cbb5f65e52f 40a34ec9 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan KASAN: use-after-free Read in l2cap_sock_new_connection_cb
2024/11/16 03:37 linux-6.1.y 59d7b1a7104a cfe3a04a .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan KASAN: use-after-free Read in l2cap_sock_new_connection_cb
2024/11/13 06:45 linux-6.1.y d7039b844a1c 62026c85 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan KASAN: use-after-free Read in l2cap_sock_new_connection_cb
2024/11/01 14:53 linux-6.1.y 7c15117f9468 96eb609f .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan KASAN: use-after-free Read in l2cap_sock_new_connection_cb
2025/03/06 04:51 linux-6.1.y 3a8358583626 831e3629 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan-arm64 KASAN: use-after-free Read in l2cap_sock_new_connection_cb
2025/02/15 01:16 linux-6.1.y 0cbb5f65e52f 1022af74 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan-arm64 KASAN: use-after-free Read in l2cap_sock_new_connection_cb
* Struck through repros no longer work on HEAD.