RE: [PATCH v2 11/14] vfio: Make vfio_device_open() exclusive between group path and device cdev path

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

 



> From: Liu, Yi L <yi.l.liu@xxxxxxxxx>
> Sent: Monday, February 6, 2023 5:05 PM
> 
>  struct vfio_device_file *
> -vfio_allocate_device_file(struct vfio_device *device)
> +vfio_allocate_device_file(struct vfio_device *device, bool is_cdev_device)
>  {
>  	struct vfio_device_file *df;
> 
> @@ -407,6 +407,7 @@ vfio_allocate_device_file(struct vfio_device *device)
>  		return ERR_PTR(-ENOMEM);
> 
>  	df->device = device;
> +	df->is_cdev_device = is_cdev_device;

You missed Alex's comment that the one caller can open code the
assignment instead of introducing an unmemorable Boolean arg here.

> 
> +	/*
> +	 * Device cdev path cannot support multiple device open since
> +	 * it doesn't have a secure way for it. So a second device
> +	 * open attempt should be failed if the caller is from a cdev
> +	 * path or the device has already been opened by a cdev path.
> +	 */
> +	if (device->open_count != 0 &&
> +	    (df->is_cdev_device || device->single_open))
> +		return -EINVAL;
> +

If we are gonna handle the exclusive open via dma ownership, then
here we don't need a new single_open flag inside vfio_device since
only one interface (cdev or group) could be used to open this device.

Just preventing multi-open in cdev is sufficient here.




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Kernel Development]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite Info]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Linux Media]     [Device Mapper]

  Powered by Linux