syzbot


KASAN: use-after-free Write in ex_handler_refcount

Status: fixed on 2020/10/03 03:40
Reported-by: syzbot+de475a73984b7512adb2@syzkaller.appspotmail.com
Fix commit: af7122cfbaee Bluetooth: add a mutex lock to avoid UAF in do_enale_set
First crash: 1534d, last: 1325d
Fix bisection: fixed by (bisect log) :
commit af7122cfbaeef4a854a242b43fa2fa5bb9e4eac9
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 1288d 1288d 0/1 auto-closed as invalid on 2021/02/06 10:12
android-54 KASAN: use-after-free Write in ex_handler_refcount syz 4 1327d 1329d 0/2 auto-obsoleted due to no activity on 2023/04/15 04:57
linux-4.14 KASAN: use-after-free Write in ex_handler_refcount (3) C error 49 411d 1153d 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 44 411d 1116d 0/1 upstream: reported C repro on 2021/03/29 13:41
linux-4.19 KASAN: use-after-free Write in ex_handler_refcount C done 11 1325d 1533d 1/1 fixed on 2020/10/02 13:00
Fix bisection attempts (3)
Created Duration User Patch Repo Result
2020/10/02 13:25 3h34m bisect fix linux-4.14.y job log (1)
2020/06/01 04:49 23m bisect fix linux-4.14.y job log (0) log
2020/05/02 04:24 24m bisect fix linux-4.14.y job log (0) log

Sample crash report:
audit: type=1400 audit(1596871250.327:8): avc:  denied  { execmem } for  pid=6349 comm="syz-executor744" scontext=system_u:system_r:kernel_t:s0 tcontext=system_u:system_r:kernel_t:s0 tclass=process permissive=1
==================================================================
BUG: KASAN: use-after-free in ex_handler_refcount+0x164/0x1a0 arch/x86/mm/extable.c:49
Write of size 4 at addr ffff8880974dc418 by task kworker/0:2/4112

CPU: 0 PID: 4112 Comm: kworker/0:2 Not tainted 4.14.193-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:17 [inline]
 dump_stack+0x1b2/0x283 lib/dump_stack.c:58
 print_address_description.cold+0x54/0x1d3 mm/kasan/report.c:252
 kasan_report_error.cold+0x8a/0x194 mm/kasan/report.c:351
 kasan_report mm/kasan/report.c:409 [inline]
 __asan_report_store4_noabort+0x68/0x70 mm/kasan/report.c:434
 ex_handler_refcount+0x164/0x1a0 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:208 [inline]
 do_trap+0x61/0x250 arch/x86/kernel/traps.c:257
 do_error_trap+0x132/0x2d0 arch/x86/kernel/traps.c:301
 invalid_op+0x1b/0x40 arch/x86/entry/entry_64.S:964
RIP: 0010:inat_get_avx_attribute+0x52f2/0x6a9a
RSP: 0018:ffff8880882b7c88 EFLAGS: 00010297
RAX: ffff8880882a6300 RBX: 0000000000000001 RCX: ffff8880974dc418
RDX: 0000000000000000 RSI: 0000000000000000 RDI: ffff8880974dc400
RBP: ffff8880974dc400 R08: ffffffff8a0b4450 R09: 0000000000040578
R10: ffff8880882a6bb0 R11: ffff8880882a6300 R12: ffff888097746290
R13: ffff8880a0794700 R14: ffff8880aea2ad00 R15: ffff888097746280
 do_enable_set+0x47f/0x8a0 net/bluetooth/6lowpan.c:1087
 process_one_work+0x793/0x14a0 kernel/workqueue.c:2116
 worker_thread+0x5cc/0xff0 kernel/workqueue.c:2250
 kthread+0x30d/0x420 kernel/kthread.c:232
 ret_from_fork+0x24/0x30 arch/x86/entry/entry_64.S:404

Allocated by task 18:
 save_stack mm/kasan/kasan.c:447 [inline]
 set_track mm/kasan/kasan.c:459 [inline]
 kasan_kmalloc+0xeb/0x160 mm/kasan/kasan.c:551
 kmem_cache_alloc_trace+0x131/0x3d0 mm/slab.c:3618
 kmalloc include/linux/slab.h:488 [inline]
 kzalloc include/linux/slab.h:661 [inline]
 l2cap_chan_create+0x3e/0x3c0 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+0x4ac/0x8a0 net/bluetooth/6lowpan.c:1090
 process_one_work+0x793/0x14a0 kernel/workqueue.c:2116
 worker_thread+0x5cc/0xff0 kernel/workqueue.c:2250
 kthread+0x30d/0x420 kernel/kthread.c:232
 ret_from_fork+0x24/0x30 arch/x86/entry/entry_64.S:404

Freed by task 18:
 save_stack mm/kasan/kasan.c:447 [inline]
 set_track mm/kasan/kasan.c:459 [inline]
 kasan_slab_free+0xc3/0x1a0 mm/kasan/kasan.c:524
 __cache_free mm/slab.c:3496 [inline]
 kfree+0xc9/0x250 mm/slab.c:3815
 l2cap_chan_destroy net/bluetooth/l2cap_core.c:479 [inline]
 kref_put include/linux/kref.h:70 [inline]
 l2cap_chan_put+0x152/0x1b0 net/bluetooth/l2cap_core.c:493
 do_enable_set+0x47f/0x8a0 net/bluetooth/6lowpan.c:1087
 process_one_work+0x793/0x14a0 kernel/workqueue.c:2116
 worker_thread+0x5cc/0xff0 kernel/workqueue.c:2250
 kthread+0x30d/0x420 kernel/kthread.c:232
 ret_from_fork+0x24/0x30 arch/x86/entry/entry_64.S:404

The buggy address belongs to the object at ffff8880974dc400
 which belongs to the cache kmalloc-2048 of size 2048
The buggy address is located 24 bytes inside of
 2048-byte region [ffff8880974dc400, ffff8880974dcc00)
The buggy address belongs to the page:
page:ffffea00025d3700 count:1 mapcount:0 mapping:ffff8880974dc400 index:0x0 compound_mapcount: 0
flags: 0xfffe0000008100(slab|head)
raw: 00fffe0000008100 ffff8880974dc400 0000000000000000 0000000100000003
raw: ffffea00025c2020 ffffea00021de120 ffff88812fe52c40 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
 ffff8880974dc300: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
 ffff8880974dc380: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
>ffff8880974dc400: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                            ^
 ffff8880974dc480: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff8880974dc500: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================

Crashes (16):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2020/08/08 07:22 linux-4.14.y 14b58326976d ff51e522 .config console log report syz C ci2-linux-4-14
2020/08/06 15:09 linux-4.14.y ca4f2c56d416 4ca1c0ea .config console log report syz C ci2-linux-4-14
2020/08/06 05:49 linux-4.14.y ca4f2c56d416 0487ea6f .config console log report syz C ci2-linux-4-14
2020/08/06 04:39 linux-4.14.y ca4f2c56d416 0487ea6f .config console log report syz C ci2-linux-4-14
2020/03/02 18:13 linux-4.14.y 78d697fc93f9 4a4e0509 .config console log report syz C ci2-linux-4-14
2020/03/02 16:27 linux-4.14.y 78d697fc93f9 4a4e0509 .config console log report syz C ci2-linux-4-14
2020/08/31 23:56 linux-4.14.y d7e78d08fa77 d5a3ae1f .config console log report syz ci2-linux-4-14
2020/04/02 04:24 linux-4.14.y 01364dad1d45 a34e2c33 .config console log report syz ci2-linux-4-14
2020/09/02 10:39 linux-4.14.y d7e78d08fa77 abf9ba4f .config console log report ci2-linux-4-14
2020/08/30 07:35 linux-4.14.y d7e78d08fa77 d5a3ae1f .config console log report ci2-linux-4-14
2020/08/15 16:20 linux-4.14.y 14b58326976d 5ce13532 .config console log report ci2-linux-4-14
2020/07/18 03:52 linux-4.14.y b850307b279c 9c812472 .config console log report ci2-linux-4-14
2020/06/26 12:39 linux-4.14.y b850307b279c b202c7a8 .config console log report ci2-linux-4-14
2020/03/29 18:00 linux-4.14.y 01364dad1d45 05736b29 .config console log report ci2-linux-4-14
2020/02/10 14:19 linux-4.14.y e0f8b8a65a47 35f5e45e .config console log report ci2-linux-4-14
2020/02/06 06:41 linux-4.14.y e0f8b8a65a47 662cf49a .config console log report ci2-linux-4-14
* Struck through repros no longer work on HEAD.