KASAN: use-after-free Read in hci_chan_del

25 views
Skip to first unread message

syzbot

unread,
Aug 2, 2020, 10:40:17 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=17cc1114900000
kernel config: https://syzkaller.appspot.com/x/.config?x=5b7578d3b5457a49
dashboard link: https://syzkaller.appspot.com/bug?extid=2bb1968c6e2f8782c289
compiler: gcc (GCC) 10.1.0-syz 20200507
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=102c1114900000

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

==================================================================
BUG: KASAN: use-after-free in hci_chan_del+0x13e/0x180 net/bluetooth/hci_conn.c:1666
Read of size 8 at addr ffff88808e7c5198 by task syz-executor.0/6469

CPU: 0 PID: 6469 Comm: syz-executor.0 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 mm/kasan/report.c:412 [inline]
__asan_report_load8_noabort+0x88/0x90 mm/kasan/report.c:433
hci_chan_del+0x13e/0x180 net/bluetooth/hci_conn.c:1666
l2cap_conn_del+0x44f/0x6b0 net/bluetooth/l2cap_core.c:1736
l2cap_disconn_cfm net/bluetooth/l2cap_core.c:7435 [inline]
l2cap_disconn_cfm+0x85/0xa0 net/bluetooth/l2cap_core.c:7428
hci_disconn_cfm include/net/bluetooth/hci_core.h:1261 [inline]
hci_conn_hash_flush+0x114/0x220 net/bluetooth/hci_conn.c:1495
hci_dev_do_close+0x624/0xe70 net/bluetooth/hci_core.c:1666
hci_unregister_dev+0x17c/0x7f0 net/bluetooth/hci_core.c:3271
vhci_release+0x70/0xe0 drivers/bluetooth/hci_vhci.c:354
__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
__do_sys_exit_group kernel/exit.c:1001 [inline]
__se_sys_exit_group kernel/exit.c:999 [inline]
__x64_sys_exit_group+0x3a/0x50 kernel/exit.c:999
do_syscall_64+0xf9/0x620 arch/x86/entry/common.c:293
entry_SYSCALL_64_after_hwframe+0x49/0xbe
RIP: 0033:0x45cc79
Code: 00 00 00 84 00 48 05 98 16 00 00 48 89 44 24 10 48 89 04 24 48 c7 44 24 08 00 00 00 00 e8 2f 18 fc ff 64 48 8b 04 25 f8 ff ff <ff> 48 8b 40 30 48 8b 80 d0 00 00 00 48 89 04 24 e8 e2 02 fd ff 48
RSP: 002b:00007ffed10481e8 EFLAGS: 00000246 ORIG_RAX: 00000000000000e7
RAX: ffffffffffffffda RBX: 0000000000000000 RCX: 000000000045cc79
RDX: 00000000004166d1 RSI: 0000000000ca85f0 RDI: 0000000000000043
RBP: 00000000004c2903 R08: 000000000000000b R09: 0000000000000000
R10: 0000000001b9f940 R11: 0000000000000246 R12: 0000000000000003
R13: 00007ffed1048330 R14: 00000000001622a8 R15: 00007ffed1048340

Allocated by task 18856:
kmem_cache_alloc_trace+0x12f/0x380 mm/slab.c:3625
kmalloc include/linux/slab.h:515 [inline]
sock_alloc_inode+0x5f/0x250 net/socket.c:247
alloc_inode+0x5d/0x180 fs/inode.c:211
new_inode_pseudo+0x14/0xe0 fs/inode.c:911
sock_alloc+0x3c/0x260 net/socket.c:547
__sock_create+0xba/0x740 net/socket.c:1240
sock_create net/socket.c:1316 [inline]
__sys_socket+0xef/0x200 net/socket.c:1346
__do_sys_socket net/socket.c:1355 [inline]
__se_sys_socket net/socket.c:1353 [inline]
__x64_sys_socket+0x6f/0xb0 net/socket.c:1353
do_syscall_64+0xf9/0x620 arch/x86/entry/common.c:293
entry_SYSCALL_64_after_hwframe+0x49/0xbe

Freed by task 0:
__cache_free mm/slab.c:3503 [inline]
kfree+0xcc/0x210 mm/slab.c:3822
__rcu_reclaim kernel/rcu/rcu.h:231 [inline]
rcu_do_batch kernel/rcu/tree.c:2584 [inline]
invoke_rcu_callbacks kernel/rcu/tree.c:2897 [inline]
__rcu_process_callbacks kernel/rcu/tree.c:2864 [inline]
rcu_process_callbacks+0xa0d/0x18b0 kernel/rcu/tree.c:2881
__do_softirq+0x26c/0x9a0 kernel/softirq.c:292

The buggy address belongs to the object at ffff88808e7c5180
which belongs to the cache kmalloc-128 of size 128
The buggy address is located 24 bytes inside of
128-byte region [ffff88808e7c5180, ffff88808e7c5200)
The buggy address belongs to the page:
page:ffffea000239f140 count:1 mapcount:0 mapping:ffff88812c39c640 index:0x0
flags: 0xfffe0000000100(slab)
raw: 00fffe0000000100 ffffea000237b448 ffffea0002335188 ffff88812c39c640
raw: 0000000000000000 ffff88808e7c5000 0000000100000015 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
ffff88808e7c5080: fc fc fc fc fc fc fc fc fb fb fb fb fb fb fb fb
ffff88808e7c5100: fb fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc
>ffff88808e7c5180: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
^
ffff88808e7c5200: fc fc fc fc fc fc fc fc fb fb fb fb fb fb fb fb
ffff88808e7c5280: fb fb fb fb fb fb fb fb fc fc fc fc fc fc 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.
syzbot can test patches for this issue, for details see:
https://goo.gl/tpsmEJ#testing-patches

syzbot

unread,
Aug 3, 2020, 9:37:17 AM8/3/20
to syzkaller...@googlegroups.com
Hello,

syzbot found the following issue on:

HEAD commit: 7f2c5eb4 Linux 4.14.191
git tree: linux-4.14.y
console output: https://syzkaller.appspot.com/x/log.txt?x=124eb82a900000
kernel config: https://syzkaller.appspot.com/x/.config?x=881f1aee9620bf9f
dashboard link: https://syzkaller.appspot.com/bug?extid=985dfa65ff9ce7b7cd31
compiler: gcc (GCC) 10.1.0-syz 20200507
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=10caa60a900000

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

Bluetooth: hci0 command 0x041b tx timeout
Bluetooth: hci0 command 0x040f tx timeout
Bluetooth: hci0 command 0x0419 tx timeout
==================================================================
BUG: KASAN: use-after-free in hci_chan_del+0x131/0x180 net/bluetooth/hci_conn.c:1547
Read of size 8 at addr ffff8880a40c0618 by task syz-executor.0/6383

CPU: 1 PID: 6383 Comm: syz-executor.0 Not tainted 4.14.191-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
Call Trace:
__dump_stack lib/dump_stack.c:17 [inline]
dump_stack+0x1b2/0x283 lib/dump_stack.c:58
print_address_description.cold+0x54/0x1d3 mm/kasan/report.c:252
kasan_report_error.cold+0x8a/0x194 mm/kasan/report.c:351
kasan_report mm/kasan/report.c:409 [inline]
__asan_report_load8_noabort+0x68/0x70 mm/kasan/report.c:430
hci_chan_del+0x131/0x180 net/bluetooth/hci_conn.c:1547
l2cap_conn_del+0x417/0x670 net/bluetooth/l2cap_core.c:1736
l2cap_disconn_cfm net/bluetooth/l2cap_core.c:7435 [inline]
l2cap_disconn_cfm+0x6b/0x80 net/bluetooth/l2cap_core.c:7428
hci_disconn_cfm include/net/bluetooth/hci_core.h:1226 [inline]
hci_conn_hash_flush+0x114/0x220 net/bluetooth/hci_conn.c:1376

syzbot

unread,
Aug 5, 2020, 12:34:19 AM8/5/20
to syzkaller...@googlegroups.com
syzbot has found a reproducer for 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=1470e392900000
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=14f18b14900000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=13e821fc900000

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

batman_adv: batadv0: Interface activated: batadv_slave_1
IPv6: ADDRCONF(NETDEV_CHANGE): batadv_slave_1: link becomes ready
IPv6: ADDRCONF(NETDEV_CHANGE): veth1_to_batadv: link becomes ready
Bluetooth: hci0: hardware error 0x43
==================================================================
BUG: KASAN: use-after-free in hci_chan_del+0x13e/0x180 net/bluetooth/hci_conn.c:1666
Read of size 8 at addr ffff8880a4b0e918 by task kworker/u5:1/6690

CPU: 0 PID: 6690 Comm: kworker/u5:1 Not tainted 4.19.136-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
Workqueue: hci0 hci_error_reset
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 mm/kasan/report.c:412 [inline]
__asan_report_load8_noabort+0x88/0x90 mm/kasan/report.c:433
hci_chan_del+0x13e/0x180 net/bluetooth/hci_conn.c:1666
l2cap_conn_del+0x44f/0x6b0 net/bluetooth/l2cap_core.c:1736
l2cap_disconn_cfm net/bluetooth/l2cap_core.c:7435 [inline]
l2cap_disconn_cfm+0x85/0xa0 net/bluetooth/l2cap_core.c:7428
hci_disconn_cfm include/net/bluetooth/hci_core.h:1261 [inline]
hci_conn_hash_flush+0x114/0x220 net/bluetooth/hci_conn.c:1495
hci_dev_do_close+0x624/0xe70 net/bluetooth/hci_core.c:1666
hci_error_reset+0x90/0xf0 net/bluetooth/hci_core.c:2205
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 6690:
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_chan_create+0x8e/0x310 net/bluetooth/hci_conn.c:1651
l2cap_conn_add.part.0+0x18/0xc40 net/bluetooth/l2cap_core.c:7056
l2cap_conn_add net/bluetooth/l2cap_core.c:7415 [inline]
l2cap_connect_cfm+0x236/0xe70 net/bluetooth/l2cap_core.c:7373
hci_connect_cfm include/net/bluetooth/hci_core.h:1246 [inline]
le_conn_complete_evt+0x111b/0x1730 net/bluetooth/hci_event.c:4928
hci_le_enh_conn_complete_evt net/bluetooth/hci_event.c:4970 [inline]
hci_le_meta_evt+0x738/0x39c0 net/bluetooth/hci_event.c:5649
hci_event_packet+0x1a29/0x858f net/bluetooth/hci_event.c:5885
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

Freed by task 6690:
__cache_free mm/slab.c:3503 [inline]
kfree+0xcc/0x210 mm/slab.c:3822
hci_disconn_loglink_complete_evt net/bluetooth/hci_event.c:4755 [inline]
hci_event_packet+0xf52/0x858f net/bluetooth/hci_event.c:5906
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 ffff8880a4b0e900
which belongs to the cache kmalloc-128 of size 128
The buggy address is located 24 bytes inside of
128-byte region [ffff8880a4b0e900, ffff8880a4b0e980)
The buggy address belongs to the page:
page:ffffea000292c380 count:1 mapcount:0 mapping:ffff88812c39c640 index:0x0
flags: 0xfffe0000000100(slab)
raw: 00fffe0000000100 ffffea0002316288 ffffea0002690288 ffff88812c39c640
raw: 0000000000000000 ffff8880a4b0e000 0000000100000015 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
ffff8880a4b0e800: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
ffff8880a4b0e880: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
>ffff8880a4b0e900: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
^
ffff8880a4b0e980: fc fc fc fc fc fc fc fc 00 00 00 00 00 00 00 00
ffff8880a4b0ea00: 00 00 00 00 00 00 00 fc fc fc fc fc fc fc fc fc
==================================================================

syzbot

unread,
Aug 6, 2020, 4:14:17 AM8/6/20
to syzkaller...@googlegroups.com
syzbot has found a reproducer for the following issue on:

HEAD commit: ca4f2c56 Linux 4.14.192
git tree: linux-4.14.y
console output: https://syzkaller.appspot.com/x/log.txt?x=1791572a900000
kernel config: https://syzkaller.appspot.com/x/.config?x=60834b36c72d3e64
dashboard link: https://syzkaller.appspot.com/bug?extid=985dfa65ff9ce7b7cd31
compiler: gcc (GCC) 10.1.0-syz 20200507
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=156e5332900000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=1581b41a900000

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

Bluetooth: hci4 hardware error 0x43
==================================================================
BUG: KASAN: use-after-free in hci_chan_del+0x131/0x180 net/bluetooth/hci_conn.c:1547
Read of size 8 at addr ffff8880a81f7198 by task kworker/u5:6/7915

CPU: 1 PID: 7915 Comm: kworker/u5:6 Not tainted 4.14.192-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
Workqueue: hci4 hci_error_reset
Call Trace:
__dump_stack lib/dump_stack.c:17 [inline]
dump_stack+0x1b2/0x283 lib/dump_stack.c:58
print_address_description.cold+0x54/0x1d3 mm/kasan/report.c:252
kasan_report_error.cold+0x8a/0x194 mm/kasan/report.c:351
kasan_report mm/kasan/report.c:409 [inline]
__asan_report_load8_noabort+0x68/0x70 mm/kasan/report.c:430
hci_chan_del+0x131/0x180 net/bluetooth/hci_conn.c:1547
l2cap_conn_del+0x417/0x670 net/bluetooth/l2cap_core.c:1736
l2cap_disconn_cfm net/bluetooth/l2cap_core.c:7435 [inline]
l2cap_disconn_cfm+0x6b/0x80 net/bluetooth/l2cap_core.c:7428
hci_disconn_cfm include/net/bluetooth/hci_core.h:1226 [inline]
hci_conn_hash_flush+0x114/0x220 net/bluetooth/hci_conn.c:1376
hci_dev_do_close+0x542/0xc50 net/bluetooth/hci_core.c:1620
hci_error_reset+0x90/0xe0 net/bluetooth/hci_core.c:2156
process_one_work+0x793/0x14a0 kernel/workqueue.c:2116
worker_thread+0x5cc/0xff0 kernel/workqueue.c:2250
kthread+0x30d/0x420 kernel/kthread.c:232
ret_from_fork+0x24/0x30 arch/x86/entry/entry_64.S:404

Allocated by task 6393:
save_stack mm/kasan/kasan.c:447 [inline]
set_track mm/kasan/kasan.c:459 [inline]
kasan_kmalloc+0xeb/0x160 mm/kasan/kasan.c:551
kmem_cache_alloc_trace+0x131/0x3d0 mm/slab.c:3618
kmalloc include/linux/slab.h:488 [inline]
kzalloc include/linux/slab.h:661 [inline]
hci_chan_create+0x7c/0x300 net/bluetooth/hci_conn.c:1532
l2cap_conn_add.part.0+0x18/0xc20 net/bluetooth/l2cap_core.c:7056
l2cap_conn_add net/bluetooth/l2cap_core.c:7415 [inline]
l2cap_connect_cfm+0x1d2/0xce0 net/bluetooth/l2cap_core.c:7373
hci_connect_cfm include/net/bluetooth/hci_core.h:1211 [inline]
hci_le_conn_complete_evt net/bluetooth/hci_event.c:4602 [inline]
hci_le_meta_evt+0x3288/0x3fc0 net/bluetooth/hci_event.c:5161
hci_event_packet+0x25a7/0x7c7a net/bluetooth/hci_event.c:5416
hci_rx_work+0x3e6/0x970 net/bluetooth/hci_core.c:4244
process_one_work+0x793/0x14a0 kernel/workqueue.c:2116
worker_thread+0x5cc/0xff0 kernel/workqueue.c:2250
kthread+0x30d/0x420 kernel/kthread.c:232
ret_from_fork+0x24/0x30 arch/x86/entry/entry_64.S:404

Freed by task 6393:
save_stack mm/kasan/kasan.c:447 [inline]
set_track mm/kasan/kasan.c:459 [inline]
kasan_slab_free+0xc3/0x1a0 mm/kasan/kasan.c:524
__cache_free mm/slab.c:3496 [inline]
kfree+0xc9/0x250 mm/slab.c:3815
hci_disconn_loglink_complete_evt net/bluetooth/hci_event.c:4433 [inline]
hci_event_packet+0xeae/0x7c7a net/bluetooth/hci_event.c:5437
hci_rx_work+0x3e6/0x970 net/bluetooth/hci_core.c:4244
process_one_work+0x793/0x14a0 kernel/workqueue.c:2116
worker_thread+0x5cc/0xff0 kernel/workqueue.c:2250
kthread+0x30d/0x420 kernel/kthread.c:232
ret_from_fork+0x24/0x30 arch/x86/entry/entry_64.S:404

The buggy address belongs to the object at ffff8880a81f7180
which belongs to the cache kmalloc-128 of size 128
The buggy address is located 24 bytes inside of
128-byte region [ffff8880a81f7180, ffff8880a81f7200)
The buggy address belongs to the page:
page:ffffea0002a07dc0 count:1 mapcount:0 mapping:ffff8880a81f7000 index:0x0
flags: 0xfffe0000000100(slab)
raw: 00fffe0000000100 ffff8880a81f7000 0000000000000000 0000000100000015
raw: ffffea0002a0ace0 ffffea0002a65ea0 ffff88812fe52640 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
ffff8880a81f7080: fc fc fc fc fc fc fc fc 00 00 00 00 00 00 00 00
ffff8880a81f7100: 00 00 00 00 00 00 fc fc fc fc fc fc fc fc fc fc
>ffff8880a81f7180: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
^
ffff8880a81f7200: fc fc fc fc fc fc fc fc fb fb fb fb fb fb fb fb
ffff8880a81f7280: fb fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc
==================================================================

syzbot

unread,
Aug 13, 2021, 7:29:07 PM8/13/21
to syzkaller...@googlegroups.com
syzbot suspects this issue was fixed by commit:

commit 35113c4c9fa7c970ff456982e381dc9e9594154a
Author: Lin Ma <li...@zju.edu.cn>
Date: Mon Apr 12 11:17:57 2021 +0000

bluetooth: eliminate the potential race condition when removing the HCI controller

bisection log: https://syzkaller.appspot.com/x/bisect.txt?x=1341e9fa300000
start commit: 961f830af065 Linux 4.19.138
git tree: linux-4.19.y
kernel config: https://syzkaller.appspot.com/x/.config?x=b89fed56745db52a
dashboard link: https://syzkaller.appspot.com/bug?extid=2bb1968c6e2f8782c289
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=15713dc6900000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=172854aa900000

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

#syz fix: bluetooth: eliminate the potential race condition when removing the HCI controller

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