syzbot


KASAN: use-after-free Read in l2cap_unregister_user

Status: upstream: reported on 2024/11/20 17:00
Reported-by: syzbot+e903ad7f4bd1974ccf75@syzkaller.appspotmail.com
First crash: 76d, last: 4d12h
Similar bugs (2)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
linux-6.1 KASAN: use-after-free Read in l2cap_unregister_user 35 6d08h 89d 0/3 upstream: reported on 2024/11/07 17:33
upstream KASAN: slab-use-after-free Read in l2cap_unregister_user bluetooth syz done 25222 7m 95d 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:191 [inline]
BUG: KASAN: use-after-free in __mutex_lock_common+0xe4a/0x25a0 kernel/locking/mutex.c:671
Read of size 8 at addr ffff888022628060 by task khidpd_046dfff9/5053

CPU: 0 PID: 5053 Comm: khidpd_046dfff9 Not tainted 5.15.176-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 12/27/2024
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
 __mutex_waiter_is_first kernel/locking/mutex.c:191 [inline]
 __mutex_lock_common+0xe4a/0x25a0 kernel/locking/mutex.c:671
 __mutex_lock kernel/locking/mutex.c:729 [inline]
 mutex_lock_nested+0x17/0x20 kernel/locking/mutex.c:743
 l2cap_unregister_user+0x63/0x1b0 net/bluetooth/l2cap_core.c:1868
 hidp_session_thread+0x44b/0x490 net/bluetooth/hidp/core.c:1305
 kthread+0x3f6/0x4f0 kernel/kthread.c:334
 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:287
 </TASK>

Allocated by task 4917:
 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:596 [inline]
 kzalloc include/linux/slab.h:721 [inline]
 hci_alloc_dev_priv+0x23/0x1d60 net/bluetooth/hci_core.c:3775
 hci_alloc_dev include/net/bluetooth/hci_core.h:1242 [inline]
 __vhci_create_device drivers/bluetooth/hci_vhci.c:102 [inline]
 vhci_create_device+0x120/0x590 drivers/bluetooth/hci_vhci.c:153
 vhci_get_user drivers/bluetooth/hci_vhci.c:210 [inline]
 vhci_write+0x382/0x430 drivers/bluetooth/hci_vhci.c:290
 call_write_iter include/linux/fs.h:2174 [inline]
 new_sync_write fs/read_write.c:507 [inline]
 vfs_write+0xacd/0xe50 fs/read_write.c:594
 ksys_write+0x1a2/0x2c0 fs/read_write.c:647
 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 4917:
 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
 hci_release_dev+0x149e/0x1620 net/bluetooth/hci_core.c:4096
 bt_host_release+0x7f/0x90 net/bluetooth/hci_sysfs.c:85
 device_release+0x91/0x1c0
 kobject_cleanup lib/kobject.c:713 [inline]
 kobject_release lib/kobject.c:744 [inline]
 kref_put include/linux/kref.h:65 [inline]
 kobject_put+0x224/0x460 lib/kobject.c:761
 vhci_release+0x7b/0xc0 drivers/bluetooth/hci_vhci.c:346
 __fput+0x3fe/0x8e0 fs/file_table.c:280
 task_work_run+0x129/0x1a0 kernel/task_work.c:188
 exit_task_work include/linux/task_work.h:33 [inline]
 do_exit+0x6a3/0x2480 kernel/exit.c:874
 do_group_exit+0x144/0x310 kernel/exit.c:996
 __do_sys_exit_group kernel/exit.c:1007 [inline]
 __se_sys_exit_group kernel/exit.c:1005 [inline]
 __x64_sys_exit_group+0x3b/0x40 kernel/exit.c:1005
 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

Last potentially related work creation:
 kasan_save_stack+0x36/0x60 mm/kasan/common.c:38
 kasan_record_aux_stack+0xba/0x100 mm/kasan/generic.c:348
 insert_work+0x54/0x3e0 kernel/workqueue.c:1366
 __queue_work+0x963/0xd00 kernel/workqueue.c:1532
 queue_work_on+0x14b/0x250 kernel/workqueue.c:1559
 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

Second to last potentially related work creation:
 kasan_save_stack+0x36/0x60 mm/kasan/common.c:38
 kasan_record_aux_stack+0xba/0x100 mm/kasan/generic.c:348
 insert_work+0x54/0x3e0 kernel/workqueue.c:1366
 __queue_work+0x963/0xd00 kernel/workqueue.c:1532
 call_timer_fn+0x16d/0x560 kernel/time/timer.c:1451
 expire_timers kernel/time/timer.c:1491 [inline]
 __run_timers+0x6a8/0x890 kernel/time/timer.c:1767
 run_timer_softirq+0x63/0xf0 kernel/time/timer.c:1780
 handle_softirqs+0x3a7/0x930 kernel/softirq.c:558
 __do_softirq kernel/softirq.c:592 [inline]
 invoke_softirq kernel/softirq.c:432 [inline]
 __irq_exit_rcu+0x157/0x240 kernel/softirq.c:641
 irq_exit_rcu+0x5/0x20 kernel/softirq.c:653
 instr_sysvec_apic_timer_interrupt arch/x86/kernel/apic/apic.c:1108 [inline]
 sysvec_apic_timer_interrupt+0xa0/0xc0 arch/x86/kernel/apic/apic.c:1108
 asm_sysvec_apic_timer_interrupt+0x16/0x20 arch/x86/include/asm/idtentry.h:676

The buggy address belongs to the object at ffff888022628000
 which belongs to the cache kmalloc-8k of size 8192
The buggy address is located 96 bytes inside of
 8192-byte region [ffff888022628000, ffff88802262a000)
The buggy address belongs to the page:
page:ffffea0000898a00 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x22628
head:ffffea0000898a00 order:3 compound_mapcount:0 compound_pincount:0
flags: 0xfff00000010200(slab|head|node=0|zone=1|lastcpupid=0x7ff)
raw: 00fff00000010200 0000000000000000 0000000100000001 ffff888017442280
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 0x1d20c0(__GFP_IO|__GFP_FS|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_NOMEMALLOC|__GFP_HARDWALL), pid 4917, ts 110124923088, free_ts 109810156412
 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:5465
 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:596 [inline]
 kzalloc include/linux/slab.h:721 [inline]
 hci_alloc_dev_priv+0x23/0x1d60 net/bluetooth/hci_core.c:3775
 hci_alloc_dev include/net/bluetooth/hci_core.h:1242 [inline]
 __vhci_create_device drivers/bluetooth/hci_vhci.c:102 [inline]
 vhci_create_device+0x120/0x590 drivers/bluetooth/hci_vhci.c:153
 vhci_get_user drivers/bluetooth/hci_vhci.c:210 [inline]
 vhci_write+0x382/0x430 drivers/bluetooth/hci_vhci.c:290
 call_write_iter include/linux/fs.h:2174 [inline]
 new_sync_write fs/read_write.c:507 [inline]
 vfs_write+0xacd/0xe50 fs/read_write.c:594
 ksys_write+0x1a2/0x2c0 fs/read_write.c:647
 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
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
 free_slab mm/slub.c:2015 [inline]
 discard_slab mm/slub.c:2021 [inline]
 __unfreeze_partials+0x1b7/0x210 mm/slub.c:2507
 put_cpu_partial+0x132/0x1a0 mm/slub.c:2587
 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
 kmem_cache_zalloc include/linux/slab.h:711 [inline]
 __kernfs_new_node+0xdb/0x750 fs/kernfs/dir.c:593
 kernfs_new_node+0x136/0x230 fs/kernfs/dir.c:669
 __kernfs_create_file+0x45/0x2e0 fs/kernfs/file.c:985
 sysfs_add_file_mode_ns+0x308/0x3e0 fs/sysfs/file.c:317
 create_files fs/sysfs/group.c:64 [inline]
 internal_create_group+0x573/0xf00 fs/sysfs/group.c:149
 internal_create_groups fs/sysfs/group.c:189 [inline]
 sysfs_create_groups+0x52/0x110 fs/sysfs/group.c:215

Memory state around the buggy address:
 ffff888022627f00: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
 ffff888022627f80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
>ffff888022628000: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                                                       ^
 ffff888022628080: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff888022628100: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================

Crashes (29):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2025/01/19 14:53 linux-5.15.y 4735586da88e f2cb035c .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan KASAN: use-after-free Read in l2cap_unregister_user
2025/01/15 22:22 linux-5.15.y 4735586da88e 968edaf4 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan KASAN: use-after-free Read in l2cap_unregister_user
2024/12/25 22:49 linux-5.15.y 91786f140358 444551c4 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan KASAN: use-after-free Read in l2cap_unregister_user
2024/12/25 18:02 linux-5.15.y 91786f140358 444551c4 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan KASAN: use-after-free Read in l2cap_unregister_user
2024/12/24 01:44 linux-5.15.y 91786f140358 444551c4 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan KASAN: use-after-free Read in l2cap_unregister_user
2024/12/07 23:53 linux-5.15.y 0a51d2d4527b 9ac0fdc6 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan KASAN: use-after-free Read in l2cap_unregister_user
2024/12/07 00:30 linux-5.15.y 0a51d2d4527b 9ac0fdc6 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan KASAN: use-after-free Read in l2cap_unregister_user
2024/11/27 23:11 linux-5.15.y 0a51d2d4527b 5df23865 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan KASAN: use-after-free Read in l2cap_unregister_user
2024/11/26 06:00 linux-5.15.y 0a51d2d4527b 11dbc254 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan KASAN: use-after-free Read in l2cap_unregister_user
2024/11/20 16:59 linux-5.15.y 0a51d2d4527b 4fca1650 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan KASAN: use-after-free Read in l2cap_unregister_user
2025/01/31 22:09 linux-5.15.y 003148680b79 aa47157c .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan-arm64 KASAN: use-after-free Read in l2cap_unregister_user
2025/01/30 00:12 linux-5.15.y 003148680b79 136953f1 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan-arm64 KASAN: use-after-free Read in l2cap_unregister_user
2025/01/29 06:23 linux-5.15.y 003148680b79 865ef71e .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan-arm64 KASAN: use-after-free Read in l2cap_unregister_user
2025/01/29 06:22 linux-5.15.y 003148680b79 865ef71e .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan-arm64 KASAN: use-after-free Read in l2cap_unregister_user
2025/01/24 16:36 linux-5.15.y 003148680b79 1293872d .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan-arm64 KASAN: use-after-free Read in l2cap_unregister_user
2025/01/21 19:40 linux-5.15.y 4735586da88e da72ac06 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan-arm64 KASAN: use-after-free Read in l2cap_unregister_user
2025/01/21 03:11 linux-5.15.y 4735586da88e 6e87cfa2 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan-arm64 KASAN: use-after-free Read in l2cap_unregister_user
2025/01/19 23:09 linux-5.15.y 4735586da88e f2cb035c .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan-arm64 KASAN: use-after-free Read in l2cap_unregister_user
2025/01/10 04:54 linux-5.15.y 4735586da88e 67d7ec0a .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan-arm64 KASAN: use-after-free Read in l2cap_unregister_user
2025/01/09 11:48 linux-5.15.y 91786f140358 9220929f .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan-arm64 KASAN: use-after-free Read in l2cap_unregister_user
2025/01/06 17:40 linux-5.15.y 91786f140358 f3558dbf .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan-arm64 KASAN: use-after-free Read in l2cap_unregister_user
2024/12/26 15:23 linux-5.15.y 91786f140358 d3ccff63 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan-arm64 KASAN: use-after-free Read in l2cap_unregister_user
2024/12/16 00:42 linux-5.15.y 963e654022cc 7cbfbb3a .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan-arm64 KASAN: use-after-free Read in l2cap_unregister_user
2024/12/07 21:10 linux-5.15.y 0a51d2d4527b 9ac0fdc6 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan-arm64 KASAN: use-after-free Read in l2cap_unregister_user
2024/12/06 23:27 linux-5.15.y 0a51d2d4527b 9ac0fdc6 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan-arm64 KASAN: use-after-free Read in l2cap_unregister_user
2024/12/04 14:29 linux-5.15.y 0a51d2d4527b b50eb251 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan-arm64 KASAN: use-after-free Read in l2cap_unregister_user
2024/12/04 01:36 linux-5.15.y 0a51d2d4527b b50eb251 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan-arm64 KASAN: use-after-free Read in l2cap_unregister_user
2024/12/04 01:35 linux-5.15.y 0a51d2d4527b b50eb251 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan-arm64 KASAN: use-after-free Read in l2cap_unregister_user
2024/12/02 22:42 linux-5.15.y 0a51d2d4527b b499ea68 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan-arm64 KASAN: use-after-free Read in l2cap_unregister_user
* Struck through repros no longer work on HEAD.