syzbot


KASAN: use-after-free Read in hci_cmd_timeout

Status: upstream: reported on 2024/08/11 13:01
Reported-by: syzbot+4f547073b1dd0afaa65a@syzkaller.appspotmail.com
First crash: 116d, last: 24d
Similar bugs (5)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
linux-4.19 KASAN: use-after-free Read in hci_cmd_timeout syz error 17 675d 1922d 0/1 upstream: reported syz repro on 2019/09/01 02:37
android-5-10 KASAN: use-after-free Read in hci_cmd_timeout 1 646d 646d 0/2 auto-obsoleted due to no activity on 2023/05/29 20:38
linux-4.14 KASAN: use-after-free Read in hci_cmd_timeout C inconclusive 11 1053d 1917d 0/1 upstream: reported C repro on 2019/09/06 20:31
upstream KASAN: use-after-free Read in hci_cmd_timeout C done error 371 727d 2039d 22/28 fixed on 2023/04/12 21:18
upstream KASAN: slab-use-after-free Read in hci_cmd_timeout bluetooth 28 117d 264d 0/28 auto-obsoleted due to no activity on 2024/10/24 09:00

Sample crash report:
==================================================================
BUG: KASAN: use-after-free in hci_cmd_timeout+0x1cf/0x1e0 net/bluetooth/hci_core.c:1456
Read of size 2 at addr ffff88807e515b78 by task kworker/u5:4/4253

CPU: 1 PID: 4253 Comm: kworker/u5:4 Not tainted 6.1.116-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 09/13/2024
Workqueue: hci0 hci_cmd_timeout
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
 hci_cmd_timeout+0x1cf/0x1e0 net/bluetooth/hci_core.c:1456
 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_slab_alloc+0x65/0x70 mm/kasan/common.c:328
 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]
 slab_alloc mm/slub.c:3406 [inline]
 __kmem_cache_alloc_lru mm/slub.c:3413 [inline]
 kmem_cache_alloc+0x10c/0x2d0 mm/slub.c:3422
 skb_clone+0x1e5/0x360 net/core/skbuff.c:1660
 hci_send_cmd_sync net/bluetooth/hci_core.c:4149 [inline]
 hci_cmd_work+0x296/0x660 net/bluetooth/hci_core.c:4169
 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 4403:
 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+0x292/0x510 mm/slub.c:3683
 kfree_skb include/linux/skbuff.h:1220 [inline]
 __hci_req_sync+0x626/0x940 net/bluetooth/hci_request.c:184
 hci_req_sync+0xa5/0xc0 net/bluetooth/hci_request.c:206
 hci_inquiry+0x443/0x860 net/bluetooth/hci_core.c:381
 sock_do_ioctl+0x152/0x450 net/socket.c:1204
 sock_ioctl+0x47f/0x770 net/socket.c:1321
 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

The buggy address belongs to the object at ffff88807e515b40
 which belongs to the cache skbuff_head_cache of size 240
The buggy address is located 56 bytes inside of
 240-byte region [ffff88807e515b40, ffff88807e515c30)

The buggy address belongs to the physical page:
page:ffffea0001f94540 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x7e515
flags: 0xfff00000000200(slab|node=0|zone=1|lastcpupid=0x7ff)
raw: 00fff00000000200 ffffea00009a8040 dead000000000002 ffff888019243000
raw: 0000000000000000 00000000000c000c 00000001ffffffff 0000000000000000
page dumped because: kasan: bad access detected
page_owner tracks the page as allocated
page last allocated via order 0, migratetype Unmovable, gfp_mask 0x12cc0(GFP_KERNEL|__GFP_NOWARN|__GFP_NORETRY), pid 3625, tgid 3625 (udevd), ts 17188445130, free_ts 17161977769
 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+0x1cf/0x310 mm/slub.c:3443
 __alloc_skb+0xde/0x670 net/core/skbuff.c:505
 alloc_skb include/linux/skbuff.h:1271 [inline]
 alloc_skb_with_frags+0xa4/0x740 net/core/skbuff.c:6162
 sock_alloc_send_pskb+0x915/0xa50 net/core/sock.c:2747
 unix_dgram_sendmsg+0x5b1/0x2050 net/unix/af_unix.c:1918
 sock_sendmsg_nosec net/socket.c:718 [inline]
 __sock_sendmsg net/socket.c:730 [inline]
 sock_write_iter+0x394/0x4e0 net/socket.c:1143
 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
 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_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]
 slab_alloc mm/slub.c:3406 [inline]
 __kmem_cache_alloc_lru mm/slub.c:3413 [inline]
 kmem_cache_alloc+0x10c/0x2d0 mm/slub.c:3422
 getname_flags+0xb8/0x4f0 fs/namei.c:139
 do_sys_openat2+0xd2/0x4f0 fs/open.c:1312
 do_sys_open fs/open.c:1334 [inline]
 __do_sys_openat fs/open.c:1350 [inline]
 __se_sys_openat fs/open.c:1345 [inline]
 __x64_sys_openat+0x243/0x290 fs/open.c:1345
 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:
 ffff88807e515a00: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff88807e515a80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fc fc
>ffff88807e515b00: fc fc fc fc fc fc fc fc fa fb fb fb fb fb fb fb
                                                                ^
 ffff88807e515b80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff88807e515c00: fb fb fb fb fb fb fc fc fc fc fc fc fc fc fc fc
==================================================================

Crashes (4):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2024/11/11 13:56 linux-6.1.y d7039b844a1c 0c4b1325 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan KASAN: use-after-free Read in hci_cmd_timeout
2024/10/22 17:35 linux-6.1.y 7ec6f9fa3d97 a93682b3 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan KASAN: use-after-free Read in hci_cmd_timeout
2024/09/28 06:52 linux-6.1.y e526b12bf916 440b26ec .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan KASAN: use-after-free Read in hci_cmd_timeout
2024/08/11 13:01 linux-6.1.y 36790ef5e00b 6f4edef4 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan KASAN: use-after-free Read in hci_cmd_timeout
* Struck through repros no longer work on HEAD.