syzbot


KASAN: use-after-free Read in l2cap_sock_ready_cb (2)

Status: upstream: reported on 2025/04/13 01:53
Reported-by: syzbot+9fa3c1df7f589b4c063e@syzkaller.appspotmail.com
First crash: 54d, last: 54d
Similar bugs (4)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
linux-5.15 KASAN: use-after-free Read in l2cap_sock_ready_cb 2 166d 178d 0/3 auto-obsoleted due to no activity on 2025/04/01 01:17
linux-6.1 KASAN: use-after-free Read in l2cap_sock_ready_cb 1 181d 181d 0/3 auto-obsoleted due to no activity on 2025/03/16 13:13
upstream KASAN: slab-use-after-free Read in l2cap_sock_ready_cb (2) bluetooth 47 7d00h 247d 0/28 upstream: reported on 2024/10/01 10:15
upstream KASAN: slab-use-after-free Read in l2cap_sock_ready_cb bluetooth 1 375d 370d 0/28 auto-obsoleted due to no activity on 2024/09/04 06:40

Sample crash report:
==================================================================
BUG: KASAN: use-after-free in l2cap_sock_ready_cb+0xce/0x130 net/bluetooth/l2cap_sock.c:1659
Read of size 8 at addr ffff88807e2844c8 by task kworker/u5:8/4189

CPU: 0 PID: 4189 Comm: kworker/u5:8 Not tainted 5.15.180-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 02/12/2025
Workqueue: hci0 hci_rx_work
Call Trace:
 <TASK>
 __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_sock_ready_cb+0xce/0x130 net/bluetooth/l2cap_sock.c:1659
 l2cap_chan_ready net/bluetooth/l2cap_core.c:1386 [inline]
 l2cap_le_start+0x4fa/0x1e60 net/bluetooth/l2cap_core.c:1498
 l2cap_conn_ready net/bluetooth/l2cap_core.c:1767 [inline]
 l2cap_connect_cfm+0x72b/0x1270 net/bluetooth/l2cap_core.c:8294
 hci_connect_cfm include/net/bluetooth/hci_core.h:1505 [inline]
 le_conn_complete_evt+0xd02/0x1500 net/bluetooth/hci_event.c:5429
 hci_le_conn_complete_evt net/bluetooth/hci_event.c:5454 [inline]
 hci_le_meta_evt+0x28c/0x3f50 net/bluetooth/hci_event.c:6175
 hci_event_packet+0xc41/0x1550 net/bluetooth/hci_event.c:6524
 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
 </TASK>

Allocated by task 6132:
 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]
 __kmalloc+0x168/0x300 mm/slub.c:4407
 kmalloc include/linux/slab.h:609 [inline]
 sk_prot_alloc+0xe0/0x200 net/core/sock.c:1866
 sk_alloc+0x35/0x310 net/core/sock.c:1919
 l2cap_sock_alloc+0x34/0x200 net/bluetooth/l2cap_sock.c:1861
 l2cap_sock_create+0x10d/0x1c0 net/bluetooth/l2cap_sock.c:1909
 bt_sock_create+0x159/0x220 net/bluetooth/af_bluetooth.c:130
 __sock_create+0x460/0x8f0 net/socket.c:1486
 sock_create net/socket.c:1542 [inline]
 __sys_socket+0x132/0x370 net/socket.c:1584
 __do_sys_socket net/socket.c:1593 [inline]
 __se_sys_socket net/socket.c:1591 [inline]
 __x64_sys_socket+0x76/0x80 net/socket.c:1591
 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

Freed by task 6131:
 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
 sk_prot_free net/core/sock.c:1902 [inline]
 __sk_destruct+0x593/0x840 net/core/sock.c:1988
 l2cap_sock_release+0x157/0x1d0 net/bluetooth/l2cap_sock.c:1429
 __sock_release net/socket.c:649 [inline]
 sock_close+0xcd/0x230 net/socket.c:1336
 __fput+0x3fe/0x8e0 fs/file_table.c:311
 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 ffff88807e284000
 which belongs to the cache kmalloc-2k of size 2048
The buggy address is located 1224 bytes inside of
 2048-byte region [ffff88807e284000, ffff88807e284800)
The buggy address belongs to the page:
page:ffffea0001f8a000 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x7e280
head:ffffea0001f8a000 order:3 compound_mapcount:0 compound_pincount:0
flags: 0xfff00000010200(slab|head|node=0|zone=1|lastcpupid=0x7ff)
raw: 00fff00000010200 0000000000000000 0000000100000001 ffff888017442000
raw: 0000000000000000 0000000000080008 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 0x1d20c0(__GFP_IO|__GFP_FS|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_NOMEMALLOC|__GFP_HARDWALL), pid 4182, ts 67630774172, free_ts 62836685830
 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:5466
 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]
 slab_alloc mm/slub.c:3228 [inline]
 __kmalloc+0x1c9/0x300 mm/slub.c:4403
 kmalloc include/linux/slab.h:609 [inline]
 kzalloc include/linux/slab.h:735 [inline]
 arpt_alloc_initial_table+0x68/0xc30 net/ipv4/netfilter/arp_tables.c:40
 arptable_filter_table_init+0x18/0x60 net/ipv4/netfilter/arptable_filter.c:44
 xt_find_table_lock+0x31a/0x3f0 net/netfilter/x_tables.c:1259
 xt_request_find_table_lock+0x22/0xf0 net/netfilter/x_tables.c:1284
 get_info net/ipv4/netfilter/arp_tables.c:807 [inline]
 do_arpt_get_ctl+0x8fd/0x1680 net/ipv4/netfilter/arp_tables.c:1451
 nf_getsockopt+0x28e/0x2b0 net/netfilter/nf_sockopt.c:116
 ip_getsockopt+0x15c3/0x2450 net/ipv4/ip_sockglue.c:1797
 tcp_getsockopt+0x25f/0x6ff0 net/ipv4/tcp.c:4313
 __sys_getsockopt+0x2a6/0x550 net/socket.c:2247
 __do_sys_getsockopt net/socket.c:2262 [inline]
 __se_sys_getsockopt net/socket.c:2259 [inline]
 __x64_sys_getsockopt+0xb1/0xc0 net/socket.c:2259
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x3b/0xb0 arch/x86/entry/common.c:80
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
 do_slab_free mm/slub.c:3487 [inline]
 ___cache_free+0xe3/0x100 mm/slub.c:3506
 qlist_free_all+0x36/0x90 mm/kasan/quarantine.c:176
 kasan_quarantine_reduce+0x162/0x180 mm/kasan/quarantine.c:283
 __kasan_slab_alloc+0x2f/0xc0 mm/kasan/common.c:444
 kasan_slab_alloc include/linux/kasan.h:254 [inline]
 slab_post_alloc_hook+0x53/0x380 mm/slab.h:519
 slab_alloc_node mm/slub.c:3220 [inline]
 slab_alloc mm/slub.c:3228 [inline]
 kmem_cache_alloc+0xf3/0x280 mm/slub.c:3233
 __d_alloc+0x2a/0x700 fs/dcache.c:1749
 d_alloc fs/dcache.c:1828 [inline]
 d_alloc_parallel+0xca/0x1390 fs/dcache.c:2582
 __lookup_slow+0x111/0x3d0 fs/namei.c:1648
 lookup_one_len+0x187/0x2d0 fs/namei.c:2718
 start_creating+0x17f/0x310 fs/debugfs/inode.c:354
 debugfs_create_dir+0x24/0x480 fs/debugfs/inode.c:559
 nsim_dev_port_debugfs_init drivers/net/netdevsim/dev.c:321 [inline]
 __nsim_dev_port_add+0x458/0xb90 drivers/net/netdevsim/dev.c:1308
 nsim_dev_port_add_all+0x35/0x110 drivers/net/netdevsim/dev.c:1372

Memory state around the buggy address:
 ffff88807e284380: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff88807e284400: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff88807e284480: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                                              ^
 ffff88807e284500: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff88807e284580: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================

Crashes (1):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2025/04/13 01:53 linux-5.15.y f7347f400572 0bd6db41 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan KASAN: use-after-free Read in l2cap_sock_ready_cb
* Struck through repros no longer work on HEAD.