KASAN: use-after-free Read in __queue_work

13 views
Skip to first unread message

syzbot

unread,
Aug 3, 2020, 12:16:21 AM8/3/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=1375de04900000
kernel config: https://syzkaller.appspot.com/x/.config?x=5b7578d3b5457a49
dashboard link: https://syzkaller.appspot.com/bug?extid=cc2c0bfd39eb9c4f3998
compiler: gcc (GCC) 10.1.0-syz 20200507
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=15ec7014900000

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

==================================================================
BUG: KASAN: use-after-free in __queue_work+0xdff/0x1100 kernel/workqueue.c:1383
Read of size 4 at addr ffff8880928b4240 by task syz-executor.2/11635

CPU: 1 PID: 11635 Comm: syz-executor.2 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_load4_noabort+0x88/0x90 mm/kasan/report.c:432
__queue_work+0xdff/0x1100 kernel/workqueue.c:1383
queue_work_on+0x17e/0x1f0 kernel/workqueue.c:1488
queue_work include/linux/workqueue.h:512 [inline]
req_run+0x2c5/0x4a0 net/bluetooth/hci_request.c:87
hci_req_run_skb net/bluetooth/hci_request.c:99 [inline]
__hci_req_sync+0x1d8/0x830 net/bluetooth/hci_request.c:212
hci_req_sync+0x7d/0xb0 net/bluetooth/hci_request.c:279
hci_dev_cmd+0x55f/0x890 net/bluetooth/hci_core.c:1911
hci_sock_ioctl+0x3c2/0x7a0 net/bluetooth/hci_sock.c:1045
sock_do_ioctl+0xcb/0x2d0 net/socket.c:950
sock_ioctl+0x2ef/0x5d0 net/socket.c:1074
vfs_ioctl fs/ioctl.c:46 [inline]
file_ioctl fs/ioctl.c:501 [inline]
do_vfs_ioctl+0xcdb/0x12e0 fs/ioctl.c:688
ksys_ioctl+0x9b/0xc0 fs/ioctl.c:705
__do_sys_ioctl fs/ioctl.c:712 [inline]
__se_sys_ioctl fs/ioctl.c:710 [inline]
__x64_sys_ioctl+0x6f/0xb0 fs/ioctl.c:710
do_syscall_64+0xf9/0x620 arch/x86/entry/common.c:293
entry_SYSCALL_64_after_hwframe+0x49/0xbe
RIP: 0033:0x45cc79
Code: 2d b6 fb ff c3 66 2e 0f 1f 84 00 00 00 00 00 66 90 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 0f 83 fb b5 fb ff c3 66 2e 0f 1f 84 00 00 00 00
RSP: 002b:00007f438b639c78 EFLAGS: 00000246 ORIG_RAX: 0000000000000010
RAX: ffffffffffffffda RBX: 000000000001d300 RCX: 000000000045cc79
RDX: 0000000020000000 RSI: 00000000400448de RDI: 0000000000000004
RBP: 000000000078bf40 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 000000000078bf0c
R13: 00007ffe03ac323f R14: 00007f438b63a9c0 R15: 000000000078bf0c

Allocated by task 14:
__do_kmalloc mm/slab.c:3727 [inline]
__kmalloc+0x15a/0x3c0 mm/slab.c:3736
kmalloc include/linux/slab.h:520 [inline]
kzalloc include/linux/slab.h:709 [inline]
__alloc_workqueue_key+0x789/0xed0 kernel/workqueue.c:4087
hci_register_dev+0x1bf/0x870 net/bluetooth/hci_core.c:3179
__vhci_create_device+0x2b5/0x580 drivers/bluetooth/hci_vhci.c:139
vhci_create_device drivers/bluetooth/hci_vhci.c:163 [inline]
vhci_open_timeout+0x35/0x50 drivers/bluetooth/hci_vhci.c:319
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 9:
__cache_free mm/slab.c:3503 [inline]
kfree+0xcc/0x210 mm/slab.c:3822
__rcu_reclaim kernel/rcu/rcu.h:236 [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+0x8ff/0x18b0 kernel/rcu/tree.c:2881
__do_softirq+0x26c/0x9a0 kernel/softirq.c:292

The buggy address belongs to the object at ffff8880928b40c0
which belongs to the cache kmalloc-512 of size 512
The buggy address is located 384 bytes inside of
512-byte region [ffff8880928b40c0, ffff8880928b42c0)
The buggy address belongs to the page:
page:ffffea00024a2d00 count:1 mapcount:0 mapping:ffff88812c39c940 index:0x0
flags: 0xfffe0000000100(slab)
raw: 00fffe0000000100 ffffea00024f5448 ffffea00024a0e48 ffff88812c39c940
raw: 0000000000000000 ffff8880928b40c0 0000000100000006 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
ffff8880928b4100: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff8880928b4180: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff8880928b4200: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
^
ffff8880928b4280: fb fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc
ffff8880928b4300: fc fc fc fc fc fc fc fc 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,
Aug 3, 2020, 11:06:23 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=17b60692900000
kernel config: https://syzkaller.appspot.com/x/.config?x=881f1aee9620bf9f
dashboard link: https://syzkaller.appspot.com/bug?extid=d50829dd9012153a5ad2
compiler: gcc (GCC) 10.1.0-syz 20200507
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=167825d4900000

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

Bluetooth: hci2 command 0x041b tx timeout
==================================================================
BUG: KASAN: use-after-free in __queue_work+0xc2f/0xf70 kernel/workqueue.c:1385
Read of size 4 at addr ffff8880a7e71b80 by task syz-executor.4/10075

CPU: 0 PID: 10075 Comm: syz-executor.4 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_load4_noabort+0x68/0x70 mm/kasan/report.c:429
__queue_work+0xc2f/0xf70 kernel/workqueue.c:1385
queue_work_on+0x159/0x1d0 kernel/workqueue.c:1490
queue_work include/linux/workqueue.h:491 [inline]
req_run+0x2bb/0x490 net/bluetooth/hci_request.c:77
hci_req_run_skb net/bluetooth/hci_request.c:89 [inline]
__hci_req_sync+0x277/0x770 net/bluetooth/hci_request.c:214
hci_req_sync+0x71/0xa0 net/bluetooth/hci_request.c:285
hci_dev_cmd+0x395/0x720 net/bluetooth/hci_core.c:1865
hci_sock_ioctl+0x30c/0x650 net/bluetooth/hci_sock.c:1040
sock_do_ioctl net/socket.c:974 [inline]
sock_ioctl+0x2cc/0x4c0 net/socket.c:1071
vfs_ioctl fs/ioctl.c:46 [inline]
file_ioctl fs/ioctl.c:500 [inline]
do_vfs_ioctl+0x75a/0xff0 fs/ioctl.c:684
SYSC_ioctl fs/ioctl.c:701 [inline]
SyS_ioctl+0x7f/0xb0 fs/ioctl.c:692
do_syscall_64+0x1d5/0x640 arch/x86/entry/common.c:292
entry_SYSCALL_64_after_hwframe+0x46/0xbb
RIP: 0033:0x45cc79
RSP: 002b:00007feecffd8c78 EFLAGS: 00000246 ORIG_RAX: 0000000000000010
RAX: ffffffffffffffda RBX: 000000000001d300 RCX: 000000000045cc79
RDX: 0000000020000000 RSI: 00000000400448de RDI: 0000000000000004
RBP: 000000000078bf40 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 000000000078bf0c
R13: 00007ffc48cb57af R14: 00007feecffd99c0 R15: 000000000078bf0c

Allocated by task 6675:
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
__do_kmalloc mm/slab.c:3720 [inline]
__kmalloc+0x15a/0x400 mm/slab.c:3729
kmalloc include/linux/slab.h:493 [inline]
kzalloc include/linux/slab.h:661 [inline]
__alloc_workqueue_key+0x10e/0x1080 kernel/workqueue.c:3996
hci_register_dev+0x1a0/0x800 net/bluetooth/hci_core.c:3099
__vhci_create_device+0x28d/0x540 drivers/bluetooth/hci_vhci.c:139
vhci_create_device drivers/bluetooth/hci_vhci.c:163 [inline]
vhci_open_timeout+0x35/0x50 drivers/bluetooth/hci_vhci.c:319
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 17:
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
__rcu_reclaim kernel/rcu/rcu.h:195 [inline]
rcu_do_batch kernel/rcu/tree.c:2699 [inline]
invoke_rcu_callbacks kernel/rcu/tree.c:2962 [inline]
__rcu_process_callbacks kernel/rcu/tree.c:2929 [inline]
rcu_process_callbacks+0x780/0x1180 kernel/rcu/tree.c:2946
__do_softirq+0x254/0xa1d kernel/softirq.c:288

The buggy address belongs to the object at ffff8880a7e71a00
which belongs to the cache kmalloc-512 of size 512
The buggy address is located 384 bytes inside of
512-byte region [ffff8880a7e71a00, ffff8880a7e71c00)
The buggy address belongs to the page:
page:ffffea00029f9c40 count:1 mapcount:0 mapping:ffff8880a7e71000 index:0x0
flags: 0xfffe0000000100(slab)
raw: 00fffe0000000100 ffff8880a7e71000 0000000000000000 0000000100000006
raw: ffffea00029fc060 ffffea0002a0da20 ffff88812fe52940 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
ffff8880a7e71a80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff8880a7e71b00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff8880a7e71b80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
^
ffff8880a7e71c00: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
ffff8880a7e71c80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb

syzbot

unread,
Sep 9, 2021, 6:23:09 AM9/9/21
to syzkaller...@googlegroups.com
syzbot suspects this issue was fixed by commit:

commit 3719acc161d5c1ce09912cc1c9eddc2c5faa3c66
Author: Tetsuo Handa <penguin...@i-love.sakura.ne.jp>
Date: Wed Aug 4 10:26:56 2021 +0000

Bluetooth: defer cleanup of resources in hci_unregister_dev()

bisection log: https://syzkaller.appspot.com/x/bisect.txt?x=17751db3300000
start commit: 811218eceeaa Linux 4.19.172
git tree: linux-4.19.y
kernel config: https://syzkaller.appspot.com/x/.config?x=c1cb1d27398c8808
dashboard link: https://syzkaller.appspot.com/bug?extid=cc2c0bfd39eb9c4f3998
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=13705ff8d00000

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

#syz fix: Bluetooth: defer cleanup of resources in hci_unregister_dev()

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