All of lore.kernel.org
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: Mark Kanda <mark.kanda@oracle.com>, kvm@vger.kernel.org
Cc: rkrcmar@redhat.com, ameya.more@oracle.com,
	Jim Mattson <jmattson@google.com>
Subject: Re: [PATCH] KVM: nVMX: Eliminate vmcs02 pool
Date: Mon, 27 Nov 2017 18:51:07 +0100	[thread overview]
Message-ID: <3f88befc-a296-a8a7-f2d4-28afd15d632e@redhat.com> (raw)
In-Reply-To: <0dd4862d-f1dd-bd08-a91d-97060c7b5f42@oracle.com>

On 27/11/2017 18:43, Mark Kanda wrote:
> On 11/23/2017 5:46 PM, Paolo Bonzini wrote:
>> On 21/11/2017 18:22, Mark Kanda wrote:
>>> -    nested_free_all_saved_vmcss(vmx);
>>> +    free_loaded_vmcs(&vmx->nested.vmcs02);
>>
>> Please add to free_loaded_vmcs a WARN that the passed vmcs is not
>> vmx->loaded_vmcs.
> 
> Sure.
> 
> However, I don't see a way to access vmx from the passed in vmcs, which
> would necessitate passing in vmx for the WARN (multiple callers) - I may
> be missing something..

free_loaded_vmcs is only ever used on VMCS02's, so you can change it to

static void vmx_nested_free_vmcs02(struct vcpu_vmx *vmx)
{
	struct loaded_vmcs *loaded_vmcs = &vmx->nested.vmcs02;

	/*
	 * Just leak the VMCS02 if the WARN triggers.  Better than
	 * a use-after-free.
	 */
	if (WARN_ON(vmx->loaded_vmcs == loaded_vmcs))
		return;
	...
}

> I'm happy to do this, but it seems possibly excessive for the sole
> purpose of adding the WARN. Thoughts?

We've had this kind of bug in the past, so I prefer to err on the side
of safety.

Paolo

  reply	other threads:[~2017-11-27 17:51 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-21 17:22 [PATCH] KVM: nVMX: Eliminate vmcs02 pool Mark Kanda
2017-11-23 16:59 ` David Hildenbrand
2017-11-23 17:17   ` Paolo Bonzini
2017-11-23 17:25     ` David Hildenbrand
2017-11-27 17:17   ` Jim Mattson
2017-11-27 17:18     ` Paolo Bonzini
2017-11-27 22:01       ` David Hildenbrand
2017-11-23 23:46 ` Paolo Bonzini
2017-11-27 17:43   ` Mark Kanda
2017-11-27 17:51     ` Paolo Bonzini [this message]
2017-11-27 17:56       ` Mark Kanda
2017-11-27 20:04       ` Mark Kanda
2017-11-27 20:36         ` Mark Kanda
2017-11-27 20:54           ` Paolo Bonzini

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=3f88befc-a296-a8a7-f2d4-28afd15d632e@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=ameya.more@oracle.com \
    --cc=jmattson@google.com \
    --cc=kvm@vger.kernel.org \
    --cc=mark.kanda@oracle.com \
    --cc=rkrcmar@redhat.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.