syzbot


KASAN: slab-use-after-free Read in l2cap_sock_new_connection_cb

Status: upstream: reported on 2024/10/21 08:46
Subsystems: bluetooth
[Documentation on labels]
Reported-by: syzbot+cdae834448ec8c3602fe@syzkaller.appspotmail.com
First crash: 52d, last: 1d14h
Discussions (1)
Title Replies (including bot) Last reply
[syzbot] [bluetooth?] KASAN: slab-use-after-free Read in l2cap_sock_new_connection_cb 0 (1) 2024/10/21 08:46
Similar bugs (1)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
linux-6.1 KASAN: use-after-free Read in l2cap_sock_new_connection_cb 3 21d 35d 0/3 upstream: reported on 2024/11/01 14:54

Sample crash report:
==================================================================
BUG: KASAN: slab-use-after-free in l2cap_sock_new_connection_cb+0x1f8/0x2d0 net/bluetooth/l2cap_sock.c:1483
Read of size 8 at addr ffff88805691f580 by task kworker/u9:4/5853

CPU: 1 UID: 0 PID: 5853 Comm: kworker/u9:4 Not tainted 6.12.0-syzkaller-09435-g2c22dc1ee3a1 #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 09/13/2024
Workqueue: hci3 hci_rx_work
Call Trace:
 <TASK>
 __dump_stack lib/dump_stack.c:94 [inline]
 dump_stack_lvl+0x241/0x360 lib/dump_stack.c:120
 print_address_description mm/kasan/report.c:378 [inline]
 print_report+0x169/0x550 mm/kasan/report.c:489
 kasan_report+0x143/0x180 mm/kasan/report.c:602
 l2cap_sock_new_connection_cb+0x1f8/0x2d0 net/bluetooth/l2cap_sock.c:1483
 l2cap_connect_cfm+0x379/0x1220 net/bluetooth/l2cap_core.c:7261
 hci_connect_cfm+0xa4/0x150 include/net/bluetooth/hci_core.h:2035
 le_conn_complete_evt+0xd3e/0x12e0 net/bluetooth/hci_event.c:5763
 hci_le_conn_complete_evt+0x18c/0x420 net/bluetooth/hci_event.c:5789
 hci_event_func net/bluetooth/hci_event.c:7481 [inline]
 hci_event_packet+0xa57/0x1540 net/bluetooth/hci_event.c:7536
 hci_rx_work+0x3f3/0xdb0 net/bluetooth/hci_core.c:4039
 process_one_work kernel/workqueue.c:3229 [inline]
 process_scheduled_works+0xa65/0x1850 kernel/workqueue.c:3310
 worker_thread+0x870/0xd30 kernel/workqueue.c:3391
 kthread+0x2f2/0x390 kernel/kthread.c:389
 ret_from_fork+0x4d/0x80 arch/x86/kernel/process.c:147
 ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:244
 </TASK>

Allocated by task 5853:
 kasan_save_stack mm/kasan/common.c:47 [inline]
 kasan_save_track+0x3f/0x80 mm/kasan/common.c:68
 poison_kmalloc_redzone mm/kasan/common.c:377 [inline]
 __kasan_kmalloc+0x98/0xb0 mm/kasan/common.c:394
 kasan_kmalloc include/linux/kasan.h:260 [inline]
 __do_kmalloc_node mm/slub.c:4283 [inline]
 __kmalloc_noprof+0x285/0x4c0 mm/slub.c:4295
 kmalloc_noprof include/linux/slab.h:905 [inline]
 sk_prot_alloc+0xe0/0x210 net/core/sock.c:2165
 sk_alloc+0x38/0x370 net/core/sock.c:2218
 bt_sock_alloc+0x3c/0x340 net/bluetooth/af_bluetooth.c:148
 l2cap_sock_alloc net/bluetooth/l2cap_sock.c:1877 [inline]
 l2cap_sock_new_connection_cb+0xe1/0x2d0 net/bluetooth/l2cap_sock.c:1468
 l2cap_connect_cfm+0x379/0x1220 net/bluetooth/l2cap_core.c:7261
 hci_connect_cfm+0xa4/0x150 include/net/bluetooth/hci_core.h:2035
 le_conn_complete_evt+0xd3e/0x12e0 net/bluetooth/hci_event.c:5763
 hci_le_conn_complete_evt+0x18c/0x420 net/bluetooth/hci_event.c:5789
 hci_event_func net/bluetooth/hci_event.c:7481 [inline]
 hci_event_packet+0xa57/0x1540 net/bluetooth/hci_event.c:7536
 hci_rx_work+0x3f3/0xdb0 net/bluetooth/hci_core.c:4039
 process_one_work kernel/workqueue.c:3229 [inline]
 process_scheduled_works+0xa65/0x1850 kernel/workqueue.c:3310
 worker_thread+0x870/0xd30 kernel/workqueue.c:3391
 kthread+0x2f2/0x390 kernel/kthread.c:389
 ret_from_fork+0x4d/0x80 arch/x86/kernel/process.c:147
 ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:244

Freed by task 11128:
 kasan_save_stack mm/kasan/common.c:47 [inline]
 kasan_save_track+0x3f/0x80 mm/kasan/common.c:68
 kasan_save_free_info+0x40/0x50 mm/kasan/generic.c:582
 poison_slab_object mm/kasan/common.c:247 [inline]
 __kasan_slab_free+0x59/0x70 mm/kasan/common.c:264
 kasan_slab_free include/linux/kasan.h:233 [inline]
 slab_free_hook mm/slub.c:2338 [inline]
 slab_free mm/slub.c:4598 [inline]
 kfree+0x196/0x420 mm/slub.c:4746
 sk_prot_free net/core/sock.c:2201 [inline]
 __sk_destruct+0x479/0x5f0 net/core/sock.c:2293
 l2cap_sock_cleanup_listen+0xdd/0x3c0 net/bluetooth/l2cap_sock.c:1448
 l2cap_sock_release+0x5d/0x1d0 net/bluetooth/l2cap_sock.c:1411
 __sock_release net/socket.c:640 [inline]
 sock_close+0xbe/0x240 net/socket.c:1408
 __fput+0x23e/0xa50 fs/file_table.c:450
 task_work_run+0x251/0x310 kernel/task_work.c:239
 get_signal+0x15f7/0x1750 kernel/signal.c:2789
 arch_do_signal_or_restart+0x96/0x860 arch/x86/kernel/signal.c:337
 exit_to_user_mode_loop kernel/entry/common.c:111 [inline]
 exit_to_user_mode_prepare include/linux/entry-common.h:329 [inline]
 __syscall_exit_to_user_mode_work kernel/entry/common.c:207 [inline]
 syscall_exit_to_user_mode+0xce/0x340 kernel/entry/common.c:218
 do_syscall_64+0x100/0x230 arch/x86/entry/common.c:89
 entry_SYSCALL_64_after_hwframe+0x77/0x7f

The buggy address belongs to the object at ffff88805691f000
 which belongs to the cache kmalloc-2k of size 2048
The buggy address is located 1408 bytes inside of
 freed 2048-byte region [ffff88805691f000, ffff88805691f800)

The buggy address belongs to the physical page:
page: refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x56918
head: order:3 mapcount:0 entire_mapcount:0 nr_pages_mapped:0 pincount:0
flags: 0xfff00000000040(head|node=0|zone=1|lastcpupid=0x7ff)
page_type: f5(slab)
raw: 00fff00000000040 ffff88801ac42000 ffffea000085ac00 dead000000000002
raw: 0000000000000000 0000000080080008 00000001f5000000 0000000000000000
head: 00fff00000000040 ffff88801ac42000 ffffea000085ac00 dead000000000002
head: 0000000000000000 0000000080080008 00000001f5000000 0000000000000000
head: 00fff00000000003 ffffea00015a4601 ffffffffffffffff 0000000000000000
head: 0000000000000008 0000000000000000 00000000ffffffff 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 0xd28c0(GFP_NOWAIT|__GFP_IO|__GFP_FS|__GFP_NORETRY|__GFP_COMP|__GFP_NOMEMALLOC), pid 5854, tgid 5854 (syz-executor), ts 80223730017, free_ts 23119632737
 set_page_owner include/linux/page_owner.h:32 [inline]
 post_alloc_hook+0x1f3/0x230 mm/page_alloc.c:1556
 prep_new_page mm/page_alloc.c:1564 [inline]
 get_page_from_freelist+0x3649/0x3790 mm/page_alloc.c:3474
 __alloc_pages_noprof+0x292/0x710 mm/page_alloc.c:4751
 alloc_pages_mpol_noprof+0x3e8/0x680 mm/mempolicy.c:2265
 alloc_slab_page+0x6a/0x140 mm/slub.c:2408
 allocate_slab+0x5a/0x2f0 mm/slub.c:2574
 new_slab mm/slub.c:2627 [inline]
 ___slab_alloc+0xcd1/0x14b0 mm/slub.c:3815
 __slab_alloc+0x58/0xa0 mm/slub.c:3905
 __slab_alloc_node mm/slub.c:3980 [inline]
 slab_alloc_node mm/slub.c:4141 [inline]
 __do_kmalloc_node mm/slub.c:4282 [inline]
 __kmalloc_node_track_caller_noprof+0x2e9/0x4c0 mm/slub.c:4302
 kmalloc_reserve+0x111/0x2a0 net/core/skbuff.c:609
 pskb_expand_head+0x1f0/0x1380 net/core/skbuff.c:2275
 netlink_trim+0x183/0x220 net/netlink/af_netlink.c:1303
 netlink_broadcast_filtered+0x76/0x12a0 net/netlink/af_netlink.c:1509
 nlmsg_multicast_filtered include/net/netlink.h:1128 [inline]
 nlmsg_multicast include/net/netlink.h:1147 [inline]
 nlmsg_notify+0xfb/0x1c0 net/netlink/af_netlink.c:2584
 rtnl_notify net/core/rtnetlink.c:943 [inline]
 rtmsg_ifinfo_send net/core/rtnetlink.c:4365 [inline]
 rtmsg_ifinfo_event net/core/rtnetlink.c:4381 [inline]
 rtnetlink_event+0x21d/0x260 net/core/rtnetlink.c:6971
 notifier_call_chain+0x1a1/0x3e0 kernel/notifier.c:85
page last free pid 1 tgid 1 stack trace:
 reset_page_owner include/linux/page_owner.h:25 [inline]
 free_pages_prepare mm/page_alloc.c:1127 [inline]
 free_unref_page+0xdf9/0x1140 mm/page_alloc.c:2657
 free_contig_range+0x152/0x550 mm/page_alloc.c:6630
 destroy_args+0x92/0x910 mm/debug_vm_pgtable.c:1017
 debug_vm_pgtable+0x4be/0x550 mm/debug_vm_pgtable.c:1397
 do_one_initcall+0x24a/0x880 init/main.c:1266
 do_initcall_level+0x157/0x210 init/main.c:1328
 do_initcalls+0x3f/0x80 init/main.c:1344
 kernel_init_freeable+0x435/0x5d0 init/main.c:1577
 kernel_init+0x1d/0x2b0 init/main.c:1466
 ret_from_fork+0x4d/0x80 arch/x86/kernel/process.c:147
 ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:244

Memory state around the buggy address:
 ffff88805691f480: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff88805691f500: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff88805691f580: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                   ^
 ffff88805691f600: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff88805691f680: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================

Crashes (15):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2024/11/26 12:17 upstream 2c22dc1ee3a1 11dbc254 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-kasan-gce-root KASAN: slab-use-after-free Read in l2cap_sock_new_connection_cb
2024/11/15 13:04 upstream cfaaa7d010d1 f6ede3a3 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-kasan-gce-selinux-root KASAN: slab-use-after-free Read in l2cap_sock_new_connection_cb
2024/11/15 08:40 upstream cfaaa7d010d1 f6ede3a3 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-kasan-gce-selinux-root KASAN: slab-use-after-free Read in l2cap_sock_new_connection_cb
2024/11/14 23:56 upstream 0a9b9d17f3a7 77f3eeb7 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-kasan-gce-selinux-root KASAN: slab-use-after-free Read in l2cap_sock_new_connection_cb
2024/11/14 19:54 upstream 0a9b9d17f3a7 77f3eeb7 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-kasan-gce-selinux-root KASAN: slab-use-after-free Read in l2cap_sock_new_connection_cb
2024/11/14 04:27 upstream f1b785f4c787 a8c99394 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-kasan-gce-selinux-root KASAN: slab-use-after-free Read in l2cap_sock_new_connection_cb
2024/10/18 19:40 upstream 4d939780b705 cd6fc0a3 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-kasan-gce-selinux-root KASAN: slab-use-after-free Read in l2cap_sock_new_connection_cb
2024/10/15 19:08 upstream eca631b8fe80 14943bb8 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-kasan-gce-smack-root KASAN: slab-use-after-free Read in l2cap_sock_new_connection_cb
2024/11/18 19:41 upstream adc218676eef e7bb5d6e .config console log report [disk image (non-bootable)] [vmlinux] [kernel image] ci-snapshot-upstream-root KASAN: slab-use-after-free Read in l2cap_sock_new_connection_cb
2024/12/05 15:43 git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git for-kernelci 7b1d1d4cfac0 6e50d07b .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-gce-arm64 KASAN: slab-use-after-free Read in l2cap_sock_new_connection_cb
2024/11/15 17:20 git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git for-kernelci 887407160d72 f6ede3a3 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-gce-arm64 KASAN: slab-use-after-free Read in l2cap_sock_new_connection_cb
2024/11/15 13:19 git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git for-kernelci 887407160d72 f6ede3a3 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-gce-arm64 KASAN: slab-use-after-free Read in l2cap_sock_new_connection_cb
2024/11/14 21:34 git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git for-kernelci 887407160d72 77f3eeb7 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-gce-arm64 KASAN: slab-use-after-free Read in l2cap_sock_new_connection_cb
2024/11/02 07:31 git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git for-kernelci 5283dc78f4da f00eed24 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-gce-arm64 KASAN: slab-use-after-free Read in l2cap_sock_new_connection_cb
2024/10/25 18:27 git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git for-kernelci 7678c1b2735a 65e8686b .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-gce-arm64 KASAN: slab-use-after-free Read in l2cap_sock_new_connection_cb
* Struck through repros no longer work on HEAD.