CVE-2021-46978

KVM: nVMX: Always make an attempt to map eVMCS after migration

High · published February 28, 2024

CVSS v3.1
7.8
EPSS
0%
Percentile
14.4
In the wild
Unconfirmed
What it is

In the Linux kernel, the following vulnerability has been resolved:

KVM: nVMX: Always make an attempt to map eVMCS after migration

When enlightened VMCS is in use and nested state is migrated with

vmx_get_nested_state()/vmx_set_nested_state() KVM can't map evmcs

page right away: evmcs gpa is not 'struct kvm_vmx_nested_state_hdr'

and we can't read it from VP assist page because userspace may decide

to restore HV_X64_MSR_VP_ASSIST_PAGE after restoring nested state

(and QEMU, for example, does exactly that). To make sure eVMCS is

mapped /vmx_set_nested_state() raises KVM_REQ_GET_NESTED_STATE_PAGES

request.

Commit f2c7ef3ba955 ("KVM: nSVM: cancel KVM_REQ_GET_NESTED_STATE_PAGES

on nested vmexit") added KVM_REQ_GET_NESTED_STATE_PAGES clearing to

nested_vmx_vmexit() to make sure MSR permission bitmap is not switched

when an immediate exit from L2 to L1 happens right after migration (caused

by a pending event, for example). Unfortunately, in the exact same

situation we still need to have eVMCS mapped so

nested_sync_vmcs12_to_shadow() reflects changes in VMCS12 to eVMCS.

As a band-aid, restore nested_get_evmcs_page() when clearing

KVM_REQ_GET_NESTED_STATE_PAGES in nested_vmx_vmexit(). The 'fix' is far

from being ideal as we can't easily propagate possible failures and even if

we could, this is most likely already too late to do so. The whole

'KVM_REQ_GET_NESTED_STATE_PAGES' idea for mapping eVMCS after migration

seems to be fragile as we diverge too much from the 'native' path when

vmptr loading happens on vmx_set_nested_state().

The record
Technical detail
CVSS v3.1
7.8 · HIGH
Vector
CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H
CVSS v4.0
Not supplied
EPSS
0.00241 · 14.4th percentile
Published
2024-02-28T08:13Z
EPSS history
Timeline
  • 28 FEB 08:13Z
    KVM: nVMX: Always make an attempt to map eVMCS after migration
    cvelistv5