KASAN: slab-out-of-bounds Read in hci_inquiry_result_with_rssi_evt

5 views
Skip to first unread message

syzbot

unread,
Jul 9, 2020, 6:47:22 PM7/9/20
to syzkaller...@googlegroups.com
Hello,

syzbot found the following crash on:

HEAD commit: dce0f886 Linux 4.19.132
git tree: linux-4.19.y
console output: https://syzkaller.appspot.com/x/log.txt?x=135eea2b100000
kernel config: https://syzkaller.appspot.com/x/.config?x=630ac1b7a61d1805
dashboard link: https://syzkaller.appspot.com/bug?extid=eb6786fbb0464c8ed9c8
compiler: gcc (GCC) 10.1.0-syz 20200507
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=12044d8f100000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=16ab122b100000

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

audit: type=1400 audit(1594334700.584:8): avc: denied { execmem } for pid=6430 comm="syz-executor418" scontext=system_u:system_r:kernel_t:s0 tcontext=system_u:system_r:kernel_t:s0 tclass=process permissive=1
==================================================================
BUG: KASAN: slab-out-of-bounds in memcpy include/linux/string.h:373 [inline]
BUG: KASAN: slab-out-of-bounds in bacpy include/net/bluetooth/bluetooth.h:236 [inline]
BUG: KASAN: slab-out-of-bounds in hci_inquiry_result_with_rssi_evt+0x225/0x6b0 net/bluetooth/hci_event.c:3951
Read of size 6 at addr ffff8880a9e6973b by task kworker/u5:0/1216

CPU: 1 PID: 1216 Comm: kworker/u5:0 Not tainted 4.19.132-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
Workqueue: hci0 hci_rx_work
Call Trace:
__dump_stack lib/dump_stack.c:77 [inline]
dump_stack+0x1fc/0x2fe lib/dump_stack.c:118
print_address_description.cold+0x54/0x219 mm/kasan/report.c:256
kasan_report_error.cold+0x8a/0x1c7 mm/kasan/report.c:354
kasan_report+0x8f/0x96 mm/kasan/report.c:412
memcpy+0x20/0x50 mm/kasan/kasan.c:302
memcpy include/linux/string.h:373 [inline]
bacpy include/net/bluetooth/bluetooth.h:236 [inline]
hci_inquiry_result_with_rssi_evt+0x225/0x6b0 net/bluetooth/hci_event.c:3951
hci_event_packet+0x18a3/0x858f net/bluetooth/hci_event.c:5833
hci_rx_work+0x46b/0xa90 net/bluetooth/hci_core.c:4359
process_one_work+0x864/0x1570 kernel/workqueue.c:2155
worker_thread+0x64c/0x1130 kernel/workqueue.c:2298
kthread+0x30b/0x410 kernel/kthread.c:246
ret_from_fork+0x24/0x30 arch/x86/entry/entry_64.S:415

Allocated by task 6443:
__do_kmalloc_node mm/slab.c:3689 [inline]
__kmalloc_node_track_caller+0x4c/0x70 mm/slab.c:3703
__kmalloc_reserve net/core/skbuff.c:137 [inline]
__alloc_skb+0xae/0x560 net/core/skbuff.c:205
alloc_skb include/linux/skbuff.h:995 [inline]
bt_skb_alloc include/net/bluetooth/bluetooth.h:339 [inline]
vhci_get_user drivers/bluetooth/hci_vhci.c:180 [inline]
vhci_write+0xbd/0x450 drivers/bluetooth/hci_vhci.c:299
call_write_iter include/linux/fs.h:1821 [inline]
new_sync_write fs/read_write.c:474 [inline]
__vfs_write+0x51b/0x770 fs/read_write.c:487
vfs_write+0x1f3/0x540 fs/read_write.c:549
ksys_write+0x12b/0x2a0 fs/read_write.c:599
do_syscall_64+0xf9/0x620 arch/x86/entry/common.c:293
entry_SYSCALL_64_after_hwframe+0x49/0xbe

Freed by task 4594:
__cache_free mm/slab.c:3503 [inline]
kfree+0xcc/0x210 mm/slab.c:3822
kernfs_fop_release+0x120/0x190 fs/kernfs/file.c:783
__fput+0x2ce/0x890 fs/file_table.c:278
task_work_run+0x148/0x1c0 kernel/task_work.c:113
tracehook_notify_resume include/linux/tracehook.h:193 [inline]
exit_to_usermode_loop+0x251/0x2a0 arch/x86/entry/common.c:167
prepare_exit_to_usermode arch/x86/entry/common.c:198 [inline]
syscall_return_slowpath arch/x86/entry/common.c:271 [inline]
do_syscall_64+0x538/0x620 arch/x86/entry/common.c:296
entry_SYSCALL_64_after_hwframe+0x49/0xbe

The buggy address belongs to the object at ffff8880a9e69540
which belongs to the cache kmalloc-512 of size 512
The buggy address is located 507 bytes inside of
512-byte region [ffff8880a9e69540, ffff8880a9e69740)
The buggy address belongs to the page:
page:ffffea0002a79a40 count:1 mapcount:0 mapping:ffff88812c39c940 index:0x0
flags: 0xfffe0000000100(slab)
raw: 00fffe0000000100 ffffea0002a50188 ffffea0002373608 ffff88812c39c940
raw: 0000000000000000 ffff8880a9e69040 0000000100000006 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
ffff8880a9e69600: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
ffff8880a9e69680: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
>ffff8880a9e69700: 00 00 00 00 00 00 00 00 fc fc fc fc fc fc fc fc
^
ffff8880a9e69780: fc fc fc fc fc fc fc fc 00 00 00 00 00 00 00 00
ffff8880a9e69800: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
==================================================================


---
This bug 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 bug report. See:
https://goo.gl/tpsmEJ#status for how to communicate with syzbot.
syzbot can test patches for this bug, for details see:
https://goo.gl/tpsmEJ#testing-patches

syzbot

unread,
Sep 7, 2020, 11:11:05 AM9/7/20
to syzkaller...@googlegroups.com
syzbot suspects this issue was fixed by commit:

commit 48f70ecd6a22f5cf2a6d2670fbc3523fe64bcae8
Author: Peilin Ye <yepei...@gmail.com>
Date: Fri Jul 10 21:45:26 2020 +0000

Bluetooth: Prevent out-of-bounds read in hci_inquiry_result_with_rssi_evt()

bisection log: https://syzkaller.appspot.com/x/bisect.txt?x=15002a9e900000
start commit: 205a42ce Linux 4.19.135
git tree: linux-4.19.y
kernel config: https://syzkaller.appspot.com/x/.config?x=155b0b328eb5e700
dashboard link: https://syzkaller.appspot.com/bug?extid=eb6786fbb0464c8ed9c8
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=14b11ff4900000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=1700f468900000

If the result looks correct, please mark the issue as fixed by replying with:

#syz fix: Bluetooth: Prevent out-of-bounds read in hci_inquiry_result_with_rssi_evt()

For information about bisection process see: https://goo.gl/tpsmEJ#bisection
Reply all
Reply to author
Forward
0 new messages