public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Sean Christopherson <seanjc@google.com>
To: Jon Kohler <jon@nutanix.com>
Cc: Borislav Petkov <bp@alien8.de>,
	Thomas Gleixner <tglx@linutronix.de>,
	Ingo Molnar <mingo@redhat.com>,
	Dave Hansen <dave.hansen@linux.intel.com>,
	"x86@kernel.org" <x86@kernel.org>,
	"H. Peter Anvin" <hpa@zytor.com>,
	Paolo Bonzini <pbonzini@redhat.com>,
	Vitaly Kuznetsov <vkuznets@redhat.com>,
	Wanpeng Li <wanpengli@tencent.com>,
	Jim Mattson <jmattson@google.com>, Joerg Roedel <joro@8bytes.org>,
	Josh Poimboeuf <jpoimboe@redhat.com>,
	Peter Zijlstra <peterz@infradead.org>,
	Balbir Singh <sblbir@amazon.com>,
	Kim Phillips <kim.phillips@amd.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"kvm@vger.kernel.org" <kvm@vger.kernel.org>,
	Andrea Arcangeli <aarcange@redhat.com>,
	Kees Cook <keescook@chromium.org>,
	Waiman Long <longman@redhat.com>
Subject: Re: [PATCH v3] x86/speculation, KVM: only IBPB for switch_mm_always_ibpb on vCPU load
Date: Tue, 10 May 2022 15:50:31 +0000	[thread overview]
Message-ID: <YnqJx/5hos0lKqI9@google.com> (raw)
In-Reply-To: <520D7CBE-55FA-4EB9-BC41-9E8D695334D1@nutanix.com>

On Tue, May 10, 2022, Jon Kohler wrote:
> 
> > On May 10, 2022, at 10:44 AM, Sean Christopherson <seanjc@google.com> wrote:
> > 
> > On Sat, Apr 30, 2022, Borislav Petkov wrote:
> >> But I'm likely missing a virt aspect here so I'd let Sean explain what
> >> the rules are...
> > 
> > I don't think you're missing anything.  I think the original 15d45071523d ("KVM/x86:
> > Add IBPB support") was simply wrong.
> > 
> > As I see it:
> > 
> >  1. If the vCPUs belong to the same VM, they are in the same security domain and
> >     do not need an IPBP.
> > 
> >  2. If the vCPUs belong to different VMs, and each VM is in its own mm_struct,
> >     defer to switch_mm_irqs_off() to handle IBPB as an mm switch is guaranteed to
> >     occur prior to loading a vCPU belonging to a different VMs.
> > 
> >  3. If the vCPUs belong to different VMs, but multiple VMs share an mm_struct,
> >     then the security benefits of an IBPB when switching vCPUs are dubious, at best.
> > 
> > If we only consider #1 and #2, then KVM doesn't need an IBPB, period.
> > 
> > #3 is the only one that's a grey area.  I have no objection to omitting IBPB entirely
> > even in that case, because none of us can identify any tangible value in doing so.
> 
> Thanks, Sean. Our messages crossed in flight, I sent a reply to your earlier message
> just a bit ago. This is super helpful to frame this up.
> 
> What would you think framing the patch like this:
> 
>     x86/speculation, KVM: remove IBPB on vCPU load
> 
>     Remove IBPB that is done on KVM vCPU load, as the guest-to-guest
>     attack surface is already covered by switch_mm_irqs_off() ->
>     cond_mitigation().
> 
>     The original 15d45071523d ("KVM/x86: Add IBPB support") was simply wrong in
>     its guest-to-guest design intention. There are three scenarios at play
>     here:
> 
>     1. If the vCPUs belong to the same VM, they are in the same security 
>     domain and do not need an IPBP.
>     2. If the vCPUs belong to different VMs, and each VM is in its own mm_struct,
>     switch_mm_irqs_off() will handle IBPB as an mm switch is guaranteed to
>     occur prior to loading a vCPU belonging to a different VMs.
>     3. If the vCPUs belong to different VMs, but multiple VMs share an mm_struct,
>     then the security benefits of an IBPB when switching vCPUs are dubious, 
>     at best.
> 
>     Issuing IBPB from KVM vCPU load would only cover #3, but there are no

Just to hedge, there are no _known_ use cases.

>     real world tangible use cases for such a configuration.

and I would further qualify this with:

      but there are no known real world, tangible use cases for running multiple
      VMs belonging to different security domains in a shared address space.

Running multiple VMs in a single address space is plausible and sane, _if_ they
are all in the same security domain or security is not a concern.  That way the
statement isn't invalidated if someone pops up with a use case for running multiple
VMs but has no security story.

Other than that, LGTM.

>     If multiple VMs
>     are sharing an mm_structs, prediction attacks are the least of their
>     security worries.
> 
>     Fixes: 15d45071523d ("KVM/x86: Add IBPB support")
>     (Reviewedby/signed of by people here)
>     (Code change simply whacks IBPB in KVM vmx/svm and thats it)
> 
> 
> 

  reply	other threads:[~2022-05-10 15:54 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-22 16:21 [PATCH v3] x86/speculation, KVM: only IBPB for switch_mm_always_ibpb on vCPU load Jon Kohler
2022-04-28 12:51 ` Jon Kohler
2022-04-29 16:59 ` Borislav Petkov
2022-04-29 17:31   ` Jon Kohler
2022-04-29 19:32     ` Borislav Petkov
2022-04-29 20:08       ` Jon Kohler
2022-04-29 20:29       ` Sean Christopherson
2022-04-29 20:59         ` Borislav Petkov
2022-04-29 21:59           ` Sean Christopherson
2022-04-29 22:22             ` Borislav Petkov
2022-04-29 23:23               ` Sean Christopherson
2022-04-30  9:50                 ` Borislav Petkov
2022-04-30 14:50                   ` Jon Kohler
2022-04-30 16:08                     ` Borislav Petkov
2022-05-06 15:42                       ` Jon Kohler
2022-05-10 14:44                       ` Sean Christopherson
2022-05-10 15:03                         ` Jon Kohler
2022-05-10 15:50                           ` Sean Christopherson [this message]
2022-05-12 13:44                             ` Borislav Petkov
2022-05-12 17:56                               ` Jon Kohler
2022-05-10 14:22                     ` Sean Christopherson
2022-05-10 14:49                       ` Jon Kohler

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=YnqJx/5hos0lKqI9@google.com \
    --to=seanjc@google.com \
    --cc=aarcange@redhat.com \
    --cc=bp@alien8.de \
    --cc=dave.hansen@linux.intel.com \
    --cc=hpa@zytor.com \
    --cc=jmattson@google.com \
    --cc=jon@nutanix.com \
    --cc=joro@8bytes.org \
    --cc=jpoimboe@redhat.com \
    --cc=keescook@chromium.org \
    --cc=kim.phillips@amd.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=longman@redhat.com \
    --cc=mingo@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=peterz@infradead.org \
    --cc=sblbir@amazon.com \
    --cc=tglx@linutronix.de \
    --cc=vkuznets@redhat.com \
    --cc=wanpengli@tencent.com \
    --cc=x86@kernel.org \
    /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