[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <df876461-17a6-dbdd-2292-9822db68b6b8@redhat.com>
Date: Mon, 27 Sep 2021 17:25:49 +0200
From: Paolo Bonzini <pbonzini@...hat.com>
To: Zhenzhong Duan <zhenzhong.duan@...el.com>, kvm@...r.kernel.org
Cc: linux-kernel@...r.kernel.org, vkuznets@...hat.com,
wanpengli@...cent.com, jmattson@...gle.com, joro@...tes.org,
stable@...r.kernel.org, Sean Christopherson <seanjc@...gle.com>
Subject: Re: [PATCH v2] KVM: VMX: Fix a TSX_CTRL_CPUID_CLEAR field mask issue
On 26/09/21 03:55, Zhenzhong Duan wrote:
> 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.
>
> Cc: stable@...r.kernel.org
> Fixes: 8ea8b8d6f869 ("KVM: VMX: Use common x86's uret MSR list as the one true list")
> Signed-off-by: Zhenzhong Duan <zhenzhong.duan@...el.com>
> Reviewed-by: Sean Christopherson <seanjc@...gle.com>
> ---
> arch/x86/kvm/vmx/vmx.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c
> index 0c2c0d5ae873..cbf3d33432b9 100644
> --- a/arch/x86/kvm/vmx/vmx.c
> +++ b/arch/x86/kvm/vmx/vmx.c
> @@ -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
Powered by blists - more mailing lists