On Thu, Jun 27, 2024 at 09:42:09AM -0300, Jason Gunthorpe wrote:
On Thu, Jun 27, 2024 at 05:51:01PM +0800, Yan Zhao wrote:For group path, I'm afraid there's no such a place ensuring only one active fd
Maybe we can put this assignment to vfio_df_ioctl_bind_iommufd() afterThis doesn't seem right.. There is only one device but multiple file
can be opened on that device.
vfio_df_open() makes sure device->open_count is 1.
Yeah, that seems better.
Logically it would be best if all places set the inode once the
inode/FD has been made to be the one and only way to access it.
in kernel.
I tried modifying QEMU to allow two openings and two assignments of the same
device. It works and appears to guest that there were 2 devices, though this
ultimately leads to device malfunctions in guest.
Thanks. However, from the code, it reads like a drawback of the cdev flow :)BTW, in group path, what's the benefit of allowing multiple open of device?
I don't know, the thing that opened the first FD can just dup it, no
idea why two different FDs would be useful. It is something we removed
in the cdev flow
I don't understand why the group path is secure though.
/*
* Only the group path allows the device to be opened multiple
* times. The device cdev path doesn't have a secure way for it.
*/
if (device->open_count != 0 && !df->group)
return -EINVAL;