]> xenbits.xensource.com Git - people/liuw/xen.git/commit
x86/vmx: Fix security issue when a guest balloons out the #VE info page
authorAndrew Cooper <andrew.cooper3@citrix.com>
Thu, 17 Jan 2019 12:26:17 +0000 (12:26 +0000)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Thu, 28 Feb 2019 11:16:27 +0000 (11:16 +0000)
commit0ec9b4ef3148e052bd8adf83800d7d681571f49e
tree3315dcd72aa0cd0cd80b37505dcaa7443f1fcd6f
parent346e7d0f4b2179b9e0b09f4ebc98cbb3aae39a2c
x86/vmx: Fix security issue when a guest balloons out the #VE info page

The logic in altp2m_vcpu_{en,dis}able_ve() and vmx_vcpu_update_vmfunc_ve() is
dangerous.  After #VE has been set up, the guest can balloon out and free the
nominated GFN, after which the processor may write to it.  Also, the unlocked
GFN query means the MFN is stale by the time it is used.  Alternatively, a
guest can race two disable calls to cause one VMCS to still reference the
nominated GFN after the tracking information was dropped.

Rework the logic from scratch to make it safe.

Hold an extra page reference on the underlying frame, to account for the
VMCS's reference.  This means that if the GFN gets ballooned out, it isn't
freed back to Xen until #VE is disabled, and the VMCS no longer refers to the
page.

A consequence of this is that altp2m_vcpu_disable_ve() needs to be called
during the domain_kill() path, to drop the reference for domains which shut
down with #VE still enabled.

For domains using altp2m, we expect a single enable call and no disable for
the remaining lifetime of the domain.  However, to avoid problems with
concurrent calls, use cmpxchg() to locklessly maintain safety.

This doesn't have an XSA because altp2m is not yet a security-supported
feature.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Tested-by: Razvan Cojocaru <rcojocaru@bitdefender.com>
Reviewed-by: Kevin Tian <kevin.tian@intel.com>
Release-acked-by: Juergen Gross <jgross@suse.com>
xen/arch/x86/domain.c
xen/arch/x86/hvm/vmx/vmx.c
xen/arch/x86/mm/altp2m.c
xen/include/asm-x86/hvm/vcpu.h