Re: [syzbot] [kvm?] WARNING in __load_segment_descriptor

From: Sean Christopherson
Date: Thu Jul 13 2023 - 11:58:09 EST


On Wed, Jul 12, 2023, syzbot wrote:
> Hello,
>
> syzbot found the following issue on:
>
> HEAD commit: 1c7873e33645 mm: lock newly mapped VMA with corrected orde..
> git tree: upstream
> console+strace: https://syzkaller.appspot.com/x/log.txt?x=106f1664a80000
> kernel config: https://syzkaller.appspot.com/x/.config?x=7ad417033279f15a
> dashboard link: https://syzkaller.appspot.com/bug?extid=5234e75fb68b86fe89e3
> compiler: gcc (Debian 10.2.1-6) 10.2.1 20210110, GNU ld (GNU Binutils for Debian) 2.35.2
> syz repro: https://syzkaller.appspot.com/x/repro.syz?x=146864a8a80000
> C reproducer: https://syzkaller.appspot.com/x/repro.c?x=134a32bca80000
>
> Downloadable assets:
> disk image: https://storage.googleapis.com/syzbot-assets/7eb52a4d9cf3/disk-1c7873e3.raw.xz
> vmlinux: https://storage.googleapis.com/syzbot-assets/b9aa9a9e09e8/vmlinux-1c7873e3.xz
> kernel image: https://storage.googleapis.com/syzbot-assets/782d5e4196e2/bzImage-1c7873e3.xz
>
> The issue was bisected to:
>
> commit 65966aaca18a5cbf42ac22234cb9cbbf60a4d33c
> Author: Sean Christopherson <seanjc@xxxxxxxxxx>
> Date: Thu Feb 16 20:22:54 2023 +0000
>
> KVM: x86: Assert that the emulator doesn't load CS with garbage in !RM
>
> bisection log: https://syzkaller.appspot.com/x/bisect.txt?x=16c70f4ca80000
> final oops: https://syzkaller.appspot.com/x/report.txt?x=15c70f4ca80000
> console output: https://syzkaller.appspot.com/x/log.txt?x=11c70f4ca80000
>
> IMPORTANT: if you fix the issue, please add the following tag to the commit:
> Reported-by: syzbot+5234e75fb68b86fe89e3@xxxxxxxxxxxxxxxxxxxxxxxxx
> Fixes: 65966aaca18a ("KVM: x86: Assert that the emulator doesn't load CS with garbage in !RM")
>
> kvm_intel: set kvm_intel.dump_invalid_vmcs=1 to dump internal KVM state.
> ------------[ cut here ]------------
> WARNING: CPU: 0 PID: 5022 at arch/x86/kvm/emulate.c:1648 __load_segment_descriptor+0xf89/0x1200 arch/x86/kvm/emulate.c:1648

This is the caused by the bug where KVM doesn't check the incoming CR0 provided
by userspace via KVM_SET_SREGS, and ultimately ends up with KVM being confused
about whether the vCPU is in Real Mode. The new WARN is just the messenger, i.e.
detects that KVM is confused.

#syz dup: WARNING in kvm_arch_vcpu_ioctl_run (5)