From: Paolo Bonzini <pbonzini@redhat.com>
To: Sean Christopherson <seanjc@google.com>,
Vitaly Kuznetsov <vkuznets@redhat.com>
Cc: kvm@vger.kernel.org, Wanpeng Li <wanpengli@tencent.com>,
Jim Mattson <jmattson@google.com>,
Igor Mammedov <imammedo@redhat.com>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/2] KVM: x86: Use memcmp in kvm_cpuid_check_equal()
Date: Mon, 24 Jan 2022 18:07:27 +0100 [thread overview]
Message-ID: <979883b4-8fcd-7488-0313-de6348863b21@redhat.com> (raw)
In-Reply-To: <Ye7ZQJ6NYoZqK9yk@google.com>
On 1/24/22 17:52, Sean Christopherson wrote:
> On Mon, Jan 24, 2022, Vitaly Kuznetsov wrote:
>> Paolo Bonzini <pbonzini@redhat.com> writes:
>>>> + if (memcmp(e2, vcpu->arch.cpuid_entries, nent * sizeof(*e2)))
>>>> + return -EINVAL;
>>>
>>> Hmm, not sure about that due to the padding in struct kvm_cpuid_entry2.
>>> It might break userspace that isn't too careful about zeroing it.
>
> Given that we already are fully committed to potentially breaking userspace by
> disallowing KVM_SET_CPUID{2} after KVM_RUN, we might as well get greedy.
Hmm, I thought this series was because we were _not_ fully committed. :)
>> FWIW, QEMU zeroes the whole thing before setting individual CPUID
>> entries. Legacy KVM_SET_CPUID call is also not afffected as it copies
>> entries to a newly allocated "struct kvm_cpuid_entry2[]" and explicitly
>> zeroes padding.
>>
>> Do we need to at least add a check for ".flags"?
>
> Yes.
Yes, we do. Alternatively, we can replace memdup with a copy in the
style of KVM_CPUID.
Paolo
next prev parent reply other threads:[~2022-01-24 17:07 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-24 10:36 [PATCH 0/2] KVM: x86: Partially allow KVM_SET_CPUID{,2} follow-up Vitaly Kuznetsov
2022-01-24 10:36 ` [PATCH 1/2] KVM: x86: Move CPUID.(EAX=0x12,ECX=1) mangling to __kvm_update_cpuid_runtime() Vitaly Kuznetsov
2022-01-24 10:36 ` [PATCH 2/2] KVM: x86: Use memcmp in kvm_cpuid_check_equal() Vitaly Kuznetsov
2022-01-24 14:02 ` Paolo Bonzini
2022-01-24 15:10 ` Vitaly Kuznetsov
2022-01-24 16:52 ` Sean Christopherson
2022-01-24 17:07 ` Paolo Bonzini [this message]
2022-01-24 19:08 ` Sean Christopherson
2022-01-24 21:03 ` Joe Perches
2022-01-26 10:03 ` Vitaly Kuznetsov
2022-01-26 16:02 ` Sean Christopherson
2022-01-26 16:25 ` Vitaly Kuznetsov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=979883b4-8fcd-7488-0313-de6348863b21@redhat.com \
--to=pbonzini@redhat.com \
--cc=imammedo@redhat.com \
--cc=jmattson@google.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=seanjc@google.com \
--cc=vkuznets@redhat.com \
--cc=wanpengli@tencent.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®