All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sean Christopherson <seanjc@google.com>
To: Vitaly Kuznetsov <vkuznets@redhat.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>,
	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 16:52:16 +0000	[thread overview]
Message-ID: <Ye7ZQJ6NYoZqK9yk@google.com> (raw)
In-Reply-To: <87bl01i2zl.fsf@redhat.com>

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.

> 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.

  reply	other threads:[~2022-01-24 16:52 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 [this message]
2022-01-24 17:07         ` Paolo Bonzini
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=Ye7ZQJ6NYoZqK9yk@google.com \
    --to=seanjc@google.com \
    --cc=imammedo@redhat.com \
    --cc=jmattson@google.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pbonzini@redhat.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.