syzbot


KASAN: use-after-free Read in l2cap_connect_cfm

Status: upstream: reported on 2024/10/19 04:09
Reported-by: syzbot+45bb087e690ccd9196bf@syzkaller.appspotmail.com
First crash: 63d, last: 32d
Similar bugs (1)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
upstream KASAN: slab-use-after-free Read in l2cap_connect_cfm bluetooth syz inconclusive 19 6d03h 4d07h 0/28 upstream: reported on 2024/12/17 17:58

Sample crash report:
 kthread+0x28d/0x320 kernel/kthread.c:376
 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:295
 </TASK>
kobject_add_internal failed for hci1:201 with -EEXIST, don't try to register things with the same name in the same directory.
Bluetooth: hci1: failed to register connection device
==================================================================
BUG: KASAN: use-after-free in l2cap_connect_cfm+0x752/0x1270 net/bluetooth/l2cap_core.c:8334
Read of size 8 at addr ffff8880251fc498 by task kworker/u5:2/4253

CPU: 0 PID: 4253 Comm: kworker/u5:2 Not tainted 6.1.118-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 10/30/2024
Workqueue: hci1 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:284 [inline]
 print_report+0x15f/0x4f0 mm/kasan/report.c:395
 kasan_report+0x136/0x160 mm/kasan/report.c:495
 l2cap_connect_cfm+0x752/0x1270 net/bluetooth/l2cap_core.c:8334
 hci_connect_cfm+0x9e/0x150 include/net/bluetooth/hci_core.h:1787
 le_conn_complete_evt+0xd54/0x1320 net/bluetooth/hci_event.c:6008
 hci_le_conn_complete_evt+0x188/0x410 net/bluetooth/hci_event.c:6034
 hci_event_func net/bluetooth/hci_event.c:7533 [inline]
 hci_event_packet+0xa40/0x1510 net/bluetooth/hci_event.c:7588
 hci_rx_work+0x3ee/0xce0 net/bluetooth/hci_core.c:4087
 process_one_work+0x8a9/0x11d0 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 4253:
 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
 kmalloc include/linux/slab.h:557 [inline]
 kzalloc include/linux/slab.h:693 [inline]
 l2cap_chan_create+0x4c/0x760 net/bluetooth/l2cap_core.c:469
 l2cap_sock_alloc net/bluetooth/l2cap_sock.c:1920 [inline]
 l2cap_sock_new_connection_cb+0x178/0x2a0 net/bluetooth/l2cap_sock.c:1502
 l2cap_connect_cfm+0x36b/0x1270 net/bluetooth/l2cap_core.c:8317
 hci_connect_cfm+0x9e/0x150 include/net/bluetooth/hci_core.h:1787
 le_conn_complete_evt+0xd54/0x1320 net/bluetooth/hci_event.c:6008
 hci_le_conn_complete_evt+0x188/0x410 net/bluetooth/hci_event.c:6034
 hci_event_func net/bluetooth/hci_event.c:7533 [inline]
 hci_event_packet+0xa40/0x1510 net/bluetooth/hci_event.c:7588
 hci_rx_work+0x3ee/0xce0 net/bluetooth/hci_core.c:4087
 process_one_work+0x8a9/0x11d0 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 10125:
 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
 l2cap_sock_cleanup_listen+0xe9/0x270 net/bluetooth/l2cap_sock.c:1485
 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
 exit_task_work include/linux/task_work.h:39 [inline]
 do_exit+0xa73/0x26a0 kernel/exit.c:871
 do_group_exit+0x202/0x2b0 kernel/exit.c:1021
 get_signal+0x16f7/0x17d0 kernel/signal.c:2871
 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

Last potentially related work creation:
 kasan_save_stack+0x3b/0x60 mm/kasan/common.c:45
 __kasan_record_aux_stack+0xb0/0xc0 mm/kasan/generic.c:486
 call_rcu+0x163/0xa10 kernel/rcu/tree.c:2845
 netlink_release+0x1554/0x19e0 net/netlink/af_netlink.c:815
 __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
 resume_user_mode_work include/linux/resume_user_mode.h:49 [inline]
 exit_to_user_mode_loop+0xde/0x100 kernel/entry/common.c:177
 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 ffff8880251fc000
 which belongs to the cache kmalloc-2k of size 2048
The buggy address is located 1176 bytes inside of
 2048-byte region [ffff8880251fc000, ffff8880251fc800)

The buggy address belongs to the physical page:
page:ffffea0000947e00 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x251f8
head:ffffea0000947e00 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 0x1d2a20(GFP_ATOMIC|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_NOMEMALLOC|__GFP_HARDWALL), pid 5824, tgid 5824 (syz-executor), ts 149343688671, free_ts 148447272628
 set_page_owner include/linux/page_owner.h:31 [inline]
 post_alloc_hook+0x18d/0x1b0 mm/page_alloc.c:2517
 prep_new_page mm/page_alloc.c:2524 [inline]
 get_page_from_freelist+0x3731/0x38d0 mm/page_alloc.c:4313
 __alloc_pages+0x28d/0x770 mm/page_alloc.c:5589
 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]
 pskb_expand_head+0x18c/0x10e0 net/core/skbuff.c:1848
 netlink_trim+0x183/0x220 net/netlink/af_netlink.c:1308
 netlink_broadcast+0x5b/0x10b0 net/netlink/af_netlink.c:1502
 nlmsg_multicast include/net/netlink.h:1071 [inline]
 nlmsg_notify+0xfb/0x1c0 net/netlink/af_netlink.c:2551
 __dev_notify_flags+0xdd/0x610 net/core/dev.c:8627
 rtnl_newlink_create net/core/rtnetlink.c:3427 [inline]
 __rtnl_newlink net/core/rtnetlink.c:3639 [inline]
 rtnl_newlink+0x1946/0x2050 net/core/rtnetlink.c:3652
 rtnetlink_rcv_msg+0x818/0xff0 net/core/rtnetlink.c:6150
 netlink_rcv_skb+0x1cd/0x410 net/netlink/af_netlink.c:2508
page last free stack trace:
 reset_page_owner include/linux/page_owner.h:24 [inline]
 free_pages_prepare mm/page_alloc.c:1444 [inline]
 free_pcp_prepare mm/page_alloc.c:1494 [inline]
 free_unref_page_prepare+0xf63/0x1120 mm/page_alloc.c:3369
 free_unref_page+0x33/0x3e0 mm/page_alloc.c:3464
 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_kmalloc mm/kasan/common.c:340 [inline]
 __kasan_kmalloc+0x1f/0xb0 mm/kasan/common.c:383
 kmalloc include/linux/slab.h:557 [inline]
 netdevice_queue_work drivers/infiniband/core/roce_gid_mgmt.c:643 [inline]
 netdevice_event+0x3eb/0xa00 drivers/infiniband/core/roce_gid_mgmt.c:802
 notifier_call_chain kernel/notifier.c:87 [inline]
 raw_notifier_call_chain+0xd0/0x170 kernel/notifier.c:455
 call_netdevice_notifiers_info net/core/dev.c:1970 [inline]
 call_netdevice_notifiers_extack net/core/dev.c:2008 [inline]
 call_netdevice_notifiers net/core/dev.c:2022 [inline]
 unregister_netdevice_many+0xebf/0x17a0 net/core/dev.c:10890
 default_device_exit_batch+0x956/0x9d0 net/core/dev.c:11403
 ops_exit_list net/core/net_namespace.c:177 [inline]
 cleanup_net+0x763/0xb60 net/core/net_namespace.c:604
 process_one_work+0x8a9/0x11d0 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

Memory state around the buggy address:
 ffff8880251fc380: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff8880251fc400: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff8880251fc480: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                            ^
 ffff8880251fc500: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff8880251fc580: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================

Crashes (2):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2024/11/19 19:38 linux-6.1.y b67dc5c9ade9 7d02db5a .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan KASAN: use-after-free Read in l2cap_connect_cfm
2024/10/19 04:08 linux-6.1.y 54d90d17e8ce cd6fc0a3 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan-arm64 KASAN: use-after-free Read in l2cap_connect_cfm
* Struck through repros no longer work on HEAD.