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: 34d, last: 34d
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 593d 1840d 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 564d 564d 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 971d 1835d 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 645d 1957d 22/28 fixed on 2023/04/12 21:18
upstream KASAN: slab-use-after-free Read in hci_cmd_timeout bluetooth 28 35d 182d 0/28 upstream: reported on 2024/03/16 12:17

Sample crash report:
Bluetooth: hci4: unexpected event 0x2f length: 509 > 260
Bluetooth: hci3: command tx timeout
==================================================================
BUG: KASAN: use-after-free in hci_cmd_timeout+0x1cf/0x1e0 net/bluetooth/hci_core.c:1459
Read of size 2 at addr ffff8880761442b8 by task kworker/u5:5/3647

CPU: 1 PID: 3647 Comm: kworker/u5:5 Not tainted 6.1.104-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 06/27/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:1459
 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 3647:
 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:4146 [inline]
 hci_cmd_work+0x296/0x660 net/bluetooth/hci_core.c:4166
 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

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

The buggy address belongs to the physical page:
page:ffffea0001d85100 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x76144
flags: 0xfff00000000200(slab|node=0|zone=1|lastcpupid=0x7ff)
raw: 00fff00000000200 ffffea0001d21c00 dead000000000003 ffff888142649000
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 0x132a20(GFP_ATOMIC|__GFP_NOWARN|__GFP_NORETRY|__GFP_MEMALLOC|__GFP_HARDWALL), pid 21, tgid 21 (ksoftirqd/1), ts 136266564817, free_ts 136235071572
 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+0x322e/0x33b0 mm/page_alloc.c:4290
 __alloc_pages+0x28d/0x770 mm/page_alloc.c:5558
 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
 __netdev_alloc_skb+0xfb/0x500 net/core/skbuff.c:579
 netdev_alloc_skb include/linux/skbuff.h:3206 [inline]
 dev_alloc_skb include/linux/skbuff.h:3219 [inline]
 __ieee80211_beacon_get+0xc7d/0x2110 net/mac80211/tx.c:5258
 ieee80211_beacon_get_tim+0xb1/0x5d0 net/mac80211/tx.c:5340
 ieee80211_beacon_get include/net/mac80211.h:5248 [inline]
 mac80211_hwsim_beacon_tx+0x1d2/0xaa0 drivers/net/wireless/mac80211_hwsim.c:2086
 __iterate_interfaces+0x21e/0x4b0 net/mac80211/util.c:788
 ieee80211_iterate_active_interfaces_atomic+0xd4/0x170 net/mac80211/util.c:824
 mac80211_hwsim_beacon+0xd0/0x1e0 drivers/net/wireless/mac80211_hwsim.c:2142
 __run_hrtimer kernel/time/hrtimer.c:1686 [inline]
 __hrtimer_run_queues+0x5e5/0xe50 kernel/time/hrtimer.c:1750
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
 __vunmap+0x834/0x9a0 mm/vmalloc.c:2717
 bpf_prog_calc_tag+0x65f/0x8f0 kernel/bpf/core.c:343
 resolve_pseudo_ldimm64+0xe0/0x1240 kernel/bpf/verifier.c:13113
 bpf_check+0x5600/0x15e30 kernel/bpf/verifier.c:15647
 bpf_prog_load+0x12df/0x1bb0 kernel/bpf/syscall.c:2646
 __sys_bpf+0x382/0x6c0 kernel/bpf/syscall.c:5020
 __do_sys_bpf kernel/bpf/syscall.c:5124 [inline]
 __se_sys_bpf kernel/bpf/syscall.c:5122 [inline]
 __x64_sys_bpf+0x78/0x90 kernel/bpf/syscall.c:5122
 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:
 ffff888076144180: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff888076144200: fb fb fb fb fb fb fc fc fc fc fc fc fc fc fc fc
>ffff888076144280: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                                        ^
 ffff888076144300: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fc fc
 ffff888076144380: fc fc fc fc fc fc fc fc fa fb fb fb fb fb fb fb
==================================================================

Crashes (1):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
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.