syzbot


KASAN: use-after-free Read in l2cap_unregister_user

Status: upstream: reported on 2024/11/07 17:33
Reported-by: syzbot+51b9f0aeb761754e57b8@syzkaller.appspotmail.com
First crash: 27d, last: 4d16h
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_unregister_user 7 4h37m 14d 0/3 upstream: reported on 2024/11/20 17:00
upstream KASAN: slab-use-after-free Read in l2cap_unregister_user bluetooth syz 8082 8m 33d 0/28 upstream: reported syz repro on 2024/11/01 18:29

Sample crash report:
==================================================================
BUG: KASAN: use-after-free in __mutex_waiter_is_first kernel/locking/mutex.c:197 [inline]
BUG: KASAN: use-after-free in __mutex_lock_common kernel/locking/mutex.c:681 [inline]
BUG: KASAN: use-after-free in __mutex_lock+0x6d2/0xd80 kernel/locking/mutex.c:747
Read of size 8 at addr ffff888077260060 by task khidpd_0006fff9/5346

CPU: 1 PID: 5346 Comm: khidpd_0006fff9 Not tainted 6.1.119-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 09/13/2024
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
 __mutex_waiter_is_first kernel/locking/mutex.c:197 [inline]
 __mutex_lock_common kernel/locking/mutex.c:681 [inline]
 __mutex_lock+0x6d2/0xd80 kernel/locking/mutex.c:747
 l2cap_unregister_user+0x63/0x1b0 net/bluetooth/l2cap_core.c:1892
 hidp_session_thread+0x44b/0x490 net/bluetooth/hidp/core.c:1305
 kthread+0x28d/0x320 kernel/kthread.c:376
 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:295
 </TASK>

Allocated by task 4283:
 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]
 kzalloc include/linux/slab.h:693 [inline]
 hci_alloc_dev_priv+0x23/0x1d60 net/bluetooth/hci_core.c:2436
 hci_alloc_dev include/net/bluetooth/hci_core.h:1469 [inline]
 __vhci_create_device drivers/bluetooth/hci_vhci.c:308 [inline]
 vhci_create_device+0x12a/0x700 drivers/bluetooth/hci_vhci.c:379
 vhci_get_user drivers/bluetooth/hci_vhci.c:436 [inline]
 vhci_write+0x38b/0x440 drivers/bluetooth/hci_vhci.c:516
 call_write_iter include/linux/fs.h:2265 [inline]
 new_sync_write fs/read_write.c:491 [inline]
 vfs_write+0x857/0xbc0 fs/read_write.c:584
 ksys_write+0x19c/0x2c0 fs/read_write.c:637
 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 4940:
 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
 hci_release_dev+0x14ea/0x1670 net/bluetooth/hci_core.c:2766
 bt_host_release+0x7f/0x90 net/bluetooth/hci_sysfs.c:92
 device_release+0x91/0x1c0
 kobject_cleanup lib/kobject.c:681 [inline]
 kobject_release lib/kobject.c:712 [inline]
 kref_put include/linux/kref.h:65 [inline]
 kobject_put+0x224/0x460 lib/kobject.c:729
 vhci_release+0x87/0xd0 drivers/bluetooth/hci_vhci.c:574
 __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
 insert_work+0x54/0x3d0 kernel/workqueue.c:1361
 __queue_work+0xb4b/0xf90 kernel/workqueue.c:1520
 queue_work_on+0x14b/0x250 kernel/workqueue.c:1548
 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

Second to 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
 insert_work+0x54/0x3d0 kernel/workqueue.c:1361
 __queue_work+0xb4b/0xf90 kernel/workqueue.c:1520
 call_timer_fn+0x1ad/0x6b0 kernel/time/timer.c:1504
 expire_timers kernel/time/timer.c:1544 [inline]
 __run_timers+0x6a8/0x890 kernel/time/timer.c:1820
 run_timer_softirq+0x63/0xf0 kernel/time/timer.c:1833
 handle_softirqs+0x2ee/0xa40 kernel/softirq.c:571
 run_ksoftirqd+0xc6/0x120 kernel/softirq.c:938
 smpboot_thread_fn+0x52c/0xa30 kernel/smpboot.c:164
 kthread+0x28d/0x320 kernel/kthread.c:376
 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:295

The buggy address belongs to the object at ffff888077260000
 which belongs to the cache kmalloc-8k of size 8192
The buggy address is located 96 bytes inside of
 8192-byte region [ffff888077260000, ffff888077262000)

The buggy address belongs to the physical page:
page:ffffea0001dc9800 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x77260
head:ffffea0001dc9800 order:3 compound_mapcount:0 compound_pincount:0
flags: 0xfff00000010200(slab|head|node=0|zone=1|lastcpupid=0x7ff)
raw: 00fff00000010200 0000000000000000 dead000000000122 ffff888017c42280
raw: 0000000000000000 0000000000020002 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 4283, tgid 4283 (syz-executor), ts 343086469301, free_ts 342899404913
 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+0xa1/0x230 mm/slab_common.c:949
 kmalloc include/linux/slab.h:562 [inline]
 kzalloc include/linux/slab.h:693 [inline]
 hci_alloc_dev_priv+0x23/0x1d60 net/bluetooth/hci_core.c:2436
 hci_alloc_dev include/net/bluetooth/hci_core.h:1469 [inline]
 __vhci_create_device drivers/bluetooth/hci_vhci.c:308 [inline]
 vhci_create_device+0x12a/0x700 drivers/bluetooth/hci_vhci.c:379
 vhci_get_user drivers/bluetooth/hci_vhci.c:436 [inline]
 vhci_write+0x38b/0x440 drivers/bluetooth/hci_vhci.c:516
 call_write_iter include/linux/fs.h:2265 [inline]
 new_sync_write fs/read_write.c:491 [inline]
 vfs_write+0x857/0xbc0 fs/read_write.c:584
 ksys_write+0x19c/0x2c0 fs/read_write.c:637
 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
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
 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+0x137/0x260 mm/slub.c:3437
 kmalloc_node_trace+0x23/0xe0 mm/slab_common.c:1039
 kmalloc_node include/linux/slab.h:579 [inline]
 kzalloc_node include/linux/slab.h:704 [inline]
 __get_vm_area_node+0x126/0x360 mm/vmalloc.c:2498
 __vmalloc_node_range+0x37d/0x14b0 mm/vmalloc.c:3193
 vmalloc_user+0x70/0x80 mm/vmalloc.c:3387
 kcov_ioctl+0x55/0x630 kernel/kcov.c:713
 vfs_ioctl fs/ioctl.c:51 [inline]
 __do_sys_ioctl fs/ioctl.c:870 [inline]
 __se_sys_ioctl+0xf1/0x160 fs/ioctl.c:856
 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

Memory state around the buggy address:
 ffff88807725ff00: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
 ffff88807725ff80: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
>ffff888077260000: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                                                       ^
 ffff888077260080: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff888077260100: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================

Crashes (11):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2024/11/29 02:28 linux-6.1.y e4d90d63d385 5df23865 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan KASAN: use-after-free Read in l2cap_unregister_user
2024/11/27 12:13 linux-6.1.y e4d90d63d385 52b38cc1 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan KASAN: use-after-free Read in l2cap_unregister_user
2024/11/30 03:00 linux-6.1.y e4d90d63d385 68914665 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan-arm64 KASAN: use-after-free Read in l2cap_unregister_user
2024/11/20 14:37 linux-6.1.y b67dc5c9ade9 4fca1650 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan-arm64 KASAN: use-after-free Read in l2cap_unregister_user
2024/11/20 01:38 linux-6.1.y b67dc5c9ade9 7d02db5a .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan-arm64 KASAN: use-after-free Read in l2cap_unregister_user
2024/11/19 01:59 linux-6.1.y b67dc5c9ade9 571351cb .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan-arm64 KASAN: use-after-free Read in l2cap_unregister_user
2024/11/18 08:32 linux-6.1.y b67dc5c9ade9 cfe3a04a .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan-arm64 KASAN: use-after-free Read in l2cap_unregister_user
2024/11/13 19:17 linux-6.1.y d7039b844a1c bb3f8425 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan-arm64 KASAN: use-after-free Read in l2cap_unregister_user
2024/11/11 19:05 linux-6.1.y d7039b844a1c 0c4b1325 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan-arm64 KASAN: use-after-free Read in l2cap_unregister_user
2024/11/10 03:16 linux-6.1.y d7039b844a1c 6b856513 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan-arm64 KASAN: use-after-free Read in l2cap_unregister_user
2024/11/07 17:32 linux-6.1.y 7c15117f9468 867e44df .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan-arm64 KASAN: use-after-free Read in l2cap_unregister_user
* Struck through repros no longer work on HEAD.