[v6.1] KASAN: use-after-free Read in l2cap_sock_ready_cb

0 views
Skip to first unread message

syzbot

unread,
Dec 6, 2024, 8:13:33 AMDec 6
to syzkaller...@googlegroups.com
Hello,

syzbot found the following issue on:

HEAD commit: e4d90d63d385 Linux 6.1.119
git tree: linux-6.1.y
console output: https://syzkaller.appspot.com/x/log.txt?x=16c718df980000
kernel config: https://syzkaller.appspot.com/x/.config?x=5516a02be29a5649
dashboard link: https://syzkaller.appspot.com/bug?extid=7e5d4177beccbed48c84
compiler: Debian clang version 15.0.6, GNU ld (GNU Binutils for Debian) 2.40

Unfortunately, I don't have any reproducer for this issue yet.

Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/19f991f20183/disk-e4d90d63.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/61eb5f055f38/vmlinux-e4d90d63.xz
kernel image: https://storage.googleapis.com/syzbot-assets/0ddd97416681/bzImage-e4d90d63.xz

IMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by: syzbot+7e5d41...@syzkaller.appspotmail.com

</TASK>
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_sock_ready_cb+0xce/0x130 net/bluetooth/l2cap_sock.c:1704
Read of size 8 at addr ffff8880555254a8 by task kworker/u5:4/4261

CPU: 0 PID: 4261 Comm: kworker/u5:4 Not tainted 6.1.119-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 09/13/2024
Workqueue: hci0 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_sock_ready_cb+0xce/0x130 net/bluetooth/l2cap_sock.c:1704
l2cap_chan_ready net/bluetooth/l2cap_core.c:1409 [inline]
l2cap_le_start+0x4d2/0x17b0 net/bluetooth/l2cap_core.c:1521
l2cap_conn_ready net/bluetooth/l2cap_core.c:1790 [inline]
l2cap_connect_cfm+0x72b/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: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+0x3cd/0xce0 net/bluetooth/hci_core.c:4085
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 4484:
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:562 [inline]
sk_prot_alloc+0xe0/0x200 net/core/sock.c:2047
sk_alloc+0x36/0x350 net/core/sock.c:2100
bt_sock_alloc+0x37/0x130 net/bluetooth/af_bluetooth.c:148
l2cap_sock_alloc net/bluetooth/l2cap_sock.c:1911 [inline]
l2cap_sock_create+0x11e/0x2b0 net/bluetooth/l2cap_sock.c:1951
bt_sock_create+0x159/0x220 net/bluetooth/af_bluetooth.c:132
__sock_create+0x488/0x930 net/socket.c:1550
sock_create net/socket.c:1606 [inline]
__sys_socket_create net/socket.c:1643 [inline]
__sys_socket+0x136/0x3a0 net/socket.c:1671
__do_sys_socket net/socket.c:1684 [inline]
__se_sys_socket net/socket.c:1682 [inline]
__x64_sys_socket+0x76/0x80 net/socket.c:1682
do_syscall_x64 arch/x86/entry/common.c:51 [inline]
do_syscall_64+0x3b/0xb0 arch/x86/entry/common.c:81
entry_SYSCALL_64_after_hwframe+0x68/0xd2

Freed by task 4490:
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:2083 [inline]
__sk_destruct+0x473/0x5f0 net/core/sock.c:2169
l2cap_sock_release+0x157/0x1d0 net/bluetooth/l2cap_sock.c:1455
__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+0x15fc/0x17d0 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 ffff888055525000
which belongs to the cache kmalloc-2k of size 2048
The buggy address is located 1192 bytes inside of
2048-byte region [ffff888055525000, ffff888055525800)

The buggy address belongs to the physical page:
page:ffffea0001554800 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x55520
head:ffffea0001554800 order:3 compound_mapcount:0 compound_pincount:0
flags: 0xfff00000010200(slab|head|node=0|zone=1|lastcpupid=0x7ff)
raw: 00fff00000010200 ffffea0000a79200 dead000000000002 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 0xd2a20(GFP_ATOMIC|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_NOMEMALLOC), pid 11, tgid 11 (kworker/u4:1), ts 78175467642, free_ts 20804585807
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:5590
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+0x135/0x670 net/core/skbuff.c:515
alloc_skb include/linux/skbuff.h:1271 [inline]
nlmsg_new include/net/netlink.h:991 [inline]
inet6_ifinfo_notify+0x69/0x110 net/ipv6/addrconf.c:6081
addrconf_notify+0xc56/0xf60 net/ipv6/addrconf.c:3689
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]
netdev_state_change+0x1a3/0x250 net/core/dev.c:1359
linkwatch_do_dev+0x10c/0x160 net/core/link_watch.c:168
__linkwatch_run_queue+0x448/0x6b0 net/core/link_watch.c:221
linkwatch_event+0x48/0x50 net/core/link_watch.c:264
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_contig_range+0x9a/0x150 mm/page_alloc.c:9550
destroy_args+0xfe/0x997 mm/debug_vm_pgtable.c:1031
debug_vm_pgtable+0x416/0x46b mm/debug_vm_pgtable.c:1354
do_one_initcall+0x265/0x8f0 init/main.c:1298
do_initcall_level+0x157/0x207 init/main.c:1371
do_initcalls+0x49/0x86 init/main.c:1387
kernel_init_freeable+0x45c/0x60f init/main.c:1626
kernel_init+0x19/0x290 init/main.c:1514
ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:295

Memory state around the buggy address:
ffff888055525380: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff888055525400: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff888055525480: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
^
ffff888055525500: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff888055525580: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================


---
This report is generated by a bot. It may contain errors.
See https://goo.gl/tpsmEJ for more information about syzbot.
syzbot engineers can be reached at syzk...@googlegroups.com.

syzbot will keep track of this issue. See:
https://goo.gl/tpsmEJ#status for how to communicate with syzbot.

If the report is already addressed, let syzbot know by replying with:
#syz fix: exact-commit-title

If you want to overwrite report's subsystems, reply with:
#syz set subsystems: new-subsystem
(See the list of subsystem names on the web dashboard)

If the report is a duplicate of another one, reply with:
#syz dup: exact-subject-of-another-report

If you want to undo deduplication, reply with:
#syz undup

syzbot

unread,
Dec 9, 2024, 5:59:28 AM (12 days ago) Dec 9
to syzkaller...@googlegroups.com
Hello,

syzbot found the following issue on:

HEAD commit: 0a51d2d4527b Linux 5.15.173
git tree: linux-5.15.y
console output: https://syzkaller.appspot.com/x/log.txt?x=12205c0f980000
kernel config: https://syzkaller.appspot.com/x/.config?x=69147a3052c29ea2
dashboard link: https://syzkaller.appspot.com/bug?extid=d6682be737fb2c4b9944
compiler: Debian clang version 15.0.6, GNU ld (GNU Binutils for Debian) 2.40
userspace arch: arm64

Unfortunately, I don't have any reproducer for this issue yet.

Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/cbeb11c653b7/disk-0a51d2d4.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/3b646052737b/vmlinux-0a51d2d4.xz
kernel image: https://storage.googleapis.com/syzbot-assets/0f7e7bafd5b2/Image-0a51d2d4.gz.xz

IMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by: syzbot+d6682b...@syzkaller.appspotmail.com

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_ready_cb+0xc4/0x130 net/bluetooth/l2cap_sock.c:1659
Read of size 8 at addr ffff0000dc6874c8 by task kworker/u5:3/4028

CPU: 1 PID: 4028 Comm: kworker/u5:3 Not tainted 5.15.173-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 09/13/2024
Workqueue: hci2 hci_rx_work
Call trace:
dump_backtrace+0x0/0x530 arch/arm64/kernel/stacktrace.c:152
show_stack+0x2c/0x3c arch/arm64/kernel/stacktrace.c:216
__dump_stack lib/dump_stack.c:88 [inline]
dump_stack_lvl+0x108/0x170 lib/dump_stack.c:106
print_address_description+0x7c/0x3f0 mm/kasan/report.c:248
__kasan_report mm/kasan/report.c:434 [inline]
kasan_report+0x174/0x1e4 mm/kasan/report.c:451
__asan_report_load8_noabort+0x44/0x50 mm/kasan/report_generic.c:309
l2cap_sock_ready_cb+0xc4/0x130 net/bluetooth/l2cap_sock.c:1659
l2cap_chan_ready net/bluetooth/l2cap_core.c:1385 [inline]
l2cap_le_start+0x59c/0x19dc net/bluetooth/l2cap_core.c:1497
l2cap_conn_ready net/bluetooth/l2cap_core.c:1766 [inline]
l2cap_connect_cfm+0x5a8/0xe5c net/bluetooth/l2cap_core.c:8298
hci_connect_cfm include/net/bluetooth/hci_core.h:1505 [inline]
le_conn_complete_evt+0xa30/0x1228 net/bluetooth/hci_event.c:5432
hci_le_conn_complete_evt net/bluetooth/hci_event.c:5457 [inline]
hci_le_meta_evt+0x234/0x31c0 net/bluetooth/hci_event.c:6178
hci_event_packet+0xd34/0x12b4 net/bluetooth/hci_event.c:6527
hci_rx_work+0x1c0/0x7c4 net/bluetooth/hci_core.c:5155
process_one_work+0x790/0x11b8 kernel/workqueue.c:2310
worker_thread+0x910/0x1034 kernel/workqueue.c:2457
kthread+0x37c/0x45c kernel/kthread.c:334
ret_from_fork+0x10/0x20 arch/arm64/kernel/entry.S:870

Allocated by task 5905:
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+0xbc/0xfc mm/kasan/common.c:513
__kasan_kmalloc+0x10/0x1c mm/kasan/common.c:522
kasan_kmalloc include/linux/kasan.h:264 [inline]
__kmalloc+0x29c/0x4c8 mm/slub.c:4407
kmalloc include/linux/slab.h:596 [inline]
sk_prot_alloc+0xc4/0x1f0 net/core/sock.c:1863
sk_alloc+0x40/0x3e0 net/core/sock.c:1916
l2cap_sock_alloc net/bluetooth/l2cap_sock.c:1861 [inline]
l2cap_sock_create+0x140/0x33c net/bluetooth/l2cap_sock.c:1907
bt_sock_create+0x14c/0x248 net/bluetooth/af_bluetooth.c:130
__sock_create+0x43c/0x8a0 net/socket.c:1486
sock_create net/socket.c:1542 [inline]
__sys_socket+0x168/0x310 net/socket.c:1584
__do_sys_socket net/socket.c:1593 [inline]
__se_sys_socket net/socket.c:1591 [inline]
__arm64_sys_socket+0x7c/0x94 net/socket.c:1591
__invoke_syscall arch/arm64/kernel/syscall.c:38 [inline]
invoke_syscall+0x98/0x2b8 arch/arm64/kernel/syscall.c:52
el0_svc_common+0x138/0x258 arch/arm64/kernel/syscall.c:142
do_el0_svc+0x58/0x14c arch/arm64/kernel/syscall.c:181
el0_svc+0x7c/0x1f0 arch/arm64/kernel/entry-common.c:608
el0t_64_sync_handler+0x84/0xe4 arch/arm64/kernel/entry-common.c:626
el0t_64_sync+0x1a0/0x1a4 arch/arm64/kernel/entry.S:584

Freed by task 5905:
kasan_save_stack mm/kasan/common.c:38 [inline]
kasan_set_track+0x4c/0x84 mm/kasan/common.c:46
kasan_set_free_info+0x28/0x4c mm/kasan/generic.c:360
____kasan_slab_free+0x118/0x164 mm/kasan/common.c:366
__kasan_slab_free+0x18/0x28 mm/kasan/common.c:374
kasan_slab_free include/linux/kasan.h:230 [inline]
slab_free_hook mm/slub.c:1705 [inline]
slab_free_freelist_hook+0x128/0x1ec mm/slub.c:1731
slab_free mm/slub.c:3499 [inline]
kfree+0x178/0x410 mm/slub.c:4559
sk_prot_free net/core/sock.c:1899 [inline]
__sk_destruct+0x418/0x600 net/core/sock.c:1985
sk_destruct net/core/sock.c:2000 [inline]
__sk_free+0x37c/0x4e8 net/core/sock.c:2011
sk_free+0x68/0xdc net/core/sock.c:2022
sock_put include/net/sock.h:1923 [inline]
l2cap_sock_kill+0x114/0x228 net/bluetooth/l2cap_sock.c:1258
l2cap_sock_release+0x138/0x1b4 net/bluetooth/l2cap_sock.c:1429
__sock_release net/socket.c:649 [inline]
sock_close+0xb8/0x1fc net/socket.c:1336
__fput+0x1c4/0x800 fs/file_table.c:280
____fput+0x20/0x30 fs/file_table.c:308
task_work_run+0x130/0x1e4 kernel/task_work.c:188
exit_task_work include/linux/task_work.h:33 [inline]
do_exit+0x670/0x20bc kernel/exit.c:874
do_group_exit+0x110/0x268 kernel/exit.c:996
get_signal+0x634/0x1550 kernel/signal.c:2900
do_signal arch/arm64/kernel/signal.c:890 [inline]
do_notify_resume+0x3d0/0x32b8 arch/arm64/kernel/signal.c:943
prepare_exit_to_user_mode arch/arm64/kernel/entry-common.c:133 [inline]
exit_to_user_mode arch/arm64/kernel/entry-common.c:138 [inline]
el0_svc+0xfc/0x1f0 arch/arm64/kernel/entry-common.c:609
el0t_64_sync_handler+0x84/0xe4 arch/arm64/kernel/entry-common.c:626
el0t_64_sync+0x1a0/0x1a4 arch/arm64/kernel/entry.S:584

Last potentially related work creation:
kasan_save_stack+0x38/0x68 mm/kasan/common.c:38
kasan_record_aux_stack+0xd4/0x11c mm/kasan/generic.c:348
kvfree_call_rcu+0xb8/0x684 kernel/rcu/tree.c:3596
drop_sysctl_table+0x274/0x3a0 fs/proc/proc_sysctl.c:1678
unregister_sysctl_table+0x94/0x130 fs/proc/proc_sysctl.c:1716
unregister_net_sysctl_table+0x20/0x30 net/sysctl_net.c:175
__devinet_sysctl_unregister net/ipv4/devinet.c:2626 [inline]
devinet_sysctl_unregister net/ipv4/devinet.c:2654 [inline]
inetdev_destroy net/ipv4/devinet.c:326 [inline]
inetdev_event+0x534/0x1234 net/ipv4/devinet.c:1611
notifier_call_chain kernel/notifier.c:83 [inline]
raw_notifier_call_chain+0xd4/0x164 kernel/notifier.c:391
call_netdevice_notifiers_info net/core/dev.c:2018 [inline]
call_netdevice_notifiers_extack net/core/dev.c:2030 [inline]
call_netdevice_notifiers net/core/dev.c:2044 [inline]
unregister_netdevice_many+0xec4/0x189c net/core/dev.c:11102
default_device_exit_batch+0x4c0/0x520 net/core/dev.c:11635
ops_exit_list net/core/net_namespace.c:177 [inline]
cleanup_net+0x5e0/0x9bc net/core/net_namespace.c:599
process_one_work+0x790/0x11b8 kernel/workqueue.c:2310
worker_thread+0x910/0x1034 kernel/workqueue.c:2457
kthread+0x37c/0x45c kernel/kthread.c:334
ret_from_fork+0x10/0x20 arch/arm64/kernel/entry.S:870

The buggy address belongs to the object at ffff0000dc687000
which belongs to the cache kmalloc-2k of size 2048
The buggy address is located 1224 bytes inside of
2048-byte region [ffff0000dc687000, ffff0000dc687800)
The buggy address belongs to the page:
page:00000000caabca20 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x11c680
head:00000000caabca20 order:3 compound_mapcount:0 compound_pincount:0
flags: 0x5ffc00000010200(slab|head|node=0|zone=2|lastcpupid=0x7ff)
raw: 05ffc00000010200 0000000000000000 0000000100000001 ffff0000c0002900
raw: 0000000000000000 0000000000080008 00000001ffffffff 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
ffff0000dc687380: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff0000dc687400: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff0000dc687480: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
^
ffff0000dc687500: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff0000dc687580: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
Reply all
Reply to author
Forward
0 new messages