KASAN: use-after-free Write in sco_chan_del

8 views
Skip to first unread message

syzbot

unread,
Aug 2, 2020, 8:43:24 PM8/2/20
to syzkaller...@googlegroups.com
Hello,

syzbot found the following issue on:

HEAD commit: 13af6c74 Linux 4.19.136
git tree: linux-4.19.y
console output: https://syzkaller.appspot.com/x/log.txt?x=1731f8ec900000
kernel config: https://syzkaller.appspot.com/x/.config?x=5b7578d3b5457a49
dashboard link: https://syzkaller.appspot.com/bug?extid=4de628651a6b3eee15ed
compiler: gcc (GCC) 10.1.0-syz 20200507
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=1531cb98900000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=131834fc900000

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

==================================================================
BUG: KASAN: use-after-free in atomic_dec_and_test include/asm-generic/atomic-instrumented.h:259 [inline]
BUG: KASAN: use-after-free in hci_conn_drop include/net/bluetooth/hci_core.h:972 [inline]
BUG: KASAN: use-after-free in sco_chan_del+0xe6/0x420 net/bluetooth/sco.c:148
Write of size 4 at addr ffff8880844e6e50 by task syz-executor681/6643

CPU: 0 PID: 6643 Comm: syz-executor681 Not tainted 4.19.136-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
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
atomic_dec_and_test include/asm-generic/atomic-instrumented.h:259 [inline]
hci_conn_drop include/net/bluetooth/hci_core.h:972 [inline]
sco_chan_del+0xe6/0x420 net/bluetooth/sco.c:148
__sco_sock_close+0xc3/0x720 net/bluetooth/sco.c:433
sco_sock_close net/bluetooth/sco.c:447 [inline]
sco_sock_release+0x6b/0x3d0 net/bluetooth/sco.c:1008
__sock_release+0xcd/0x2a0 net/socket.c:579
sock_close+0x15/0x20 net/socket.c:1140
__fput+0x2ce/0x890 fs/file_table.c:278
task_work_run+0x148/0x1c0 kernel/task_work.c:113
exit_task_work include/linux/task_work.h:22 [inline]
do_exit+0xbb2/0x2b70 kernel/exit.c:887
do_group_exit+0x125/0x310 kernel/exit.c:990
get_signal+0x3f2/0x1f70 kernel/signal.c:2588
do_signal+0x8f/0x1670 arch/x86/kernel/signal.c:821
exit_to_usermode_loop+0x204/0x2a0 arch/x86/entry/common.c:163
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
RIP: 0033:0x446e69
Code: Bad RIP value.
RSP: 002b:00007ffc797512f8 EFLAGS: 00000246 ORIG_RAX: 000000000000002a
RAX: fffffffffffffffc RBX: 0000000000000000 RCX: 0000000000446e69
RDX: 0000000000000008 RSI: 0000000020000000 RDI: 0000000000000004
RBP: 0000000000000004 R08: 0000000000000002 R09: 00000003000200ff
R10: 0000000000000004 R11: 0000000000000246 R12: 0000000000000000
R13: 0000000000407ac0 R14: 0000000000000000 R15: 0000000000000000

Allocated by task 6643:
kmem_cache_alloc_trace+0x12f/0x380 mm/slab.c:3625
kmalloc include/linux/slab.h:515 [inline]
kzalloc include/linux/slab.h:709 [inline]
hci_conn_add+0x53/0x11e0 net/bluetooth/hci_conn.c:501
hci_connect_sco+0x2fc/0x950 net/bluetooth/hci_conn.c:1238
sco_connect net/bluetooth/sco.c:240 [inline]
sco_sock_connect+0x2ff/0x970 net/bluetooth/sco.c:576
__sys_connect+0x265/0x2c0 net/socket.c:1663
__do_sys_connect net/socket.c:1674 [inline]
__se_sys_connect net/socket.c:1671 [inline]
__x64_sys_connect+0x6f/0xb0 net/socket.c:1671
do_syscall_64+0xf9/0x620 arch/x86/entry/common.c:293
entry_SYSCALL_64_after_hwframe+0x49/0xbe

Freed by task 6630:
__cache_free mm/slab.c:3503 [inline]
kfree+0xcc/0x210 mm/slab.c:3822
device_release+0x76/0x210 drivers/base/core.c:1061
kobject_cleanup lib/kobject.c:662 [inline]
kobject_release lib/kobject.c:691 [inline]
kref_put include/linux/kref.h:70 [inline]
kobject_put+0x22d/0x350 lib/kobject.c:708
put_device+0x1c/0x30 drivers/base/core.c:2251
hci_conn_del+0x27e/0x6a0 net/bluetooth/hci_conn.c:611
hci_phy_link_complete_evt.isra.0+0x5a4/0x7a0 net/bluetooth/hci_event.c:4677
hci_event_packet+0x1973/0x858f net/bluetooth/hci_event.c:5898
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

The buggy address belongs to the object at ffff8880844e6e40
which belongs to the cache kmalloc-4096 of size 4096
The buggy address is located 16 bytes inside of
4096-byte region [ffff8880844e6e40, ffff8880844e7e40)
The buggy address belongs to the page:
page:ffffea0002113980 count:1 mapcount:0 mapping:ffff88812c39cdc0 index:0x0 compound_mapcount: 0
flags: 0xfffe0000008100(slab|head)
raw: 00fffe0000008100 ffffea0002113488 ffffea0002113a08 ffff88812c39cdc0
raw: 0000000000000000 ffff8880844e6e40 0000000100000001 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
ffff8880844e6d00: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
ffff8880844e6d80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
>ffff8880844e6e00: fc fc fc fc fc fc fc fc fb fb fb fb fb fb fb fb
^
ffff8880844e6e80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff8880844e6f00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================


---
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.
syzbot can test patches for this issue, for details see:
https://goo.gl/tpsmEJ#testing-patches

syzbot

unread,
Jan 3, 2021, 10:25:05 PM1/3/21
to syzkaller...@googlegroups.com
syzbot suspects this issue was fixed by commit:

commit abae100355c011d14c75cabbf9eb773c231187ee
Author: Anmol Karn <anmol.k...@gmail.com>
Date: Wed Sep 30 14:18:13 2020 +0000

Bluetooth: Fix null pointer dereference in hci_event_packet()

bisection log: https://syzkaller.appspot.com/x/bisect.txt?x=154a752f500000
start commit: c076c79e Linux 4.19.137
git tree: linux-4.19.y
kernel config: https://syzkaller.appspot.com/x/.config?x=b8bacc01843402f4
dashboard link: https://syzkaller.appspot.com/bug?extid=4de628651a6b3eee15ed
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=12741ec6900000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=12636efa900000

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

#syz fix: Bluetooth: Fix null pointer dereference in hci_event_packet()

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