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] [thread-next>] [day] [month] [year] [list]
Date:   Fri, 20 Aug 2021 14:50:39 +0000
From:   Sean Christopherson <seanjc@...gle.com>
To:     Marc Orr <marcorr@...gle.com>
Cc:     Peter Gonda <pgonda@...gle.com>, kvm list <kvm@...r.kernel.org>,
        Paolo Bonzini <pbonzini@...hat.com>,
        David Rientjes <rientjes@...gle.com>,
        "Dr . David Alan Gilbert" <dgilbert@...hat.com>,
        Brijesh Singh <brijesh.singh@....com>,
        Vitaly Kuznetsov <vkuznets@...hat.com>,
        Wanpeng Li <wanpengli@...cent.com>,
        Jim Mattson <jmattson@...gle.com>,
        Joerg Roedel <joro@...tes.org>,
        Thomas Gleixner <tglx@...utronix.de>,
        Ingo Molnar <mingo@...hat.com>, Borislav Petkov <bp@...en8.de>,
        "H. Peter Anvin" <hpa@...or.com>, linux-kernel@...r.kernel.org
Subject: Re: [PATCH 1/2 V4] KVM, SEV: Add support for SEV intra host migration

On Thu, Aug 19, 2021, Marc Orr wrote:
> On Thu, Aug 19, 2021 at 3:58 PM Sean Christopherson <seanjc@...gle.com> wrote:
> >
> > On Thu, Aug 19, 2021, Peter Gonda wrote:
> > > Marc I think that only having the spin lock could result in
> > > deadlocking. If userspace double migrated 2 VMs, A and B for
> > > discussion, A could grab VM_A.spin_lock then VM_A.kvm_mutex. Meanwhile
> > > B could grab VM_B.spin_lock and VM_B.kvm_mutex. Then A attempts to
> > > grab VM_B.spin_lock and we have a deadlock. If the same happens with
> > > the proposed scheme when A attempts to lock B, VM_B.spin_lock will be
> > > open but the bool will mark the VM under migration so A will unlock
> > > and bail. Sean originally proposed a global spin lock but I thought a
> > > per kvm_sev_info struct would also be safe.
> >
> > Close.  The issue is taking kvm->lock from both VM_A and VM_B.  If userspace
> > double migrates we'll end up with lock ordering A->B and B-A, so we need a way
> > to guarantee one of those wins.  My proposed solution is to use a flag as a sort
> > of one-off "try lock" to detect a mean userspace.
> 
> Got it now. Thanks to you both, for the explanation. By the way, just
> to make sure I completely follow, I assume that if a "double
> migration" occurs, then user space is mis-behaving -- correct?

Yep.

> But presumably, we need to reason about how to respond to such mis-behavior
> so that buggy or malicious user-space code cannot stumble over/exploit this
> scenario?

That's what the anti-deadlock flag is for. :-)  With that in place, there's no
meaningful difference between say a bad userspace doing double migrate and a bad
userspace migrating from garbage, e.g. passing in a bogus fd.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ