syzbot


KASAN: use-after-free Read in hardware_disable

Status: fixed on 2022/02/25 18:09
Reported-by: syzbot+b244ff9edf83997425fa@syzkaller.appspotmail.com
Fix commit: 080dbe7e9b86 KVM: x86: Forcibly leave nested virt when SMM state is toggled
First crash: 1035d, last: 1032d
Cause bisection: failed (error log, bisect log)
  
Fix bisection: fixed by (bisect log) :
commit 080dbe7e9b86a0392d8dffc00d9971792afc121f
Author: Sean Christopherson <seanjc@google.com>
Date: Tue Jan 25 22:03:58 2022 +0000

  KVM: x86: Forcibly leave nested virt when SMM state is toggled

  
Last patch testing requests (1)
Created Duration User Patch Repo Result
2022/02/01 23:16 18m tadeusz.struk@linaro.org patch https://android.googlesource.com/kernel/common 6aa9e78d6e98 OK

Sample crash report:
RDX: 0000000000000000 RSI: 0000000000000080 RDI: 00007fdcd6dad408
RBP: 00007fdcd6dad400 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 00007fdcd6dad40c
R13: 00007fdcd6d7a0b8 R14: 6d766b2f7665642f R15: 0000000000022000
---[ end trace 2295e30337d94a30 ]---
==================================================================
BUG: KASAN: use-after-free in vmclear_local_loaded_vmcss arch/x86/kvm/vmx/vmx.c:2322 [inline]
BUG: KASAN: use-after-free in hardware_disable+0x10f/0x250 arch/x86/kvm/vmx/vmx.c:2341
Read of size 8 at addr ffff88810eb028f8 by task syz-executor686/722

CPU: 0 PID: 722 Comm: syz-executor686 Tainted: G        W         5.10.93-syzkaller-01028-g0347b1658399 #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_lvl+0x1e2/0x24b lib/dump_stack.c:118
 print_address_description+0x8d/0x3d0 mm/kasan/report.c:233
 __kasan_report+0x142/0x220 mm/kasan/report.c:419
 kasan_report+0x51/0x70 mm/kasan/report.c:436
 __asan_report_load8_noabort+0x14/0x20 mm/kasan/report_generic.c:309
 vmclear_local_loaded_vmcss arch/x86/kvm/vmx/vmx.c:2322 [inline]
 hardware_disable+0x10f/0x250 arch/x86/kvm/vmx/vmx.c:2341
 kvm_arch_hardware_disable+0x16/0xe0 arch/x86/kvm/x86.c:10306
 hardware_disable_nolock+0x77/0x80 arch/x86/kvm/../../../virt/kvm/kvm_main.c:4119
 on_each_cpu+0x117/0x1a0 kernel/smp.c:839
 hardware_disable_all_nolock arch/x86/kvm/../../../virt/kvm/kvm_main.c:4137 [inline]
 hardware_disable_all arch/x86/kvm/../../../virt/kvm/kvm_main.c:4143 [inline]
 kvm_destroy_vm arch/x86/kvm/../../../virt/kvm/kvm_main.c:897 [inline]
 kvm_put_kvm+0xf72/0x10a0 arch/x86/kvm/../../../virt/kvm/kvm_main.c:910
 kvm_vm_release+0x46/0x50 arch/x86/kvm/../../../virt/kvm/kvm_main.c:933
 __fput+0x348/0x7d0 fs/file_table.c:281
 ____fput+0x15/0x20 fs/file_table.c:314
 task_work_run+0x147/0x1b0 kernel/task_work.c:154
 exit_task_work include/linux/task_work.h:30 [inline]
 do_exit+0x70e/0x23a0 kernel/exit.c:813
 do_group_exit+0x16a/0x2d0 kernel/exit.c:910
 get_signal+0x131f/0x1f70 kernel/signal.c:2780
 arch_do_signal+0x8d/0x620 arch/x86/kernel/signal.c:805
 exit_to_user_mode_loop kernel/entry/common.c:161 [inline]
 exit_to_user_mode_prepare+0xaa/0xe0 kernel/entry/common.c:191
 syscall_exit_to_user_mode+0x24/0x40 kernel/entry/common.c:266
 do_syscall_64+0x3d/0x70 arch/x86/entry/common.c:56
 entry_SYSCALL_64_after_hwframe+0x44/0xa9
RIP: 0033:0x7fdcd6d24729
Code: Unable to access opcode bytes at RIP 0x7fdcd6d246ff.
RSP: 002b:00007fdcd6cd4308 EFLAGS: 00000246 ORIG_RAX: 00000000000000ca
RAX: fffffffffffffe00 RBX: 00007fdcd6dad408 RCX: 00007fdcd6d24729
RDX: 0000000000000000 RSI: 0000000000000080 RDI: 00007fdcd6dad408
RBP: 00007fdcd6dad400 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 00007fdcd6dad40c
R13: 00007fdcd6d7a0b8 R14: 6d766b2f7665642f R15: 0000000000022000

Allocated by task 722:
 kasan_save_stack mm/kasan/common.c:38 [inline]
 kasan_set_track mm/kasan/common.c:46 [inline]
 set_alloc_info mm/kasan/common.c:428 [inline]
 __kasan_slab_alloc+0xb2/0xe0 mm/kasan/common.c:461
 kasan_slab_alloc include/linux/kasan.h:259 [inline]
 slab_post_alloc_hook mm/slab.h:583 [inline]
 slab_alloc_node mm/slub.c:2954 [inline]
 slab_alloc mm/slub.c:2962 [inline]
 kmem_cache_alloc+0x1a2/0x380 mm/slub.c:2967
 kmem_cache_zalloc include/linux/slab.h:654 [inline]
 kvm_vm_ioctl_create_vcpu arch/x86/kvm/../../../virt/kvm/kvm_main.c:3158 [inline]
 kvm_vm_ioctl+0xd78/0x1fa0 arch/x86/kvm/../../../virt/kvm/kvm_main.c:3735
 vfs_ioctl fs/ioctl.c:48 [inline]
 __do_sys_ioctl fs/ioctl.c:753 [inline]
 __se_sys_ioctl+0x115/0x190 fs/ioctl.c:739
 __x64_sys_ioctl+0x7b/0x90 fs/ioctl.c:739
 do_syscall_64+0x31/0x70 arch/x86/entry/common.c:46
 entry_SYSCALL_64_after_hwframe+0x44/0xa9

Freed by task 722:
 kasan_save_stack mm/kasan/common.c:38 [inline]
 kasan_set_track+0x4c/0x80 mm/kasan/common.c:46
 kasan_set_free_info+0x23/0x40 mm/kasan/generic.c:357
 ____kasan_slab_free+0x133/0x170 mm/kasan/common.c:360
 __kasan_slab_free+0x11/0x20 mm/kasan/common.c:368
 kasan_slab_free include/linux/kasan.h:235 [inline]
 slab_free_hook mm/slub.c:1602 [inline]
 slab_free_freelist_hook+0xcc/0x1a0 mm/slub.c:1628
 slab_free mm/slub.c:3210 [inline]
 kmem_cache_free+0xb5/0x1f0 mm/slub.c:3226
 kvm_vcpu_destroy+0x7e/0xb0 arch/x86/kvm/../../../virt/kvm/kvm_main.c:428
 kvm_free_vcpus arch/x86/kvm/x86.c:10470 [inline]
 kvm_arch_destroy_vm+0x40f/0x6c0 arch/x86/kvm/x86.c:10565
 kvm_destroy_vm arch/x86/kvm/../../../virt/kvm/kvm_main.c:889 [inline]
 kvm_put_kvm+0x95a/0x10a0 arch/x86/kvm/../../../virt/kvm/kvm_main.c:910
 kvm_vm_release+0x46/0x50 arch/x86/kvm/../../../virt/kvm/kvm_main.c:933
 __fput+0x348/0x7d0 fs/file_table.c:281
 ____fput+0x15/0x20 fs/file_table.c:314
 task_work_run+0x147/0x1b0 kernel/task_work.c:154
 exit_task_work include/linux/task_work.h:30 [inline]
 do_exit+0x70e/0x23a0 kernel/exit.c:813
 do_group_exit+0x16a/0x2d0 kernel/exit.c:910
 get_signal+0x131f/0x1f70 kernel/signal.c:2780
 arch_do_signal+0x8d/0x620 arch/x86/kernel/signal.c:805
 exit_to_user_mode_loop kernel/entry/common.c:161 [inline]
 exit_to_user_mode_prepare+0xaa/0xe0 kernel/entry/common.c:191
 syscall_exit_to_user_mode+0x24/0x40 kernel/entry/common.c:266
 do_syscall_64+0x3d/0x70 arch/x86/entry/common.c:56
 entry_SYSCALL_64_after_hwframe+0x44/0xa9

The buggy address belongs to the object at ffff88810eb00000
 which belongs to the cache kvm_vcpu of size 11328
The buggy address is located 10488 bytes inside of
 11328-byte region [ffff88810eb00000, ffff88810eb02c40)
The buggy address belongs to the page:
page:ffffea00043ac000 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x10eb00
head:ffffea00043ac000 order:2 compound_mapcount:0 compound_pincount:0
flags: 0x8000000000010200(slab|head)
raw: 8000000000010200 dead000000000100 dead000000000122 ffff8881047b4480
raw: 0000000000000000 0000000080010001 00000001ffffffff 0000000000000000
page dumped because: kasan: bad access detected
page_owner tracks the page as allocated
page last allocated via order 2, migratetype Unmovable, gfp_mask 0x52cc0(GFP_KERNEL|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP), pid 722, ts 46910148457, free_ts 46760683630
 set_page_owner include/linux/page_owner.h:35 [inline]
 post_alloc_hook mm/page_alloc.c:2385 [inline]
 prep_new_page mm/page_alloc.c:2391 [inline]
 get_page_from_freelist+0xa74/0xa90 mm/page_alloc.c:4063
 __alloc_pages_nodemask+0x3c8/0x820 mm/page_alloc.c:5106
 alloc_slab_page mm/slub.c:1813 [inline]
 allocate_slab+0x6b/0x350 mm/slub.c:1815
 new_slab mm/slub.c:1876 [inline]
 new_slab_objects mm/slub.c:2635 [inline]
 ___slab_alloc+0x143/0x2f0 mm/slub.c:2798
 __slab_alloc mm/slub.c:2838 [inline]
 slab_alloc_node mm/slub.c:2920 [inline]
 slab_alloc mm/slub.c:2962 [inline]
 kmem_cache_alloc+0x26f/0x380 mm/slub.c:2967
 kmem_cache_zalloc include/linux/slab.h:654 [inline]
 kvm_vm_ioctl_create_vcpu arch/x86/kvm/../../../virt/kvm/kvm_main.c:3158 [inline]
 kvm_vm_ioctl+0xd78/0x1fa0 arch/x86/kvm/../../../virt/kvm/kvm_main.c:3735
 vfs_ioctl fs/ioctl.c:48 [inline]
 __do_sys_ioctl fs/ioctl.c:753 [inline]
 __se_sys_ioctl+0x115/0x190 fs/ioctl.c:739
 __x64_sys_ioctl+0x7b/0x90 fs/ioctl.c:739
 do_syscall_64+0x31/0x70 arch/x86/entry/common.c:46
 entry_SYSCALL_64_after_hwframe+0x44/0xa9
page last free stack trace:
 reset_page_owner include/linux/page_owner.h:28 [inline]
 free_pages_prepare mm/page_alloc.c:1331 [inline]
 __free_pages_ok+0xbe7/0xc20 mm/page_alloc.c:1611
 free_the_page mm/page_alloc.c:5167 [inline]
 __free_pages+0x2d6/0x4a0 mm/page_alloc.c:5173
 __free_slab+0xdf/0x1a0 mm/slub.c:1901
 free_slab mm/slub.c:1916 [inline]
 discard_slab mm/slub.c:1922 [inline]
 unfreeze_partials+0x17d/0x1b0 mm/slub.c:2416
 put_cpu_partial+0xc8/0x190 mm/slub.c:2452
 __slab_free+0x2eb/0x4e0 mm/slub.c:3102
 do_slab_free mm/slub.c:3198 [inline]
 ___cache_free+0x131/0x150 mm/slub.c:3217
 qlink_free+0x38/0x40 mm/kasan/quarantine.c:146
 qlist_free_all mm/kasan/quarantine.c:165 [inline]
 kasan_quarantine_reduce+0x178/0x1d0 mm/kasan/quarantine.c:272
 __kasan_slab_alloc+0x2f/0xe0 mm/kasan/common.c:438
 kasan_slab_alloc include/linux/kasan.h:259 [inline]
 slab_post_alloc_hook mm/slab.h:583 [inline]
 slab_alloc_node mm/slub.c:2954 [inline]
 slab_alloc mm/slub.c:2962 [inline]
 kmem_cache_alloc+0x1a2/0x380 mm/slub.c:2967
 getname_flags+0xba/0x650 fs/namei.c:141
 user_path_at_empty+0x2d/0x50 fs/namei.c:2726
 user_path_at include/linux/namei.h:59 [inline]
 do_utimes_path fs/utimes.c:93 [inline]
 do_utimes+0x116/0x260 fs/utimes.c:143
 __do_sys_utimensat fs/utimes.c:162 [inline]
 __se_sys_utimensat fs/utimes.c:146 [inline]
 __x64_sys_utimensat+0x150/0x250 fs/utimes.c:146
 do_syscall_64+0x31/0x70 arch/x86/entry/common.c:46

Memory state around the buggy address:
 ffff88810eb02780: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff88810eb02800: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff88810eb02880: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                                                                ^
 ffff88810eb02900: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff88810eb02980: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================

Crashes (5):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2022/01/22 19:00 android12-5.10-lts 0347b1658399 214351e1 .config console log report syz C ci2-android-5-10 KASAN: use-after-free Read in hardware_disable
2022/01/22 13:56 android12-5.10-lts 0347b1658399 214351e1 .config console log report syz C ci2-android-5-10 KASAN: use-after-free Read in hardware_disable
2022/01/26 00:30 android12-5.10-lts 0347b1658399 2cbffd88 .config console log report info ci2-android-5-10 KASAN: use-after-free Read in hardware_disable
2022/01/25 17:58 android12-5.10-lts 0347b1658399 2cbffd88 .config console log report info ci2-android-5-10 KASAN: use-after-free Read in hardware_disable
2022/01/23 06:21 android12-5.10-lts 0347b1658399 214351e1 .config console log report info ci2-android-5-10 KASAN: use-after-free Read in hardware_disable
* Struck through repros no longer work on HEAD.