Repository navigation
Commit 2187402
KVM: X86: Fix userspace set invalid CR4
commit 3ca9419 upstream.
Reported by syzkaller:
WARNING: CPU: 0 PID: 6544 at /home/kernel/data/kvm/arch/x86/kvm//vmx/vmx.c:4689 handle_desc+0x37/0x40 [kvm_intel]
CPU: 0 PID: 6544 Comm: a.out Tainted: G OE 5.3.0-rc4+ #4
RIP: 0010:handle_desc+0x37/0x40 [kvm_intel]
Call Trace:
vmx_handle_exit+0xbe/0x6b0 [kvm_intel]
vcpu_enter_guest+0x4dc/0x18d0 [kvm]
kvm_arch_vcpu_ioctl_run+0x407/0x660 [kvm]
kvm_vcpu_ioctl+0x3ad/0x690 [kvm]
do_vfs_ioctl+0xa2/0x690
ksys_ioctl+0x6d/0x80
__x64_sys_ioctl+0x1a/0x20
do_syscall_64+0x74/0x720
entry_SYSCALL_64_after_hwframe+0x49/0xbe
When CR4.UMIP is set, guest should have UMIP cpuid flag. Current
kvm set_sregs function doesn't have such check when userspace inputs
sregs values. SECONDARY_EXEC_DESC is enabled on writes to CR4.UMIP
in vmx_set_cr4 though guest doesn't have UMIP cpuid flag. The testcast
triggers handle_desc warning when executing ltr instruction since
guest architectural CR4 doesn't set UMIP. This patch fixes it by
adding valid CR4 and CPUID combination checking in __set_sregs.
syzkaller source: https://syzkaller.appspot.com/x/repro.c?x=138efb99600000
Reported-by: [email protected]
Cc: [email protected]
Signed-off-by: Wanpeng Li <[email protected]>
Reviewed-by: Sean Christopherson <[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>1 parent 30fbe0d commit 2187402
1 file changed
Lines changed: 21 additions & 17 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
791 | 791 | | |
792 | 792 | | |
793 | 793 | | |
794 | | - | |
| 794 | + | |
795 | 795 | | |
796 | | - | |
797 | | - | |
798 | | - | |
799 | | - | |
800 | 796 | | |
801 | | - | |
| 797 | + | |
802 | 798 | | |
803 | 799 | | |
804 | | - | |
| 800 | + | |
805 | 801 | | |
806 | 802 | | |
807 | | - | |
| 803 | + | |
808 | 804 | | |
809 | 805 | | |
810 | | - | |
| 806 | + | |
811 | 807 | | |
812 | 808 | | |
813 | | - | |
| 809 | + | |
814 | 810 | | |
815 | 811 | | |
816 | | - | |
| 812 | + | |
817 | 813 | | |
818 | 814 | | |
819 | | - | |
| 815 | + | |
820 | 816 | | |
821 | 817 | | |
| 818 | + | |
| 819 | + | |
| 820 | + | |
| 821 | + | |
| 822 | + | |
| 823 | + | |
| 824 | + | |
| 825 | + | |
| 826 | + | |
| 827 | + | |
| 828 | + | |
| 829 | + | |
822 | 830 | | |
823 | 831 | | |
824 | 832 | | |
| |||
8237 | 8245 | | |
8238 | 8246 | | |
8239 | 8247 | | |
8240 | | - | |
8241 | | - | |
8242 | | - | |
8243 | | - | |
8244 | 8248 | | |
8245 | 8249 | | |
8246 | 8250 | | |
| |||
8259 | 8263 | | |
8260 | 8264 | | |
8261 | 8265 | | |
8262 | | - | |
| 8266 | + | |
8263 | 8267 | | |
8264 | 8268 | | |
8265 | 8269 | | |
| |||
0 commit comments