lkml.org 
[lkml]   [2023]   [Jan]   [13]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v3] vfio: fix potential deadlock on vfio group lock
On Fri, Jan 13, 2023 at 12:11:32PM -0500, Matthew Rosato wrote:
> @@ -462,9 +520,19 @@ static inline void vfio_device_pm_runtime_put(struct vfio_device *device)
> static int vfio_device_fops_release(struct inode *inode, struct file *filep)
> {
> struct vfio_device *device = filep->private_data;
> + struct kvm *kvm = NULL;
>
> vfio_device_group_close(device);
>
> + mutex_lock(&device->dev_set->lock);
> + if (device->open_count == 0 && device->kvm) {
> + kvm = device->kvm;
> + device->kvm = NULL;
> + }
> + mutex_unlock(&device->dev_set->lock);

This still doesn't seem right, another thread could have incr'd the
open_count already

This has to be done at the moment open_count is decremented to zero,
while still under the original lock.

Jason

\
 
 \ /
  Last update: 2023-03-26 23:41    [W:0.046 / U:0.196 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site