linux-stable/drivers/vfio
Yi Liu 839e692fa4 vfio: Make vfio_df_open() single open for device cdev path
VFIO group has historically allowed multi-open of the device FD. This
was made secure because the "open" was executed via an ioctl to the
group FD which is itself only single open.

However, no known use of multiple device FDs today. It is kind of a
strange thing to do because new device FDs can naturally be created
via dup().

When we implement the new device uAPI (only used in cdev path) there is
no natural way to allow the device itself from being multi-opened in a
secure manner. Without the group FD we cannot prove the security context
of the opener.

Thus, when moving to the new uAPI we block the ability of opening
a device multiple times. Given old group path still allows it we store
a vfio_group pointer in struct vfio_device_file to differentiate.

Reviewed-by: Kevin Tian <kevin.tian@intel.com>
Reviewed-by: Jason Gunthorpe <jgg@nvidia.com>
Reviewed-by: Eric Auger <eric.auger@redhat.com>
Tested-by: Terrence Xu <terrence.xu@intel.com>
Tested-by: Nicolin Chen <nicolinc@nvidia.com>
Tested-by: Matthew Rosato <mjrosato@linux.ibm.com>
Tested-by: Yanting Jiang <yanting.jiang@intel.com>
Tested-by: Shameer Kolothum <shameerali.kolothum.thodi@huawei.com>
Tested-by: Zhenzhong Duan <zhenzhong.duan@intel.com>
Signed-off-by: Yi Liu <yi.l.liu@intel.com>
Link: https://lore.kernel.org/r/20230718135551.6592-10-yi.l.liu@intel.com
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
2023-07-25 10:18:57 -06:00
..
cdx vfio/cdx: add support for CDX bus 2023-06-16 12:27:04 -06:00
fsl-mc VFIO updates for v6.5-rc1 2023-06-30 15:22:09 -07:00
mdev vfio/mdev: Move the compat_class initialization to module init 2023-06-27 12:05:26 -06:00
pci vfio/pci: Allow passing zero-length fd array in VFIO_DEVICE_PCI_HOT_RESET 2023-07-25 10:18:13 -06:00
platform vfio/platform: Cleanup Kconfig 2023-06-16 12:23:50 -06:00
container.c VFIO updates for v6.3-rc1 2023-02-25 11:52:57 -08:00
group.c vfio: Make vfio_df_open() single open for device cdev path 2023-07-25 10:18:57 -06:00
iommufd.c vfio/pci: Extend VFIO_DEVICE_GET_PCI_HOT_RESET_INFO for vfio device cdev 2023-07-25 10:18:05 -06:00
iova_bitmap.c vfio/iova_bitmap: refactor iova_bitmap_set() to better handle page boundaries 2022-12-02 10:09:25 -07:00
Kconfig vfio/cdx: add support for CDX bus 2023-06-16 12:27:04 -06:00
Makefile vfio/cdx: add support for CDX bus 2023-06-16 12:27:04 -06:00
vfio.h vfio: Make vfio_df_open() single open for device cdev path 2023-07-25 10:18:57 -06:00
vfio_iommu_spapr_tce.c powerpc/iommu: Add iommu_ops to report capabilities and allow blocking domains 2023-03-15 00:51:46 +11:00
vfio_iommu_type1.c mm: ptep_get() conversion 2023-06-19 16:19:25 -07:00
vfio_main.c vfio: Make vfio_df_open() single open for device cdev path 2023-07-25 10:18:57 -06:00
virqfd.c vfio: Use GFP_KERNEL_ACCOUNT for userspace persistent allocations 2023-01-23 11:26:29 -07:00