lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <87zhi03a0y.fsf@vitty.brq.redhat.com>
Date:   Wed, 16 Oct 2019 18:55:25 +0200
From:   Vitaly Kuznetsov <vkuznets@...hat.com>
To:     Miaohe Lin <linmiaohe@...wei.com>
Cc:     x86@...nel.org, kvm@...r.kernel.org, linux-kernel@...r.kernel.org,
        linmiaohe@...wei.com, mingfangsen@...wei.com, pbonzini@...hat.com,
        rkrcmar@...hat.com, sean.j.christopherson@...el.com,
        wanpengli@...cent.com, jmattson@...gle.com, joro@...tes.org,
        tglx@...utronix.de, mingo@...hat.com, bp@...en8.de, hpa@...or.com
Subject: Re: [PATCH] KVM: SVM: Fix potential wrong physical id in avic_handle_ldr_update

Miaohe Lin <linmiaohe@...wei.com> writes:

> Guest physical APIC ID may not equal to vcpu->vcpu_id in some case.
> We may set the wrong physical id in avic_handle_ldr_update as we
> always use vcpu->vcpu_id.
>
> Signed-off-by: Miaohe Lin <linmiaohe@...wei.com>
> ---
>  arch/x86/kvm/svm.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
> index f8ecb6d..67cb5ba 100644
> --- a/arch/x86/kvm/svm.c
> +++ b/arch/x86/kvm/svm.c
> @@ -4591,6 +4591,8 @@ static int avic_handle_ldr_update(struct kvm_vcpu *vcpu)
>  	int ret = 0;
>  	struct vcpu_svm *svm = to_svm(vcpu);
>  	u32 ldr = kvm_lapic_get_reg(vcpu->arch.apic, APIC_LDR);
> +	u32 apic_id_reg = kvm_lapic_get_reg(vcpu->arch.apic, APIC_ID);
> +	u32 id = (apic_id_reg >> 24) & 0xff;

If we reach here than we're guaranteed to be in xAPIC mode, right? Could
you maybe export and use kvm_xapic_id() here then (and in
avic_handle_apic_id_update() too)?

>  
>  	if (ldr == svm->ldr_reg)
>  		return 0;
> @@ -4598,7 +4600,7 @@ static int avic_handle_ldr_update(struct kvm_vcpu *vcpu)
>  	avic_invalidate_logical_id_entry(vcpu);
>  
>  	if (ldr)
> -		ret = avic_ldr_write(vcpu, vcpu->vcpu_id, ldr);
> +		ret = avic_ldr_write(vcpu, id, ldr);
>  
>  	if (!ret)
>  		svm->ldr_reg = ldr;

-- 
Vitaly

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ