syzbot


KASAN: use-after-free Read in l2cap_chan_close

Status: fixed on 2020/09/09 05:22
Reported-by: syzbot+dc7c8ed1a29a930d7883@syzkaller.appspotmail.com
Fix commit: 29e1dfcd5150 Bluetooth: add a mutex lock to avoid UAF in do_enale_set
First crash: 1751d, last: 1569d
Fix bisection: fixed by (bisect log) :
commit 29e1dfcd5150097f32f34891c85a50d9ead19df3
Author: Lihong Kou <koulihong@huawei.com>
Date: Tue Jun 23 12:28:41 2020 +0000

  Bluetooth: add a mutex lock to avoid UAF in do_enale_set

  
Similar bugs (2)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
linux-4.14 KASAN: use-after-free Read in l2cap_chan_close C inconclusive 10 1567d 1750d 0/1 upstream: reported C repro on 2020/02/08 02:54
upstream KASAN: use-after-free Read in l2cap_chan_close C done 37 1570d 1750d 15/28 fixed on 2020/09/16 22:51
Fix bisection attempts (6)
Created Duration User Patch Repo Result
2020/09/06 06:23 3h30m bisect fix linux-4.19.y OK (1) job log
2020/07/17 04:17 34m bisect fix linux-4.19.y OK (0) job log log
2020/06/17 03:44 32m bisect fix linux-4.19.y OK (0) job log log
2020/05/06 19:26 35m bisect fix linux-4.19.y OK (0) job log log
2020/04/06 18:50 25m bisect fix linux-4.19.y OK (0) job log log
2020/03/07 18:15 34m bisect fix linux-4.19.y OK (0) job log log

Sample crash report:
==================================================================
BUG: KASAN: use-after-free in l2cap_chan_close+0x58b/0x820 net/bluetooth/l2cap_core.c:727
Read of size 1 at addr ffff8880893f03a0 by task kworker/1:2/3401

CPU: 1 PID: 3401 Comm: kworker/1:2 Not tainted 4.19.137-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
Workqueue: events do_enable_set
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_load1_noabort+0x88/0x90 mm/kasan/report.c:430
 l2cap_chan_close+0x58b/0x820 net/bluetooth/l2cap_core.c:727
 do_enable_set+0x4e3/0x975 net/bluetooth/6lowpan.c:1086
 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 2899:
 kmem_cache_alloc_trace+0x12f/0x380 mm/slab.c:3625
 kmalloc include/linux/slab.h:515 [inline]
 kzalloc include/linux/slab.h:709 [inline]
 l2cap_chan_create+0x40/0x380 net/bluetooth/l2cap_core.c:441
 chan_create net/bluetooth/6lowpan.c:652 [inline]
 bt_6lowpan_listen net/bluetooth/6lowpan.c:971 [inline]
 do_enable_set+0x525/0x975 net/bluetooth/6lowpan.c:1090
 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 2899:
 __cache_free mm/slab.c:3503 [inline]
 kfree+0xcc/0x210 mm/slab.c:3822
 l2cap_chan_destroy net/bluetooth/l2cap_core.c:479 [inline]
 kref_put include/linux/kref.h:70 [inline]
 l2cap_chan_put+0x16b/0x1c0 net/bluetooth/l2cap_core.c:493
 do_enable_set+0x4ef/0x975 net/bluetooth/6lowpan.c:1087
 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 ffff8880893f0380
 which belongs to the cache kmalloc-2048 of size 2048
The buggy address is located 32 bytes inside of
 2048-byte region [ffff8880893f0380, ffff8880893f0b80)
The buggy address belongs to the page:
page:ffffea000224fc00 count:1 mapcount:0 mapping:ffff88812c39cc40 index:0x0 compound_mapcount: 0
flags: 0xfffe0000008100(slab|head)
raw: 00fffe0000008100 ffffea000212a408 ffffea0002394188 ffff88812c39cc40
raw: 0000000000000000 ffff8880893f0380 0000000100000003 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
 ffff8880893f0280: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
 ffff8880893f0300: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
>ffff8880893f0380: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                               ^
 ffff8880893f0400: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff8880893f0480: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================

Crashes (8):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2020/08/07 06:23 linux-4.19.y c076c79e03c6 cb436c69 .config console log report syz C ci2-linux-4-19
2020/08/06 17:46 linux-4.19.y c076c79e03c6 4ca1c0ea .config console log report syz C ci2-linux-4-19
2020/08/05 03:11 linux-4.19.y 13af6c74b14a 02034dac .config console log report syz C ci2-linux-4-19
2020/08/04 06:49 linux-4.19.y 13af6c74b14a 96dd3623 .config console log report syz C ci2-linux-4-19
2020/08/02 22:01 linux-4.19.y 13af6c74b14a 96dd3623 .config console log report syz C ci2-linux-4-19
2020/05/18 03:44 linux-4.19.y 258f0cf7ac3b 37bccd4e .config console log report syz C ci2-linux-4-19
2020/02/06 18:15 linux-4.19.y b499cf4b3a90 5be3a391 .config console log report syz C ci2-linux-4-19
2020/04/06 19:26 linux-4.19.y dda0e2920330 99a96044 .config console log report ci2-linux-4-19
* Struck through repros no longer work on HEAD.