[Intel-gfx] [PATCH v2] vfio: fix potential deadlock on vfio group lock
Sean Christopherson
seanjc at google.com
Thu Jan 12 23:29:53 UTC 2023
On Thu, Jan 12, 2023, Matthew Rosato wrote:
> On 1/12/23 4:05 PM, Alex Williamson wrote:
> > On Thu, 12 Jan 2023 15:38:44 -0500
> > Matthew Rosato <mjrosato at linux.ibm.com> wrote:
> >> @@ -344,6 +345,35 @@ static bool vfio_assert_device_open(struct vfio_device *device)
> >> return !WARN_ON_ONCE(!READ_ONCE(device->open_count));
> >> }
> >>
> >> +static bool vfio_kvm_get_kvm_safe(struct kvm *kvm)
> >> +{
> >> + bool (*fn)(struct kvm *kvm);
> >> + bool ret;
> >> +
> >> + fn = symbol_get(kvm_get_kvm_safe);
> >> + if (WARN_ON(!fn))
In a related vein to Alex's comments about error handling, this should not WARN.
WARNing during vfio_kvm_put_kvm() makes sense, but the "get" is somewhat blind.
> >> + return false;
> >> +
> >> + ret = fn(kvm);
> >> +
> >> + symbol_put(kvm_get_kvm_safe);
> >> +
> >> + return ret;
> >> +}
> >> +
> >> +static void vfio_kvm_put_kvm(struct kvm *kvm)
> >> +{
> >> + void (*fn)(struct kvm *kvm);
> >> +
> >> + fn = symbol_get(kvm_put_kvm);
> >> + if (WARN_ON(!fn))
> >> + return;
> >> +
> >> + fn(kvm);
> >> +
> >> + symbol_put(kvm_put_kvm);
> >> +}
More information about the Intel-gfx
mailing list