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]
Message-ID: <CAMkAt6pcg_Eg49nN5hS=wbeVWtPV1N_12G9Lvfgoq_bS_tUYog@mail.gmail.com>
Date:   Fri, 29 Apr 2022 11:27:51 -0600
From:   Peter Gonda <pgonda@...gle.com>
To:     Paolo Bonzini <pbonzini@...hat.com>
Cc:     John Sperbeck <jsperbeck@...gle.com>,
        kvm list <kvm@...r.kernel.org>,
        David Rientjes <rientjes@...gle.com>,
        Sean Christopherson <seanjc@...gle.com>,
        LKML <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH v3] KVM: SEV: Mark nested locking of vcpu->lock

On Fri, Apr 29, 2022 at 11:21 AM Paolo Bonzini <pbonzini@...hat.com> wrote:
>
> On Fri, Apr 29, 2022 at 7:12 PM Peter Gonda <pgonda@...gle.com> wrote:
> > Sounds good. Instead of doing this prev_vcpu solution we could just
> > keep the 1st vcpu for source and target. I think this could work since
> > all the vcpu->mutex.dep_maps do not point to the same string.
> >
> > Lock:
> >          bool acquired = false;
> >          kvm_for_each_vcpu(...) {
> >                  if (mutex_lock_killable_nested(&vcpu->mutex, role)
> >                      goto out_unlock;
> >                 acquired = true;
> >                  if (acquired)
> >                       mutex_release(&vcpu->mutex, role)
> >          }
>
> Almost:
>
>           bool first = true;
>           kvm_for_each_vcpu(...) {
>                   if (mutex_lock_killable_nested(&vcpu->mutex, role)
>                       goto out_unlock;
>                   if (first)
>                       ++role, first = false;
>                  else
>                       mutex_release(&vcpu->mutex, role);
>          }
>
> and to unlock:
>
>           bool first = true;
>           kvm_for_each_vcpu(...) {
>                 if (first)
>                       first = false;
>                 else
>                       mutex_acquire(&vcpu->mutex, role);
>                 mutex_unlock(&vcpu->mutex);
>                 acquired = false;
>           }
>
> because you cannot use the first vCPU's role again when locking.

Ah yes I missed that. I would suggest `role = SEV_NR_MIGRATION_ROLES`
or something else instead of role++ to avoid leaking this
implementation detail outside of the function signature / enum.


>
> Paolo
>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ