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: <3a741047-48a7-ee72-27ec-f83b0b7669f6@redhat.com>
Date:   Tue, 30 Mar 2021 19:10:30 +0200
From:   Paolo Bonzini <pbonzini@...hat.com>
To:     Vitaly Kuznetsov <vkuznets@...hat.com>, kvm@...r.kernel.org
Cc:     Sean Christopherson <seanjc@...gle.com>,
        Wanpeng Li <wanpengli@...cent.com>,
        Jim Mattson <jmattson@...gle.com>,
        Wei Huang <wei.huang2@....com>, Joerg Roedel <joro@...tes.org>,
        Haiwei Li <lihaiwei.kernel@...il.com>,
        linux-kernel@...r.kernel.org
Subject: Re: [PATCH] KVM: x86/vPMU: Forbid reading from MSR_F15H_PERF MSRs
 when guest doesn't have X86_FEATURE_PERFCTR_CORE

On 29/03/21 14:48, Vitaly Kuznetsov wrote:
> MSR_F15H_PERF_CTL0-5, MSR_F15H_PERF_CTR0-5 MSRs have a CPUID bit assigned
> to them (X86_FEATURE_PERFCTR_CORE) and when it wasn't exposed to the guest
> the correct behavior is to inject #GP an not just return zero.
> 
> Signed-off-by: Vitaly Kuznetsov <vkuznets@...hat.com>
> ---
>   arch/x86/kvm/x86.c | 6 ++++++
>   1 file changed, 6 insertions(+)
> 
> diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
> index fe806e894212..125453155ede 100644
> --- a/arch/x86/kvm/x86.c
> +++ b/arch/x86/kvm/x86.c
> @@ -3381,6 +3381,12 @@ int kvm_get_msr_common(struct kvm_vcpu *vcpu, struct msr_data *msr_info)
>   		msr_info->data = 0;
>   		break;
>   	case MSR_F15H_PERF_CTL0 ... MSR_F15H_PERF_CTR5:
> +		if (kvm_pmu_is_valid_msr(vcpu, msr_info->index))
> +			return kvm_pmu_get_msr(vcpu, msr_info);
> +		if (!msr_info->host_initiated)
> +			return 1;
> +		msr_info->data = 0;
> +		break;
>   	case MSR_K7_EVNTSEL0 ... MSR_K7_EVNTSEL3:
>   	case MSR_K7_PERFCTR0 ... MSR_K7_PERFCTR3:
>   	case MSR_P6_PERFCTR0 ... MSR_P6_PERFCTR1:
> 

Queued to kvm/next, thanks (the write side goes to kvm/master instead).

Paolo

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ