KASAN: use-after-free Write in __sco_sock_close

29 views
Skip to first unread message

syzbot

unread,
Aug 2, 2020, 4:45:20ā€ÆPM8/2/20
to da...@davemloft.net, johan....@gmail.com, ku...@kernel.org, linux-b...@vger.kernel.org, linux-...@vger.kernel.org, mar...@holtmann.org, net...@vger.kernel.org, syzkall...@googlegroups.com
Hello,

syzbot found the following issue on:

HEAD commit: ac3a0c84 Merge git://git.kernel.org/pub/scm/linux/kernel/g..
git tree: upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=17082904900000
kernel config: https://syzkaller.appspot.com/x/.config?x=e59ee776d5aa8d55
dashboard link: https://syzkaller.appspot.com/bug?extid=077eca30d3cb7c02b273
compiler: clang version 10.0.0 (https://github.com/llvm/llvm-project/ c2443155a0fb245c8f17f2c1c72b6ea391e86e81)
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=12cf1904900000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=10d52e14900000

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

==================================================================
BUG: KASAN: use-after-free in instrument_atomic_write include/linux/instrumented.h:71 [inline]
BUG: KASAN: use-after-free in atomic_dec_and_test include/asm-generic/atomic-instrumented.h:748 [inline]
BUG: KASAN: use-after-free in hci_conn_drop include/net/bluetooth/hci_core.h:1049 [inline]
BUG: KASAN: use-after-free in sco_chan_del net/bluetooth/sco.c:148 [inline]
BUG: KASAN: use-after-free in __sco_sock_close+0x47c/0xed0 net/bluetooth/sco.c:433
Write of size 4 at addr ffff88809191e010 by task syz-executor393/6961

CPU: 0 PID: 6961 Comm: syz-executor393 Not tainted 5.8.0-rc7-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+0x1f0/0x31e lib/dump_stack.c:118
print_address_description+0x66/0x5a0 mm/kasan/report.c:383
__kasan_report mm/kasan/report.c:513 [inline]
kasan_report+0x132/0x1d0 mm/kasan/report.c:530
check_memory_region_inline mm/kasan/generic.c:183 [inline]
check_memory_region+0x2b5/0x2f0 mm/kasan/generic.c:192
instrument_atomic_write include/linux/instrumented.h:71 [inline]
atomic_dec_and_test include/asm-generic/atomic-instrumented.h:748 [inline]
hci_conn_drop include/net/bluetooth/hci_core.h:1049 [inline]
sco_chan_del net/bluetooth/sco.c:148 [inline]
__sco_sock_close+0x47c/0xed0 net/bluetooth/sco.c:433
sco_sock_close net/bluetooth/sco.c:447 [inline]
sco_sock_release+0x63/0x4f0 net/bluetooth/sco.c:1021
__sock_release net/socket.c:605 [inline]
sock_close+0xd8/0x260 net/socket.c:1278
__fput+0x2f0/0x750 fs/file_table.c:281
task_work_run+0x137/0x1c0 kernel/task_work.c:135
exit_task_work include/linux/task_work.h:25 [inline]
do_exit+0x601/0x1f80 kernel/exit.c:805
do_group_exit+0x161/0x2d0 kernel/exit.c:903
get_signal+0x139b/0x1d30 kernel/signal.c:2743
do_signal+0x33/0x610 arch/x86/kernel/signal.c:810
exit_to_usermode_loop arch/x86/entry/common.c:235 [inline]
__prepare_exit_to_usermode+0xd7/0x1e0 arch/x86/entry/common.c:269
do_syscall_64+0x7f/0xe0 arch/x86/entry/common.c:393
entry_SYSCALL_64_after_hwframe+0x44/0xa9
RIP: 0033:0x446e69
Code: Bad RIP value.
RSP: 002b:00007ffde45fd7f8 EFLAGS: 00000246 ORIG_RAX: 000000000000002a
RAX: fffffffffffffffc RBX: 0000000000000000 RCX: 0000000000446e69
RDX: 0000000000000008 RSI: 0000000020000000 RDI: 0000000000000004
RBP: 0000000000000004 R08: 0000000000000002 R09: 00000003000000ff
R10: 0000000000000004 R11: 0000000000000246 R12: 0000000000000000
R13: 0000000000407ac0 R14: 0000000000000000 R15: 0000000000000000

Allocated by task 6961:
save_stack mm/kasan/common.c:48 [inline]
set_track mm/kasan/common.c:56 [inline]
__kasan_kmalloc+0x103/0x140 mm/kasan/common.c:494
kmem_cache_alloc_trace+0x234/0x300 mm/slab.c:3551
kmalloc include/linux/slab.h:555 [inline]
kzalloc include/linux/slab.h:669 [inline]
hci_conn_add+0x5d/0x1040 net/bluetooth/hci_conn.c:525
hci_connect_sco+0x29a/0xa10 net/bluetooth/hci_conn.c:1279
sco_connect net/bluetooth/sco.c:240 [inline]
sco_sock_connect+0x2de/0xaa0 net/bluetooth/sco.c:576
__sys_connect_file net/socket.c:1854 [inline]
__sys_connect+0x2da/0x360 net/socket.c:1871
__do_sys_connect net/socket.c:1882 [inline]
__se_sys_connect net/socket.c:1879 [inline]
__x64_sys_connect+0x76/0x80 net/socket.c:1879
do_syscall_64+0x73/0xe0 arch/x86/entry/common.c:384
entry_SYSCALL_64_after_hwframe+0x44/0xa9

Freed by task 6957:
save_stack mm/kasan/common.c:48 [inline]
set_track mm/kasan/common.c:56 [inline]
kasan_set_free_info mm/kasan/common.c:316 [inline]
__kasan_slab_free+0x114/0x170 mm/kasan/common.c:455
__cache_free mm/slab.c:3426 [inline]
kfree+0x10a/0x220 mm/slab.c:3757
device_release+0x70/0x1a0 drivers/base/core.c:1575
kobject_cleanup lib/kobject.c:693 [inline]
kobject_release lib/kobject.c:722 [inline]
kref_put include/linux/kref.h:65 [inline]
kobject_put+0x15b/0x220 lib/kobject.c:739
hci_conn_del+0x2c2/0x550 net/bluetooth/hci_conn.c:645
hci_phy_link_complete_evt net/bluetooth/hci_event.c:4921 [inline]
hci_event_packet+0x8335/0x18260 net/bluetooth/hci_event.c:6180
hci_rx_work+0x236/0x9c0 net/bluetooth/hci_core.c:4705
process_one_work+0x789/0xfc0 kernel/workqueue.c:2269
worker_thread+0xaa4/0x1460 kernel/workqueue.c:2415
kthread+0x37e/0x3a0 drivers/block/aoe/aoecmd.c:1234
ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:293

The buggy address belongs to the object at ffff88809191e000
which belongs to the cache kmalloc-4k of size 4096
The buggy address is located 16 bytes inside of
4096-byte region [ffff88809191e000, ffff88809191f000)
The buggy address belongs to the page:
page:ffffea0002464780 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 head:ffffea0002464780 order:1 compound_mapcount:0
flags: 0xfffe0000010200(slab|head)
raw: 00fffe0000010200 ffffea0002489f88 ffffea000249dd08 ffff8880aa402000
raw: 0000000000000000 ffff88809191e000 0000000100000001 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
ffff88809191df00: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
ffff88809191df80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
>ffff88809191e000: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
^
ffff88809191e080: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff88809191e100: 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,
Aug 2, 2020, 8:49:05ā€ÆPM8/2/20
to core...@netfilter.org, da...@davemloft.net, de...@driverdev.osuosl.org, gre...@linuxfoundation.org, johan....@gmail.com, ka...@trash.net, kad...@blackhole.kfki.hu, ku...@kernel.org, linux-b...@vger.kernel.org, linux-...@vger.kernel.org, linux...@vger.kernel.org, mar...@holtmann.org, mch...@kernel.org, mch...@s-opensource.com, net...@vger.kernel.org, netfilt...@vger.kernel.org, pa...@netfilter.org, syzkall...@googlegroups.com
syzbot has bisected this issue to:

commit 43ea43b9d8b27b7acd443ec59319faa3cdb8a616
Author: Mauro Carvalho Chehab <mch...@s-opensource.com>
Date: Wed Oct 12 11:21:43 2016 +0000

[media] radio-bcm2048: don't ignore errors

bisection log: https://syzkaller.appspot.com/x/bisect.txt?x=1036e6a4900000
start commit: ac3a0c84 Merge git://git.kernel.org/pub/scm/linux/kernel/g..
git tree: upstream
final oops: https://syzkaller.appspot.com/x/report.txt?x=1236e6a4900000
console output: https://syzkaller.appspot.com/x/log.txt?x=1436e6a4900000
Reported-by: syzbot+077eca...@syzkaller.appspotmail.com
Fixes: 43ea43b9d8b2 ("[media] radio-bcm2048: don't ignore errors")

For information about bisection process see: https://goo.gl/tpsmEJ#bisection

syzbot

unread,
Aug 12, 2020, 2:48:04ā€ÆAM8/12/20
to foxh...@gmail.com, syzkall...@googlegroups.com
Hello,

syzbot has tested the proposed patch but the reproducer is still triggering an issue:
KASAN: use-after-free Write in __sco_sock_close

==================================================================
BUG: KASAN: use-after-free in instrument_atomic_write include/linux/instrumented.h:71 [inline]
BUG: KASAN: use-after-free in atomic_dec_and_test include/asm-generic/atomic-instrumented.h:748 [inline]
BUG: KASAN: use-after-free in hci_conn_drop include/net/bluetooth/hci_core.h:1116 [inline]
BUG: KASAN: use-after-free in sco_chan_del net/bluetooth/sco.c:149 [inline]
BUG: KASAN: use-after-free in __sco_sock_close+0x47c/0xed0 net/bluetooth/sco.c:434
Write of size 4 at addr ffff88809deac010 by task syz-executor.0/8217

CPU: 0 PID: 8217 Comm: syz-executor.0 Not tainted 5.8.0-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+0x1f0/0x31e lib/dump_stack.c:118
print_address_description+0x66/0x620 mm/kasan/report.c:383
__kasan_report mm/kasan/report.c:513 [inline]
kasan_report+0x132/0x1d0 mm/kasan/report.c:530
check_memory_region_inline mm/kasan/generic.c:183 [inline]
check_memory_region+0x2b5/0x2f0 mm/kasan/generic.c:192
instrument_atomic_write include/linux/instrumented.h:71 [inline]
atomic_dec_and_test include/asm-generic/atomic-instrumented.h:748 [inline]
hci_conn_drop include/net/bluetooth/hci_core.h:1116 [inline]
sco_chan_del net/bluetooth/sco.c:149 [inline]
__sco_sock_close+0x47c/0xed0 net/bluetooth/sco.c:434
sco_sock_close net/bluetooth/sco.c:448 [inline]
sco_sock_release+0x63/0x4f0 net/bluetooth/sco.c:1053
__sock_release net/socket.c:596 [inline]
sock_close+0xd8/0x260 net/socket.c:1277
__fput+0x34f/0x7b0 fs/file_table.c:281
task_work_run+0x137/0x1c0 kernel/task_work.c:135
get_signal+0x15ab/0x1d30 kernel/signal.c:2547
arch_do_signal+0x33/0x610 arch/x86/kernel/signal.c:811
exit_to_user_mode_loop kernel/entry/common.c:135 [inline]
exit_to_user_mode_prepare+0x8d/0x1c0 kernel/entry/common.c:166
syscall_exit_to_user_mode+0x5e/0x1a0 kernel/entry/common.c:241
entry_SYSCALL_64_after_hwframe+0x44/0xa9
RIP: 0033:0x45ccd9
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:00007f0357f71c78 EFLAGS: 00000246 ORIG_RAX: 000000000000002a
RAX: fffffffffffffffc RBX: 0000000000002140 RCX: 000000000045ccd9
RDX: 0000000000000008 RSI: 00000000200000c0 RDI: 0000000000000004
RBP: 000000000078bf40 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 000000000078bf0c
R13: 00007ffdf5587d8f R14: 00007f0357f729c0 R15: 000000000078bf0c

Allocated by task 8217:
kasan_save_stack mm/kasan/common.c:48 [inline]
kasan_set_track mm/kasan/common.c:56 [inline]
__kasan_kmalloc+0x100/0x130 mm/kasan/common.c:461
kmem_cache_alloc_trace+0x1f6/0x2f0 mm/slab.c:3550
kmalloc include/linux/slab.h:554 [inline]
kzalloc include/linux/slab.h:666 [inline]
hci_conn_add+0x5d/0x1040 net/bluetooth/hci_conn.c:525
hci_connect_sco+0x2aa/0xa20 net/bluetooth/hci_conn.c:1283
sco_connect net/bluetooth/sco.c:241 [inline]
sco_sock_connect+0x2de/0xaa0 net/bluetooth/sco.c:588
__sys_connect_file net/socket.c:1853 [inline]
__sys_connect+0x2da/0x360 net/socket.c:1870
__do_sys_connect net/socket.c:1881 [inline]
__se_sys_connect net/socket.c:1878 [inline]
__x64_sys_connect+0x76/0x80 net/socket.c:1878
do_syscall_64+0x31/0x70 arch/x86/entry/common.c:46
entry_SYSCALL_64_after_hwframe+0x44/0xa9

Freed by task 8244:
kasan_save_stack mm/kasan/common.c:48 [inline]
kasan_set_track+0x3d/0x70 mm/kasan/common.c:56
kasan_set_free_info+0x17/0x30 mm/kasan/generic.c:355
__kasan_slab_free+0xdd/0x110 mm/kasan/common.c:422
__cache_free mm/slab.c:3418 [inline]
kfree+0x10a/0x220 mm/slab.c:3756
device_release+0x70/0x1a0 drivers/base/core.c:1796
kobject_cleanup lib/kobject.c:704 [inline]
kobject_release lib/kobject.c:735 [inline]
kref_put include/linux/kref.h:65 [inline]
kobject_put+0x1a0/0x2c0 lib/kobject.c:752
hci_conn_del+0x2c2/0x550 net/bluetooth/hci_conn.c:645
hci_phy_link_complete_evt net/bluetooth/hci_event.c:4940 [inline]
hci_event_packet+0x82c8/0x17e10 net/bluetooth/hci_event.c:6205
hci_rx_work+0x246/0xa20 net/bluetooth/hci_core.c:4889
process_one_work+0x789/0xfc0 kernel/workqueue.c:2269
worker_thread+0xaa4/0x1460 kernel/workqueue.c:2415
kthread+0x37e/0x3a0 drivers/block/aoe/aoecmd.c:1234
ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:294

The buggy address belongs to the object at ffff88809deac000
which belongs to the cache kmalloc-4k of size 4096
The buggy address is located 16 bytes inside of
4096-byte region [ffff88809deac000, ffff88809dead000)
The buggy address belongs to the page:
page:000000006e273a44 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x9deac
head:000000006e273a44 order:1 compound_mapcount:0
flags: 0xfffe0000010200(slab|head)
raw: 00fffe0000010200 ffffea0002783008 ffffea0002799c88 ffff8880aa440900
raw: 0000000000000000 ffff88809deac000 0000000100000001 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
ffff88809deabf00: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
ffff88809deabf80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
>ffff88809deac000: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
^
ffff88809deac080: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff88809deac100: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================


Tested on:

commit: fb893de3 Merge tag 'tag-chrome-platform-for-v5.9' of git:/..
git tree: upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=13fa5dba900000
kernel config: https://syzkaller.appspot.com/x/.config?x=d766a4cdcd05286c

syzbot

unread,
Aug 14, 2020, 9:36:06ā€ÆAM8/14/20
to foxh...@gmail.com, syzkall...@googlegroups.com
Hello,

syzbot has tested the proposed patch and the reproducer did not trigger any issue:

Reported-and-tested-by: syzbot+077eca...@syzkaller.appspotmail.com

Tested on:

commit: 47ec5303 Merge git://git.kernel.org/pub/scm/linux/kernel/g..
git tree: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel config: https://syzkaller.appspot.com/x/.config?x=e0c783f658542f35
dashboard link: https://syzkaller.appspot.com/bug?extid=077eca30d3cb7c02b273
compiler: clang version 10.0.0 (https://github.com/llvm/llvm-project/ c2443155a0fb245c8f17f2c1c72b6ea391e86e81)
patch: https://syzkaller.appspot.com/x/patch.diff?x=124f9be2900000

Note: testing is done by a robot and is best-effort only.

syzbot

unread,
Dec 16, 2020, 2:15:04ā€ÆAM12/16/20
to anmol.k...@gmail.com, core...@netfilter.org, da...@davemloft.net, de...@driverdev.osuosl.org, foxh...@gmail.com, gre...@linuxfoundation.org, johan....@gmail.com, ka...@trash.net, kad...@blackhole.kfki.hu, ku...@kernel.org, linux-b...@vger.kernel.org, linux-...@vger.kernel.org, linux...@vger.kernel.org, mar...@holtmann.org, mch...@kernel.org, mch...@s-opensource.com, net...@vger.kernel.org, netfilt...@vger.kernel.org, pa...@netfilter.org, syzkall...@googlegroups.com
syzbot suspects this issue was fixed by commit:

commit 6dfccd13db2ff2b709ef60a50163925d477549aa
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=14cb845b500000
start commit: 47ec5303 Merge git://git.kernel.org/pub/scm/linux/kernel/g..
git tree: upstream
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=165a89dc900000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=130a8c62900000

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()

Dmitry Vyukov

unread,
Dec 17, 2020, 6:07:19ā€ÆAM12/17/20
to syzbot, anmol.k...@gmail.com, core...@netfilter.org, David Miller, open list:ANDROID DRIVERS, Fox Chen, Greg Kroah-Hartman, Johan Hedberg, Patrick McHardy, Jozsef Kadlecsik, Jakub Kicinski, linux-bluetooth, LKML, linux...@vger.kernel.org, Marcel Holtmann, Mauro Carvalho Chehab, mch...@s-opensource.com, netdev, NetFilter, Pablo Neira Ayuso, syzkaller-bugs
Reply all
Reply to author
Forward
0 new messages