syzbot


KASAN: slab-use-after-free Read in hci_req_sync_complete

Status: upstream: reported on 2024/06/07 22:46
Subsystems: bluetooth
[Documentation on labels]
Reported-by: syzbot+275d418cae2e1a853717@syzkaller.appspotmail.com
First crash: 49d, last: 4d23h
Discussions (1)
Title Replies (including bot) Last reply
[syzbot] [bluetooth?] KASAN: slab-use-after-free Read in hci_req_sync_complete 0 (1) 2024/06/07 22:46
Similar bugs (1)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
linux-6.1 KASAN: use-after-free Read in hci_req_sync_complete 1 2d04h 2d04h 0/3 upstream: reported on 2024/06/16 08:56

Sample crash report:
==================================================================
BUG: KASAN: slab-use-after-free in kfree_skbmem+0x18e/0x1b0 net/core/skbuff.c:1129
Read of size 1 at addr ffff88805b64cbbe by task kworker/u9:5/5129

CPU: 1 PID: 5129 Comm: kworker/u9:5 Not tainted 6.10.0-rc3-syzkaller-00044-g2ccbdf43d5e7 #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 06/07/2024
Workqueue: hci3 hci_rx_work
Call Trace:
 <TASK>
 __dump_stack lib/dump_stack.c:88 [inline]
 dump_stack_lvl+0x241/0x360 lib/dump_stack.c:114
 print_address_description mm/kasan/report.c:377 [inline]
 print_report+0x169/0x550 mm/kasan/report.c:488
 kasan_report+0x143/0x180 mm/kasan/report.c:601
 kfree_skbmem+0x18e/0x1b0 net/core/skbuff.c:1129
 kfree_skb include/linux/skbuff.h:1257 [inline]
 hci_req_sync_complete+0xe7/0x290 net/bluetooth/hci_request.c:109
 hci_event_packet+0xc73/0x1540 net/bluetooth/hci_event.c:7479
 hci_rx_work+0x3e8/0xca0 net/bluetooth/hci_core.c:4074
 process_one_work kernel/workqueue.c:3231 [inline]
 process_scheduled_works+0xa2e/0x1830 kernel/workqueue.c:3312
 worker_thread+0x86d/0xd70 kernel/workqueue.c:3393
 kthread+0x2f2/0x390 kernel/kthread.c:389
 ret_from_fork+0x4d/0x80 arch/x86/kernel/process.c:147
 ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:244
 </TASK>

Allocated by task 5129:
 kasan_save_stack mm/kasan/common.c:47 [inline]
 kasan_save_track+0x3f/0x80 mm/kasan/common.c:68
 unpoison_slab_object mm/kasan/common.c:312 [inline]
 __kasan_slab_alloc+0x66/0x80 mm/kasan/common.c:338
 kasan_slab_alloc include/linux/kasan.h:201 [inline]
 slab_post_alloc_hook mm/slub.c:3941 [inline]
 slab_alloc_node mm/slub.c:4001 [inline]
 kmem_cache_alloc_noprof+0x135/0x2a0 mm/slub.c:4008
 skb_clone+0x20c/0x390 net/core/skbuff.c:2052
 hci_send_cmd_sync net/bluetooth/hci_core.c:4123 [inline]
 hci_cmd_work+0x29e/0x670 net/bluetooth/hci_core.c:4143
 process_one_work kernel/workqueue.c:3231 [inline]
 process_scheduled_works+0xa2e/0x1830 kernel/workqueue.c:3312
 worker_thread+0x86d/0xd70 kernel/workqueue.c:3393
 kthread+0x2f2/0x390 kernel/kthread.c:389
 ret_from_fork+0x4d/0x80 arch/x86/kernel/process.c:147
 ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:244

Freed by task 7944:
 kasan_save_stack mm/kasan/common.c:47 [inline]
 kasan_save_track+0x3f/0x80 mm/kasan/common.c:68
 kasan_save_free_info+0x40/0x50 mm/kasan/generic.c:579
 poison_slab_object+0xe0/0x150 mm/kasan/common.c:240
 __kasan_slab_free+0x37/0x60 mm/kasan/common.c:256
 kasan_slab_free include/linux/kasan.h:184 [inline]
 slab_free_hook mm/slub.c:2196 [inline]
 slab_free mm/slub.c:4437 [inline]
 kmem_cache_free+0x145/0x350 mm/slub.c:4512
 kfree_skb include/linux/skbuff.h:1257 [inline]
 __hci_req_sync+0x62f/0x950 net/bluetooth/hci_request.c:184
 hci_req_sync+0xa9/0xd0 net/bluetooth/hci_request.c:206
 hci_dev_cmd+0x4c5/0xa50 net/bluetooth/hci_core.c:787
 sock_do_ioctl+0x15a/0x460 net/socket.c:1222
 sock_ioctl+0x629/0x8e0 net/socket.c:1341
 vfs_ioctl fs/ioctl.c:51 [inline]
 __do_sys_ioctl fs/ioctl.c:907 [inline]
 __se_sys_ioctl+0xfe/0x170 fs/ioctl.c:893
 do_syscall_x64 arch/x86/entry/common.c:52 [inline]
 do_syscall_64+0xf3/0x230 arch/x86/entry/common.c:83
 entry_SYSCALL_64_after_hwframe+0x77/0x7f

The buggy address belongs to the object at ffff88805b64cb40
 which belongs to the cache skbuff_head_cache of size 240
The buggy address is located 126 bytes inside of
 freed 240-byte region [ffff88805b64cb40, ffff88805b64cc30)

The buggy address belongs to the physical page:
page: refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x5b64c
anon flags: 0xfff00000000000(node=0|zone=1|lastcpupid=0x7ff)
page_type: 0xffffefff(slab)
raw: 00fff00000000000 ffff888018adb780 ffffea0000b6fa40 dead000000000005
raw: 0000000000000000 00000000000c000c 00000001ffffefff 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 0x152820(GFP_ATOMIC|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_HARDWALL), pid 5182, tgid 5182 (kworker/0:7), ts 231489126161, free_ts 230391703657
 set_page_owner include/linux/page_owner.h:32 [inline]
 post_alloc_hook+0x1f3/0x230 mm/page_alloc.c:1468
 prep_new_page mm/page_alloc.c:1476 [inline]
 get_page_from_freelist+0x2e43/0x2f00 mm/page_alloc.c:3420
 __alloc_pages_noprof+0x256/0x6c0 mm/page_alloc.c:4678
 __alloc_pages_node_noprof include/linux/gfp.h:269 [inline]
 alloc_pages_node_noprof include/linux/gfp.h:296 [inline]
 alloc_slab_page+0x5f/0x120 mm/slub.c:2265
 allocate_slab+0x5a/0x2f0 mm/slub.c:2428
 new_slab mm/slub.c:2481 [inline]
 ___slab_alloc+0xcd1/0x14b0 mm/slub.c:3667
 __slab_alloc+0x58/0xa0 mm/slub.c:3757
 __slab_alloc_node mm/slub.c:3810 [inline]
 slab_alloc_node mm/slub.c:3989 [inline]
 kmem_cache_alloc_node_noprof+0x1fe/0x320 mm/slub.c:4044
 __alloc_skb+0x1c3/0x440 net/core/skbuff.c:656
 alloc_skb include/linux/skbuff.h:1308 [inline]
 nsim_dev_trap_skb_build drivers/net/netdevsim/dev.c:748 [inline]
 nsim_dev_trap_report drivers/net/netdevsim/dev.c:805 [inline]
 nsim_dev_trap_report_work+0x254/0xaa0 drivers/net/netdevsim/dev.c:850
 process_one_work kernel/workqueue.c:3231 [inline]
 process_scheduled_works+0xa2e/0x1830 kernel/workqueue.c:3312
 worker_thread+0x86d/0xd70 kernel/workqueue.c:3393
 kthread+0x2f2/0x390 kernel/kthread.c:389
 ret_from_fork+0x4d/0x80 arch/x86/kernel/process.c:147
 ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:244
page last free pid 7402 tgid 7401 stack trace:
 reset_page_owner include/linux/page_owner.h:25 [inline]
 free_pages_prepare mm/page_alloc.c:1088 [inline]
 __free_pages_ok+0xb4e/0xcc0 mm/page_alloc.c:1208
 __folio_put+0x3b9/0x620 mm/swap.c:129
 folio_put include/linux/mm.h:1508 [inline]
 free_large_kmalloc+0x105/0x1c0 mm/slub.c:4529
 kfree+0x1c4/0x360 mm/slub.c:4552
 skb_kfree_head net/core/skbuff.c:1069 [inline]
 skb_free_head net/core/skbuff.c:1081 [inline]
 skb_release_data+0x676/0x880 net/core/skbuff.c:1108
 skb_release_all net/core/skbuff.c:1173 [inline]
 __kfree_skb net/core/skbuff.c:1187 [inline]
 kfree_skb_reason+0x1a3/0x3b0 net/core/skbuff.c:1223
 sctp_queue_purge_ulpevents+0xa3/0x130 net/sctp/ulpevent.c:1186
 sctp_close+0x153/0x920 net/sctp/socket.c:1500
 inet_release+0x17f/0x200 net/ipv4/af_inet.c:437
 __sock_release net/socket.c:659 [inline]
 sock_close+0xbe/0x240 net/socket.c:1421
 __fput+0x408/0x8b0 fs/file_table.c:422
 task_work_run+0x251/0x310 kernel/task_work.c:180
 get_signal+0x15e6/0x1740 kernel/signal.c:2681
 arch_do_signal_or_restart+0x96/0x860 arch/x86/kernel/signal.c:310
 exit_to_user_mode_loop kernel/entry/common.c:111 [inline]
 exit_to_user_mode_prepare include/linux/entry-common.h:328 [inline]
 __syscall_exit_to_user_mode_work kernel/entry/common.c:207 [inline]
 syscall_exit_to_user_mode+0xc9/0x370 kernel/entry/common.c:218
 do_syscall_64+0x100/0x230 arch/x86/entry/common.c:89

Memory state around the buggy address:
 ffff88805b64ca80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 fc fc
 ffff88805b64cb00: fc fc fc fc fc fc fc fc fa fb fb fb fb fb fb fb
>ffff88805b64cb80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                                        ^
 ffff88805b64cc00: fb fb fb fb fb fb fc fc fc fc fc fc fc fc fc fc
 ffff88805b64cc80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
==================================================================

Crashes (7):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2024/06/13 13:15 upstream 2ccbdf43d5e7 2aa5052f .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-kasan-gce-root KASAN: slab-use-after-free Read in hci_req_sync_complete
2024/06/05 01:36 upstream 32f88d65f01b e1e2c66e .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-fs KASAN: slab-use-after-free Read in hci_req_sync_complete
2024/04/29 23:53 upstream b947cc5bf6d7 27e33c58 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-kasan-gce-selinux-root KASAN: slab-use-after-free Read in hci_req_sync_complete
2024/06/11 20:59 net-next bb678f01804c 4d75f4f7 .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-net-next-test-gce KASAN: slab-use-after-free Read in hci_req_sync_complete
2024/06/07 22:45 net-next a99997323654 82c05ab8 .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-net-next-test-gce KASAN: slab-use-after-free Read in hci_req_sync_complete
2024/05/15 21:55 net-next 654de42f3fc6 94b087b1 .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-net-next-test-gce KASAN: slab-use-after-free Read in hci_req_sync_complete
2024/05/08 08:46 net-next 0d5044b4e774 4cf3f9b3 .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-net-next-test-gce KASAN: slab-use-after-free Read in hci_req_sync_complete
* Struck through repros no longer work on HEAD.