Re: [PATCH v3] vfio: fix deadlock between group lock and kvm lock

From: Alex Williamson
Date: Fri Feb 03 2023 - 16:37:23 EST


On Fri, 3 Feb 2023 16:19:10 -0500
Matthew Rosato <mjrosato@xxxxxxxxxxxxx> wrote:
> > @@ -350,32 +350,25 @@ void vfio_device_get_kvm_safe(struct vfio_device *device)
> >
> > lockdep_assert_held(&device->dev_set->lock);
> >
> > - spin_lock(&device->group->kvm_ref_lock);
> > - if (!device->group->kvm)
> > - goto unlock;
> > -
> > pfn = symbol_get(kvm_put_kvm);
> > if (WARN_ON(!pfn))
> > - goto unlock;
> > + return;
> >
> > fn = symbol_get(kvm_get_kvm_safe);
> > if (WARN_ON(!fn)) {
> > symbol_put(kvm_put_kvm);
> > - goto unlock;
> > + return;
> > }
> > > ret = fn(device->group->kvm);
>
> s/device->group->kvm/kvm/

Oops, yes.

> With that small change, this looks good to me too (and testing looks
> good too). Do you want me to send a v4 for one last round of review?

Please do. Thanks,

Alex