syzbot


KASAN: use-after-free Write in hci_sock_bind

Status: fixed on 2021/08/26 13:35
Reported-by: syzbot+bdbdd849903b8659f6ea@syzkaller.appspotmail.com
Fix commit: 3719acc161d5 Bluetooth: defer cleanup of resources in hci_unregister_dev()
First crash: 1559d, last: 999d
Fix bisection: fixed by (bisect log) :
commit 3719acc161d5c1ce09912cc1c9eddc2c5faa3c66
Author: Tetsuo Handa <penguin-kernel@i-love.sakura.ne.jp>
Date: Wed Aug 4 10:26:56 2021 +0000

  Bluetooth: defer cleanup of resources in hci_unregister_dev()

  
Similar bugs (2)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
upstream KASAN: use-after-free Write in hci_sock_bind bluetooth 4 1523d 1555d 15/26 fixed on 2020/02/18 14:31
upstream KASAN: use-after-free Write in hci_sock_bind (2) bluetooth C done unreliable 26 1234d 1508d 0/26 auto-obsoleted due to no activity on 2023/01/05 15:02
Fix bisection attempts (16)
Created Duration User Patch Repo Result
2021/08/24 00:07 4h33m bisect fix linux-4.19.y job log (1)
2021/07/24 22:23 31m bisect fix linux-4.19.y job log (0) log
2021/06/24 21:49 26m bisect fix linux-4.19.y job log (0) log
2021/05/25 18:59 32m bisect fix linux-4.19.y job log (0) log
2021/04/25 17:32 34m bisect fix linux-4.19.y job log (0) log
2021/03/26 08:59 33m bisect fix linux-4.19.y job log (0) log
2021/02/24 07:37 32m bisect fix linux-4.19.y job log (0) log
2021/01/24 16:43 33m bisect fix linux-4.19.y job log (0) log
2020/12/25 16:13 29m bisect fix linux-4.19.y job log (0) log
2020/11/25 15:46 27m bisect fix linux-4.19.y job log (0) log
2020/10/26 15:18 28m bisect fix linux-4.19.y job log (0) log
2020/09/26 14:11 27m bisect fix linux-4.19.y job log (0) log
2020/08/27 13:40 30m bisect fix linux-4.19.y job log (0) log
2020/07/25 10:02 35m bisect fix linux-4.19.y job log (0) log
2020/06/25 09:32 29m bisect fix linux-4.19.y job log (0) log
2020/02/11 04:31 39m bisect fix linux-4.19.y job log (0) log

Sample crash report:
==================================================================
BUG: KASAN: use-after-free in atomic_inc include/asm-generic/atomic-instrumented.h:109 [inline]
BUG: KASAN: use-after-free in hci_sock_bind+0x521/0x1000 net/bluetooth/hci_sock.c:1226
Write of size 4 at addr ffff8880a01422e0 by task syz-executor639/8329

CPU: 0 PID: 8329 Comm: syz-executor639 Not tainted 4.19.113-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+0x188/0x20d lib/dump_stack.c:118
 print_address_description.cold+0x7c/0x212 mm/kasan/report.c:256
 kasan_report_error mm/kasan/report.c:354 [inline]
 kasan_report mm/kasan/report.c:412 [inline]
 kasan_report.cold+0x88/0x2b9 mm/kasan/report.c:396
 atomic_inc include/asm-generic/atomic-instrumented.h:109 [inline]
 hci_sock_bind+0x521/0x1000 net/bluetooth/hci_sock.c:1226
 __sys_bind+0x20e/0x250 net/socket.c:1482
 __do_sys_bind net/socket.c:1493 [inline]
 __se_sys_bind net/socket.c:1491 [inline]
 __x64_sys_bind+0x6f/0xb0 net/socket.c:1491
 do_syscall_64+0xf9/0x620 arch/x86/entry/common.c:293
 entry_SYSCALL_64_after_hwframe+0x49/0xbe
RIP: 0033:0x4467e9
Code: e8 0c e8 ff ff 48 83 c4 18 c3 0f 1f 80 00 00 00 00 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 5b 07 fc ff c3 66 2e 0f 1f 84 00 00 00 00
RSP: 002b:00007f9c63c08db8 EFLAGS: 00000246 ORIG_RAX: 0000000000000031
RAX: ffffffffffffffda RBX: 00000000006dbc28 RCX: 00000000004467e9
RDX: 0000000000000006 RSI: 0000000020000080 RDI: 0000000000000004
RBP: 00000000006dbc20 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 00000000006dbc2c
R13: 00007ffcd6b2faaf R14: 00007f9c63c099c0 R15: 000000000000002d

Allocated by task 8333:
 set_track mm/kasan/kasan.c:460 [inline]
 kasan_kmalloc mm/kasan/kasan.c:553 [inline]
 kasan_kmalloc+0xbf/0xe0 mm/kasan/kasan.c:531
 kmem_cache_alloc_trace+0x14d/0x7a0 mm/slab.c:3625
 kmalloc include/linux/slab.h:515 [inline]
 kzalloc include/linux/slab.h:709 [inline]
 hci_alloc_dev+0x3e/0x1cf0 net/bluetooth/hci_core.c:3053
 __vhci_create_device+0x100/0x580 drivers/bluetooth/hci_vhci.c:114
 vhci_create_device drivers/bluetooth/hci_vhci.c:163 [inline]
 vhci_get_user drivers/bluetooth/hci_vhci.c:219 [inline]
 vhci_write+0x2c5/0x460 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+0x512/0x760 fs/read_write.c:487
 vfs_write+0x206/0x550 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 8327:
 set_track mm/kasan/kasan.c:460 [inline]
 __kasan_slab_free+0xf7/0x140 mm/kasan/kasan.c:521
 __cache_free mm/slab.c:3503 [inline]
 kfree+0xce/0x220 mm/slab.c:3822
 bt_host_release+0x15/0x20 net/bluetooth/hci_sysfs.c:86
 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+0x17c/0x270 lib/kobject.c:708
 put_device+0x1c/0x30 drivers/base/core.c:2251
 vhci_release+0x78/0xe0 drivers/bluetooth/hci_vhci.c:355
 __fput+0x2cd/0x890 fs/file_table.c:278
 task_work_run+0x13f/0x1b0 kernel/task_work.c:113
 exit_task_work include/linux/task_work.h:22 [inline]
 do_exit+0xbcd/0x2f30 kernel/exit.c:880
 do_group_exit+0x125/0x350 kernel/exit.c:983
 __do_sys_exit_group kernel/exit.c:994 [inline]
 __se_sys_exit_group kernel/exit.c:992 [inline]
 __x64_sys_exit_group+0x3a/0x50 kernel/exit.c:992
 do_syscall_64+0xf9/0x620 arch/x86/entry/common.c:293
 entry_SYSCALL_64_after_hwframe+0x49/0xbe

The buggy address belongs to the object at ffff8880a0141280
 which belongs to the cache kmalloc-8192 of size 8192
The buggy address is located 4192 bytes inside of
 8192-byte region [ffff8880a0141280, ffff8880a0143280)
The buggy address belongs to the page:
page:ffffea0002805000 count:1 mapcount:0 mapping:ffff88812c3d5080 index:0x0 compound_mapcount: 0
flags: 0xfffe0000008100(slab|head)
raw: 00fffe0000008100 ffffea0002510908 ffffea0002378a08 ffff88812c3d5080
raw: 0000000000000000 ffff8880a0141280 0000000100000001 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
 ffff8880a0142180: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff8880a0142200: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff8880a0142280: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                                                       ^
 ffff8880a0142300: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff8880a0142380: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================

Crashes (12):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2020/03/27 19:38 linux-4.19.y 54b4fa6d3955 831e9a81 .config console log report syz C ci2-linux-4-19
2020/01/12 01:08 linux-4.19.y cb1f9a169a0e 4c04afaa .config console log report syz C ci2-linux-4-19
2020/07/28 11:58 linux-4.19.y 20b3a3dfdf6c cb93dc6a .config console log report ci2-linux-4-19
2020/05/26 09:32 linux-4.19.y 1bab61d3e8cd 8ca3b7d2 .config console log report ci2-linux-4-19
2020/05/04 18:16 linux-4.19.y fdc072324f3c 58ae5e18 .config console log report ci2-linux-4-19
2020/04/17 19:30 linux-4.19.y 8488c3f3bc86 18397578 .config console log report ci2-linux-4-19
2020/04/02 12:36 linux-4.19.y 54b4fa6d3955 a34e2c33 .config console log report ci2-linux-4-19
2020/04/01 04:51 linux-4.19.y 54b4fa6d3955 a34e2c33 .config console log report ci2-linux-4-19
2020/03/20 12:24 linux-4.19.y 14cfdbd39e31 2c31c529 .config console log report ci2-linux-4-19
2020/03/20 07:03 linux-4.19.y 93556fb211fa 2c31c529 .config console log report ci2-linux-4-19
2020/03/20 03:46 linux-4.19.y 93556fb211fa 2c31c529 .config console log report ci2-linux-4-19
2020/03/02 14:27 linux-4.19.y a083db76118d 4a4e0509 .config console log report ci2-linux-4-19
* Struck through repros no longer work on HEAD.