syzbot


KASAN: use-after-free Write in sco_chan_del

Status: fixed on 2021/01/04 20:45
Reported-by: syzbot+4de628651a6b3eee15ed@syzkaller.appspotmail.com
Fix commit: abae100355c0 Bluetooth: Fix null pointer dereference in hci_event_packet()
First crash: 1571d, last: 1447d
Fix bisection: fixed by (bisect log) :
commit abae100355c011d14c75cabbf9eb773c231187ee
Author: Anmol Karn <anmol.karan123@gmail.com>
Date: Wed Sep 30 14:18:13 2020 +0000

  Bluetooth: Fix null pointer dereference in hci_event_packet()

  
Similar bugs (1)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
upstream KASAN: use-after-free Write in sco_chan_del bluetooth C done 29 1563d 1571d 0/28 closed as dup on 2020/08/18 06:37
Fix bisection attempts (5)
Created Duration User Patch Repo Result
2021/01/04 00:00 3h24m bisect fix linux-4.19.y OK (1) job log
2020/12/04 23:09 25m bisect fix linux-4.19.y OK (0) job log log
2020/11/04 20:14 23m bisect fix linux-4.19.y OK (0) job log log
2020/10/05 19:39 25m bisect fix linux-4.19.y OK (0) job log log
2020/09/05 19:10 28m bisect fix linux-4.19.y OK (0) job log log

Sample crash report:
==================================================================
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 ffff88809710a910 by task syz-executor338/8495

CPU: 0 PID: 8495 Comm: syz-executor338 Not tainted 4.19.137-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:0x446eb9
Code: Bad RIP value.
RSP: 002b:00007ffc5cc6a1c8 EFLAGS: 00000246 ORIG_RAX: 000000000000002a
RAX: fffffffffffffffc RBX: 0000000000000003 RCX: 0000000000446eb9
RDX: 0000000000000008 RSI: 00000000200000c0 RDI: 0000000000000004
RBP: 000000000000b778 R08: 0000000000000002 R09: 00000000000400ff
R10: 0000000000000004 R11: 0000000000000246 R12: 0000000000000000
R13: 0000000000407b10 R14: 0000000000000000 R15: 0000000000000000

Allocated by task 8495:
 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 6645:
 __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:4680
 hci_event_packet+0x1973/0x858f net/bluetooth/hci_event.c:5910
 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 ffff88809710a900
 which belongs to the cache kmalloc-4096 of size 4096
The buggy address is located 16 bytes inside of
 4096-byte region [ffff88809710a900, ffff88809710b900)
The buggy address belongs to the page:
page:ffffea00025c4280 count:1 mapcount:0 mapping:ffff88812c39cdc0 index:0x0 compound_mapcount: 0
Bluetooth: hci1: command 0x0405 tx timeout
flags: 0xfffe0000008100(slab|head)
raw: 00fffe0000008100 ffffea00021d1f88 ffffea00025c4f88 ffff88812c39cdc0
raw: 0000000000000000 ffff88809710a900 0000000100000001 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
 ffff88809710a800: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
 ffff88809710a880: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
>ffff88809710a900: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                         ^
 ffff88809710a980: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff88809710aa00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================

Crashes (10):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2020/08/06 18:57 linux-4.19.y c076c79e03c6 4ca1c0ea .config console log report syz C ci2-linux-4-19
2020/08/06 16:46 linux-4.19.y c076c79e03c6 4ca1c0ea .config console log report syz C ci2-linux-4-19
2020/08/06 08:45 linux-4.19.y c076c79e03c6 0487ea6f .config console log report syz C ci2-linux-4-19
2020/08/06 08:14 linux-4.19.y c076c79e03c6 0487ea6f .config console log report syz C ci2-linux-4-19
2020/08/05 13:48 linux-4.19.y c076c79e03c6 b7129355 .config console log report syz C ci2-linux-4-19
2020/08/05 12:48 linux-4.19.y c076c79e03c6 b7129355 .config console log report syz C ci2-linux-4-19
2020/08/04 05:50 linux-4.19.y 13af6c74b14a 96dd3623 .config console log report syz C ci2-linux-4-19
2020/08/03 20:12 linux-4.19.y 13af6c74b14a 96dd3623 .config console log report syz C ci2-linux-4-19
2020/08/03 19:11 linux-4.19.y 13af6c74b14a 96dd3623 .config console log report syz C ci2-linux-4-19
2020/08/03 00:43 linux-4.19.y 13af6c74b14a 96dd3623 .config console log report syz C ci2-linux-4-19
* Struck through repros no longer work on HEAD.