syzbot


KASAN: use-after-free Read in kvm_write_guest_offset_cached

Status: auto-obsoleted due to no activity on 2022/09/01 23:22
Reported-by: syzbot+ff40b9bc4835ea83211c@syzkaller.appspotmail.com
First crash: 1406d, last: 1399d

Cause bisection: failed (bisect log)

Fix bisection: fixed by (bisect log) [no-op commit]:
commit 98af8452945c55652de68536afdde3b520fec429
Author: Josh Poimboeuf <jpoimboe@redhat.com>
Date: Fri Apr 12 20:39:28 2019 +0000

  cpu/speculation: Add 'mitigations=' cmdline option

Patch testing requests:
Created Duration User Patch Repo Result
2022/09/01 20:27 13m upstream OK log
2022/08/31 10:27 14m linux-next OK log

Sample crash report:
==================================================================
BUG: KASAN: use-after-free in mark_page_dirty_in_slot arch/x86/kvm/../../../virt/kvm/kvm_main.c:2056 [inline]
BUG: KASAN: use-after-free in kvm_write_guest_offset_cached+0x693/0x6b0 arch/x86/kvm/../../../virt/kvm/kvm_main.c:1988
Read of size 8 at addr ffff8881b4302460 by task syz-executor3/2896

CPU: 1 PID: 2896 Comm: syz-executor3 Not tainted 4.20.0-rc4+ #351
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+0x244/0x39d lib/dump_stack.c:113
 print_address_description.cold.7+0x9/0x1ff mm/kasan/report.c:256
 kasan_report_error mm/kasan/report.c:354 [inline]
 kasan_report.cold.8+0x242/0x309 mm/kasan/report.c:412
 __asan_report_load8_noabort+0x14/0x20 mm/kasan/report.c:433
 mark_page_dirty_in_slot arch/x86/kvm/../../../virt/kvm/kvm_main.c:2056 [inline]
 kvm_write_guest_offset_cached+0x693/0x6b0 arch/x86/kvm/../../../virt/kvm/kvm_main.c:1988
 kvm_steal_time_set_preempted arch/x86/kvm/x86.c:3241 [inline]
 kvm_arch_vcpu_put+0x365/0x420 arch/x86/kvm/x86.c:3268
 kvm_sched_out+0x91/0xb0 arch/x86/kvm/../../../virt/kvm/kvm_main.c:3993
 __fire_sched_out_preempt_notifiers kernel/sched/core.c:2503 [inline]
 fire_sched_out_preempt_notifiers kernel/sched/core.c:2511 [inline]
 prepare_task_switch kernel/sched/core.c:2617 [inline]
 context_switch kernel/sched/core.c:2796 [inline]
 __schedule+0x103d/0x21d0 kernel/sched/core.c:3472
 preempt_schedule_irq+0xb9/0x140 kernel/sched/core.c:3699
 retint_kernel+0x1b/0x2d
RIP: 0010:search_memslots include/linux/kvm_host.h:956 [inline]
RIP: 0010:__gfn_to_memslot include/linux/kvm_host.h:976 [inline]
RIP: 0010:__kvm_gfn_to_hva_cache_init+0x306/0xd10 arch/x86/kvm/../../../virt/kvm/kvm_main.c:1935
Code: 4c 39 eb 0f 82 6e 01 00 00 45 31 ed e8 f3 f3 77 00 44 89 fe 44 89 ef e8 78 f4 77 00 45 39 fd 0f 8d cf 00 00 00 e8 da f3 77 00 <44> 89 f8 48 b9 00 00 00 00 00 fc ff df 44 29 e8 41 89 c4 41 c1 ec
RSP: 0018:ffff8881d8f4e970 EFLAGS: 00000293 ORIG_RAX: ffffffffffffff13
RAX: ffff8881b800a0c0 RBX: 0000000000000000 RCX: ffffffff81079718
RDX: 0000000000000000 RSI: ffffffff81079726 RDI: 0000000000000004
RBP: ffff8881d8f4eb60 R08: ffff8881b800a0c0 R09: ffffed1033a0dfc9
R10: ffffed1033a0dfc9 R11: ffff88819d06fe4b R12: ffff88819d064e10
R13: 0000000000000000 R14: ffff88819d06fe48 R15: 0000000000000018
 kvm_gfn_to_hva_cache_init+0x15a/0x340 arch/x86/kvm/../../../virt/kvm/kvm_main.c:1963
 kvm_set_msr_common+0x1a0c/0x2670 arch/x86/kvm/x86.c:2549
 vmx_set_msr+0x75e/0x1fa0 arch/x86/kvm/vmx.c:4360
 kvm_set_msr+0x18a/0x370 arch/x86/kvm/x86.c:1324
 do_set_msr+0x10d/0x1a0 arch/x86/kvm/x86.c:1353
 __msr_io arch/x86/kvm/x86.c:2905 [inline]
 msr_io+0x222/0x380 arch/x86/kvm/x86.c:2941
 kvm_arch_vcpu_ioctl+0x966/0x3b10 arch/x86/kvm/x86.c:3956
 kvm_vcpu_ioctl+0x278/0x1150 arch/x86/kvm/../../../virt/kvm/kvm_main.c:2748
 vfs_ioctl fs/ioctl.c:46 [inline]
 file_ioctl fs/ioctl.c:509 [inline]
 do_vfs_ioctl+0x1de/0x1790 fs/ioctl.c:696
 ksys_ioctl+0xa9/0xd0 fs/ioctl.c:713
 __do_sys_ioctl fs/ioctl.c:720 [inline]
 __se_sys_ioctl fs/ioctl.c:718 [inline]
 __x64_sys_ioctl+0x73/0xb0 fs/ioctl.c:718
 do_syscall_64+0x1b9/0x820 arch/x86/entry/common.c:290
 entry_SYSCALL_64_after_hwframe+0x49/0xbe
RIP: 0033:0x457569
Code: fd b3 fb ff c3 66 2e 0f 1f 84 00 00 00 00 00 66 90 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 cb b3 fb ff c3 66 2e 0f 1f 84 00 00 00 00
RSP: 002b:00007f467a947c78 EFLAGS: 00000246 ORIG_RAX: 0000000000000010
RAX: ffffffffffffffda RBX: 0000000000000003 RCX: 0000000000457569
RDX: 0000000020000280 RSI: 000000004008ae89 RDI: 0000000000000005
RBP: 000000000072bfa0 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 00007f467a9486d4
R13: 00000000004bff9d R14: 00000000004d0970 R15: 00000000ffffffff

Allocated by task 2884:
 save_stack+0x43/0xd0 mm/kasan/kasan.c:448
 set_track mm/kasan/kasan.c:460 [inline]
 kasan_kmalloc+0xc7/0xe0 mm/kasan/kasan.c:553
 __do_kmalloc_node mm/slab.c:3684 [inline]
 __kmalloc_node+0x50/0x70 mm/slab.c:3691
 kmalloc_node include/linux/slab.h:589 [inline]
 kvmalloc_node+0xb9/0xf0 mm/util.c:416
 kvmalloc include/linux/mm.h:577 [inline]
 kvzalloc include/linux/mm.h:585 [inline]
 __kvm_set_memory_region+0x116e/0x2d50 arch/x86/kvm/../../../virt/kvm/kvm_main.c:1023
 kvm_set_memory_region+0x2e/0x50 arch/x86/kvm/../../../virt/kvm/kvm_main.c:1085
 kvm_vm_ioctl_set_memory_region arch/x86/kvm/../../../virt/kvm/kvm_main.c:1097 [inline]
 kvm_vm_ioctl+0x652/0x1d60 arch/x86/kvm/../../../virt/kvm/kvm_main.c:2995
 vfs_ioctl fs/ioctl.c:46 [inline]
 file_ioctl fs/ioctl.c:509 [inline]
 do_vfs_ioctl+0x1de/0x1790 fs/ioctl.c:696
 ksys_ioctl+0xa9/0xd0 fs/ioctl.c:713
 __do_sys_ioctl fs/ioctl.c:720 [inline]
 __se_sys_ioctl fs/ioctl.c:718 [inline]
 __x64_sys_ioctl+0x73/0xb0 fs/ioctl.c:718
 do_syscall_64+0x1b9/0x820 arch/x86/entry/common.c:290
 entry_SYSCALL_64_after_hwframe+0x49/0xbe

Freed by task 2884:
 save_stack+0x43/0xd0 mm/kasan/kasan.c:448
 set_track mm/kasan/kasan.c:460 [inline]
 __kasan_slab_free+0x102/0x150 mm/kasan/kasan.c:521
 kasan_slab_free+0xe/0x10 mm/kasan/kasan.c:528
 __cache_free mm/slab.c:3498 [inline]
 kfree+0xcf/0x230 mm/slab.c:3817
 kvfree+0x61/0x70 mm/util.c:445
 __kvm_set_memory_region+0x1cb3/0x2d50 arch/x86/kvm/../../../virt/kvm/kvm_main.c:1067
 kvm_set_memory_region+0x2e/0x50 arch/x86/kvm/../../../virt/kvm/kvm_main.c:1085
 kvm_vm_ioctl_set_memory_region arch/x86/kvm/../../../virt/kvm/kvm_main.c:1097 [inline]
 kvm_vm_ioctl+0x652/0x1d60 arch/x86/kvm/../../../virt/kvm/kvm_main.c:2995
 vfs_ioctl fs/ioctl.c:46 [inline]
 file_ioctl fs/ioctl.c:509 [inline]
 do_vfs_ioctl+0x1de/0x1790 fs/ioctl.c:696
 ksys_ioctl+0xa9/0xd0 fs/ioctl.c:713
 __do_sys_ioctl fs/ioctl.c:720 [inline]
 __se_sys_ioctl fs/ioctl.c:718 [inline]
 __x64_sys_ioctl+0x73/0xb0 fs/ioctl.c:718
 do_syscall_64+0x1b9/0x820 arch/x86/entry/common.c:290
 entry_SYSCALL_64_after_hwframe+0x49/0xbe

The buggy address belongs to the object at ffff8881b4302080
 which belongs to the cache kmalloc-64k of size 65536
The buggy address is located 992 bytes inside of
 65536-byte region [ffff8881b4302080, ffff8881b4312080)
The buggy address belongs to the page:
page:ffffea0006d0c000 count:1 mapcount:0 mapping:ffff8881da802500 index:0x0 compound_mapcount: 0
flags: 0x2fffc0000010200(slab|head)
raw: 02fffc0000010200 ffffea0006898808 ffffea00069d1808 ffff8881da802500
raw: 0000000000000000 ffff8881b4302080 0000000100000001 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
 ffff8881b4302300: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff8881b4302380: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff8881b4302400: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                                                       ^
 ffff8881b4302480: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff8881b4302500: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================

Crashes (4):
Manager Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Title
ci-upstream-kasan-gce-root 2018/11/27 08:32 upstream 6f8b52ba442c ac912200 .config log report syz
ci-upstream-linux-next-kasan-gce-root 2018/11/27 04:11 linux-next 442b8cea2477 ac912200 .config log report syz
ci-upstream-kasan-gce 2018/12/04 09:46 upstream 0072a0c14d5b 03f94a45 .config log report
ci-upstream-linux-next-kasan-gce-root 2018/11/27 02:10 linux-next 442b8cea2477 ac912200 .config log report
* Struck through repros no longer work on HEAD.