RE: [PATCH] vfio: Get/put KVM only for the first/last vfio_df_open/close in cdev path

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> From: Zhao, Yan Y <yan.y.zhao@xxxxxxxxx>
> Sent: Monday, July 1, 2024 8:02 PM
> 
> On Mon, Jul 01, 2024 at 06:30:05PM +0800, Yi Liu wrote:
> > On 2024/7/1 16:43, Tian, Kevin wrote:
> > >
> > > what about extending vfio_df_open() to unify the get/put_kvm()
> > > and open_count trick in one place?
> > >
> > > int vfio_df_open(struct vfio_device_file *df, struct kvm *kvm,
> > > 	spinlock_t *kvm_ref_lock)
> > > {
> >
> > this should work. But need a comment to note why need pass in both kvm
> > and kvm_ref_lock given df has both of them. :)
> So why to pass them?

hmm actually passing them is wrong especially for the group path.
We have to get kvm upon the first reference to the pointer otherwise
it is prone to use-after-free issue.

> 
> What about making vfio_device_group_get_kvm_safe() or
> vfio_df_get_kvm_safe()
> not static and calling one of them in vfio_df_open() according to the df-
> >group
> ?
> 

yeah, this sounds better.






[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux