[v6.1] KASAN: use-after-free Read in __hci_req_sync

0 views
Skip to first unread message

syzbot

unread,
Apr 18, 2024, 12:31:23 PMApr 18
to syzkaller...@googlegroups.com
Hello,

syzbot found the following issue on:

HEAD commit: 6741e066ec76 Linux 6.1.87
git tree: linux-6.1.y
console output: https://syzkaller.appspot.com/x/log.txt?x=1668926f180000
kernel config: https://syzkaller.appspot.com/x/.config?x=3fc2f61bd0ae457
dashboard link: https://syzkaller.appspot.com/bug?extid=c82a4318e25512a36791
compiler: Debian clang version 15.0.6, GNU ld (GNU Binutils for Debian) 2.40
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=11e46653180000

Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/665ba05da528/disk-6741e066.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/2ec8afc9ea0a/vmlinux-6741e066.xz
kernel image: https://storage.googleapis.com/syzbot-assets/b0dbfd69f35b/bzImage-6741e066.xz

IMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by: syzbot+c82a43...@syzkaller.appspotmail.com

==================================================================
BUG: KASAN: use-after-free in instrument_atomic_read include/linux/instrumented.h:72 [inline]
BUG: KASAN: use-after-free in atomic_read include/linux/atomic/atomic-instrumented.h:27 [inline]
BUG: KASAN: use-after-free in refcount_read include/linux/refcount.h:147 [inline]
BUG: KASAN: use-after-free in skb_unref include/linux/skbuff.h:1203 [inline]
BUG: KASAN: use-after-free in kfree_skb_reason+0x3d/0x390 net/core/skbuff.c:887
Read of size 4 at addr ffff888018fb04a4 by task syz-executor.3/3609

CPU: 1 PID: 3609 Comm: syz-executor.3 Not tainted 6.1.87-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 03/27/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
kasan_check_range+0x27f/0x290 mm/kasan/generic.c:189
instrument_atomic_read include/linux/instrumented.h:72 [inline]
atomic_read include/linux/atomic/atomic-instrumented.h:27 [inline]
refcount_read include/linux/refcount.h:147 [inline]
skb_unref include/linux/skbuff.h:1203 [inline]
kfree_skb_reason+0x3d/0x390 net/core/skbuff.c:887
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_dev_cmd+0x2fc/0xa30 net/bluetooth/hci_core.c:790
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
RIP: 0033:0x7fbc67a7dc0b
Code: 00 48 89 44 24 18 31 c0 48 8d 44 24 60 c7 04 24 10 00 00 00 48 89 44 24 08 48 8d 44 24 20 48 89 44 24 10 b8 10 00 00 00 0f 05 <89> c2 3d 00 f0 ff ff 77 1c 48 8b 44 24 18 64 48 2b 04 25 28 00 00
RSP: 002b:00007ffe3e4c3f50 EFLAGS: 00000246 ORIG_RAX: 0000000000000010
RAX: ffffffffffffffda RBX: 0000000000000003 RCX: 00007fbc67a7dc0b
RDX: 00007ffe3e4c3fc8 RSI: 00000000400448dd RDI: 0000000000000003
RBP: 0000555555ea1430 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000008 R11: 0000000000000246 R12: 0000000000000002
R13: 0000000000000002 R14: 0000000000000001 R15: 00000000fffffff1
</TASK>

Allocated by task 3610:
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:4179 [inline]
hci_cmd_work+0x296/0x660 net/bluetooth/hci_core.c:4199
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:308

Freed by task 3616:
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_complete+0xee/0x280 net/bluetooth/hci_request.c:109
hci_event_packet+0xc49/0x1510 net/bluetooth/hci_event.c:7601
hci_rx_work+0x3cd/0xce0 net/bluetooth/hci_core.c:4130
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:308

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

The buggy address belongs to the physical page:
page:ffffea000063ec00 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x18fb0
flags: 0xfff80000000200(slab|node=0|zone=1|lastcpupid=0xfff)
raw: 00fff80000000200 0000000000000000 dead000000000122 ffff888014656500
raw: 0000000000000000 00000000800c000c 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 3610, tgid 3610 (kworker/u5:3), ts 522197843856, free_ts 231318491887
set_page_owner include/linux/page_owner.h:31 [inline]
post_alloc_hook+0x18d/0x1b0 mm/page_alloc.c:2513
prep_new_page mm/page_alloc.c:2520 [inline]
get_page_from_freelist+0x31a1/0x3320 mm/page_alloc.c:4279
__alloc_pages+0x28d/0x770 mm/page_alloc.c:5547
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]
mgmt_alloc_skb net/bluetooth/mgmt_util.c:64 [inline]
mgmt_send_event+0x42/0x1a0 net/bluetooth/mgmt_util.c:116
mgmt_index_event net/bluetooth/mgmt.c:326 [inline]
mgmt_index_added+0x260/0x370 net/bluetooth/mgmt.c:9403
hci_power_on+0x488/0x6f0
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:308
page last free stack trace:
reset_page_owner include/linux/page_owner.h:24 [inline]
free_pages_prepare mm/page_alloc.c:1440 [inline]
free_pcp_prepare mm/page_alloc.c:1490 [inline]
free_unref_page_prepare+0xf63/0x1120 mm/page_alloc.c:3358
free_unref_page_list+0x663/0x900 mm/page_alloc.c:3499
release_pages+0x2836/0x2b40 mm/swap.c:1055
tlb_batch_pages_flush mm/mmu_gather.c:59 [inline]
tlb_flush_mmu_free mm/mmu_gather.c:254 [inline]
tlb_flush_mmu+0xfc/0x210 mm/mmu_gather.c:261
tlb_finish_mmu+0xce/0x1f0 mm/mmu_gather.c:361
exit_mmap+0x3c3/0x9f0 mm/mmap.c:3239
__mmput+0x115/0x3c0 kernel/fork.c:1199
exit_mm+0x226/0x300 kernel/exit.c:563
do_exit+0x9f6/0x26a0 kernel/exit.c:856
do_group_exit+0x202/0x2b0 kernel/exit.c:1019
__do_sys_exit_group kernel/exit.c:1030 [inline]
__se_sys_exit_group kernel/exit.c:1028 [inline]
__x64_sys_exit_group+0x3b/0x40 kernel/exit.c:1028
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:
ffff888018fb0380: fc fc fc fc fc fc fc fc fa fb fb fb fb fb fb fb
ffff888018fb0400: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff888018fb0480: fb fb fb fb fb fb fc fc fc fc fc fc fc fc fc fc
^
ffff888018fb0500: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
ffff888018fb0580: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 fc fc
==================================================================


---
This report is generated by a bot. It may contain errors.
See https://goo.gl/tpsmEJ for more information about syzbot.
syzbot engineers can be reached at syzk...@googlegroups.com.

syzbot will keep track of this issue. See:
https://goo.gl/tpsmEJ#status for how to communicate with syzbot.

If the report is already addressed, let syzbot know by replying with:
#syz fix: exact-commit-title

If you want syzbot to run the reproducer, reply with:
#syz test: git://repo/address.git branch-or-commit-hash
If you attach or paste a git patch, syzbot will apply it before testing.

If you want to overwrite report's subsystems, reply with:
#syz set subsystems: new-subsystem
(See the list of subsystem names on the web dashboard)

If the report is a duplicate of another one, reply with:
#syz dup: exact-subject-of-another-report

If you want to undo deduplication, reply with:
#syz undup
Reply all
Reply to author
Forward
0 new messages