KVM: VMX: Fix a TSX_CTRL_CPUID_CLEAR field mask issue
Subsystems (4)
PATCH v2 1/1 KVM: VMX: Fix a TSX_CTRL_CPUID_CLEAR field mask issue
When updating the host's mask for its MSR_IA32_TSX_CTRL user return entry, clear the mask in the found uret MSR instead of vmx->guest_uret_msrs[i]. Modifying guest_uret_msrs directly is completely broken as 'i' does not point at the MSR_IA32_TSX_CTRL entry. In fact, it's guaranteed to be an out-of-bounds accesses as is always set to kvm_nr_uret_msrs in a prior loop. By sheer dumb luck, the fallout is limited to "only" failing to preserve the host's TSX_CTRL_CPUID_CLEAR. The out-of-bounds access is benign as it's guaranteed to clear a bit in a guest MSR value, which are always zero at vCPU creation on both x86-64 and i386.
--- arch/x86/kvm/vmx/vmx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/kvm/vmx/vmx.c +1 -1
@@ -6833,7 +6833,7 @@ static int vmx_create_vcpu(struct kvm_vcpu *vcpu)*/ tsx_ctrl =vmx_find_uret_msr (vmx,MSR_IA32_TSX_CTRL );if (tsx_ctrl) - vmx->guest_uret_msrs[i].mask = ~(u64 )TSX_CTRL_CPUID_CLEAR ; + tsx_ctrl->mask = ~(u64 )TSX_CTRL_CPUID_CLEAR ; } err =alloc_loaded_vmcs (&vmx->vmcs01);
Signature · 1 line
2.25.1
Quoted 24 lines · Zhenzhong Duan
When updating the host's mask for its
MSR_IA32_TSX_CTRLuser return entry, clear the mask in the found uret MSR instead of vmx->guest_uret_msrs[i]. Modifyingguest_uret_msrsdirectly is completely broken as 'i' does not point at theMSR_IA32_TSX_CTRLentry. In fact, it's guaranteed to be an out-of-bounds accesses as is always set tokvm_nr_uret_msrsin a prior loop. By sheer dumb luck, the fallout is limited to "only" failing to preserve the host'sTSX_CTRL_CPUID_CLEAR. The out-of-bounds access is benign as it's guaranteed to clear a bit in a guest MSR value, which are always zero at vCPU creation on both x86-64 and i386.Fixes 8ea8b8d6f869 ("KVM: VMX: Use common x86's uret MSR list as the one true list")Signed-off-by Zhenzhong Duan <[email protected]>Reviewed-by Sean Christopherson <[email protected]>--- arch/x86/kvm/vmx/vmx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)arch/x86/kvm/vmx/vmx.c +0
-0
arch/x86/kvm/vmx/vmx.c static int vmx_create_vcpu(struct kvm_vcpu *vcpu) · line 6839
Quoted 8 lines
arch/x86/kvm/vmx/vmx.c +1
-1@@ -6833,7 +6833,7 @@ static int vmx_create_vcpu(struct kvm_vcpu *vcpu)*/ tsx_ctrl =vmx_find_uret_msr (vmx,MSR_IA32_TSX_CTRL );if (tsx_ctrl) - vmx->guest_uret_msrs[i].mask = ~(u64 )TSX_CTRL_CPUID_CLEAR ; + tsx_ctrl->mask = ~(u64 )TSX_CTRL_CPUID_CLEAR ; } err =alloc_loaded_vmcs (&vmx->vmcs01);
Queued, thanks.
Paolo