syzbot


KASAN: use-after-free Write in ex_handler_refcount

Status: fixed on 2020/10/02 13:00
Reported-by: syzbot+9c84cc6d4604e4deaa1c@syzkaller.appspotmail.com
Fix commit: 29e1dfcd5150 Bluetooth: add a mutex lock to avoid UAF in do_enale_set
First crash: 872d, last: 664d

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 (5):
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
linux-4.14 KASAN: use-after-free Write in ex_handler_refcount (2) 1 627d 627d 0/1 auto-closed as invalid on 2021/02/06 10:12
linux-4.14 KASAN: use-after-free Write in ex_handler_refcount C done 16 664d 873d 1/1 fixed on 2020/10/03 03:40
android-54 KASAN: use-after-free Write in ex_handler_refcount syz 4 666d 668d 0/2 upstream: reported syz repro on 2020/08/29 07:49
linux-4.14 KASAN: use-after-free Write in ex_handler_refcount (3) C 32 5d06h 492d 0/1 upstream: reported C repro on 2021/02/20 19:09
linux-4.19 KASAN: use-after-free Write in ex_handler_refcount (2) C error 32 5d06h 455d 0/1 upstream: reported C repro on 2021/03/29 13:41

Sample crash report:
==================================================================
BUG: KASAN: use-after-free in ex_handler_refcount+0x18f/0x1c0 arch/x86/mm/extable.c:49
Write of size 4 at addr ffff8880a0df36d8 by task kworker/1:2/2884

CPU: 1 PID: 2884 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_store4_noabort+0x88/0x90 mm/kasan/report.c:437
 ex_handler_refcount+0x18f/0x1c0 arch/x86/mm/extable.c:49
 fixup_exception+0x8a/0xc3 arch/x86/mm/extable.c:197
 do_trap_no_signal arch/x86/kernel/traps.c:209 [inline]
 do_trap+0x61/0x250 arch/x86/kernel/traps.c:258
 do_error_trap+0x15d/0x310 arch/x86/kernel/traps.c:303
 invalid_op+0x14/0x20 arch/x86/entry/entry_64.S:1038
RIP: 0010:csum_partial_copy_generic+0x607f/0x7811
Code: 49 8d 8c 24 80 00 00 00 0f 0b 48 8d 8d 80 00 00 00 0f 0b 48 8d 8d 80 00 00 00 0f 0b 49 8d 8c 24 b8 02 00 00 0f 0b 48 8d 4d 18 <0f> 0b 48 8d 8d b8 02 00 00 0f 0b 48 8d 4b 18 0f 0b 48 8d 8d 80 00
RSP: 0018:ffff88809e1afc20 EFLAGS: 00010297
RAX: ffff88809e198380 RBX: 0000000000000001 RCX: ffff8880a0df36d8
RDX: 0000000000000000 RSI: ffffffff868150d0 RDI: ffff8880a0df36c0
RBP: ffff8880a0df36c0 R08: 0000000000000000 R09: 0000000000000008
R10: 0000000000000001 R11: 0000000000000000 R12: ffff8880ae72bb10
R13: ffff88809e07f800 R14: ffff8880ae72bac0 R15: ffff8880a7d77280
 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

Allocated by task 6414:
 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 6414:
 __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 ffff8880a0df36c0
 which belongs to the cache kmalloc-2048 of size 2048
The buggy address is located 24 bytes inside of
 2048-byte region [ffff8880a0df36c0, ffff8880a0df3ec0)
The buggy address belongs to the page:
page:ffffea0002837c80 count:1 mapcount:0 mapping:ffff88812c39cc40 index:0x0 compound_mapcount: 0
flags: 0xfffe0000008100(slab|head)
raw: 00fffe0000008100 ffffea0002831008 ffffea000282e288 ffff88812c39cc40
raw: 0000000000000000 ffff8880a0df25c0 0000000100000003 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
 ffff8880a0df3580: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff8880a0df3600: fb fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc
>ffff8880a0df3680: fc fc fc fc fc fc fc fc fb fb fb fb fb fb fb fb
                                                    ^
 ffff8880a0df3700: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff8880a0df3780: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================

Crashes (11):
Manager Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Title
ci2-linux-4-19 2020/08/06 18:03 linux-4.19.y c076c79e03c6 4ca1c0ea .config log report syz C
ci2-linux-4-19 2020/08/06 15:31 linux-4.19.y c076c79e03c6 4ca1c0ea .config log report syz C
ci2-linux-4-19 2020/08/06 06:09 linux-4.19.y c076c79e03c6 0487ea6f .config log report syz C
ci2-linux-4-19 2020/08/05 02:51 linux-4.19.y 13af6c74b14a 02034dac .config log report syz C
ci2-linux-4-19 2020/04/15 06:30 linux-4.19.y 6dd0e32665e5 3f3c5574 .config log report syz C
ci2-linux-4-19 2020/02/28 14:12 linux-4.19.y f25804f38984 c88c7b75 .config log report syz C
ci2-linux-4-19 2020/08/31 16:22 linux-4.19.y f6d5cb9e2c06 d5a3ae1f .config log report syz
ci2-linux-4-19 2020/09/02 08:11 linux-4.19.y f6d5cb9e2c06 abf9ba4f .config log report
ci2-linux-4-19 2020/08/19 00:41 linux-4.19.y c14d30dc9987 e1c29030 .config log report
ci2-linux-4-19 2020/06/22 02:56 linux-4.19.y 3fc898571b97 eabcced4 .config log report
ci2-linux-4-19 2020/02/06 16:31 linux-4.19.y b499cf4b3a90 5be3a391 .config log report