KASAN: use-after-free Read in hardware_disable

5 views
Skip to first unread message

syzbot

unread,
Jan 22, 2022, 8:57:27 AM1/22/22
to syzkaller-a...@googlegroups.com
Hello,

syzbot found the following issue on:

HEAD commit: 0347b1658399 Merge 5.10.93 into android12-5.10-lts
git tree: android12-5.10-lts
console output: https://syzkaller.appspot.com/x/log.txt?x=14cea167b00000
kernel config: https://syzkaller.appspot.com/x/.config?x=e0f3947457f8d2a4
dashboard link: https://syzkaller.appspot.com/bug?extid=b244ff9edf83997425fa
compiler: Debian clang version 11.0.1-2, GNU ld (GNU Binutils for Debian) 2.35.2
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=1706eac0700000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=137b6538700000

IMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by: syzbot+b244ff...@syzkaller.appspotmail.com

RBP: 00007f484792a400 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 00007f484792a40c
R13: 00007f48478f70b8 R14: 6d766b2f7665642f R15: 0000000000022000
---[ end trace 10cc9e29811cf4c6 ]---
==================================================================
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 ffff888109eda8f8 by task syz-executor313/438

CPU: 0 PID: 438 Comm: syz-executor313 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:0x7f48478a1729
Code: Unable to access opcode bytes at RIP 0x7f48478a16ff.
RSP: 002b:00007f4847851308 EFLAGS: 00000246 ORIG_RAX: 00000000000000ca
RAX: fffffffffffffe00 RBX: 00007f484792a408 RCX: 00007f48478a1729
RDX: 0000000000000000 RSI: 0000000000000080 RDI: 00007f484792a408
RBP: 00007f484792a400 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 00007f484792a40c
R13: 00007f48478f70b8 R14: 6d766b2f7665642f R15: 0000000000022000

Allocated by task 438:
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 438:
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 ffff888109ed8000
which belongs to the cache kvm_vcpu of size 11328
The buggy address is located 10488 bytes inside of
11328-byte region [ffff888109ed8000, ffff888109edac40)
The buggy address belongs to the page:
page:ffffea000427b600 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x109ed8
head:ffffea000427b600 order:2 compound_mapcount:0 compound_pincount:0
flags: 0x8000000000010200(slab|head)
raw: 8000000000010200 dead000000000100 dead000000000122 ffff8881047adc80
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 438, ts 60080653180, free_ts 60051530576
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]
vfs_statx+0x10a/0x3f0 fs/stat.c:193
vfs_fstatat fs/stat.c:215 [inline]
__do_sys_newfstatat fs/stat.c:384 [inline]
__se_sys_newfstatat+0xc8/0x760 fs/stat.c:378
__x64_sys_newfstatat+0x9b/0xb0 fs/stat.c:378

Memory state around the buggy address:
ffff888109eda780: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff888109eda800: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff888109eda880: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
^
ffff888109eda900: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff888109eda980: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================


---
This report is generated by a bot. It may contain errors.
See https://goo.gl/tpsmEJ for more information about syzbot.
syzbot engineers can be reached at syzk...@googlegroups.com.

syzbot will keep track of this issue. See:
https://goo.gl/tpsmEJ#status for how to communicate with syzbot.
syzbot can test patches for this issue, for details see:
https://goo.gl/tpsmEJ#testing-patches

syzbot

unread,
Feb 24, 2022, 9:37:08 PM2/24/22
to syzkaller-a...@googlegroups.com, tadeus...@linaro.org
syzbot suspects this issue was fixed by commit:

commit 080dbe7e9b86a0392d8dffc00d9971792afc121f
Author: Sean Christopherson <sea...@google.com>
Date: Tue Jan 25 22:03:58 2022 +0000

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

bisection log: https://syzkaller.appspot.com/x/bisect.txt?x=12d164ea700000
start commit: 0347b1658399 Merge 5.10.93 into android12-5.10-lts
git tree: android12-5.10-lts
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=12a2f13db00000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=153215d0700000

If the result looks correct, please mark the issue as fixed by replying with:

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

For information about bisection process see: https://goo.gl/tpsmEJ#bisection

Tadeusz Struk

unread,
Feb 25, 2022, 11:56:13 AM2/25/22
to syzbot, syzkaller-a...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages