Skip to content

Commit ada14b9

Browse files
yiliu1765jgunthorpe
authored andcommitted
iommu: Require passing new handles to APIs supporting handle
Add kdoc to highligt the caller of iommu_[attach|replace]_group_handle() and iommu_attach_device_pasid() should always provide a new handle. This can avoid race with lockless reference to the handle. e.g. the find_fault_handler() and iommu_report_device_fault() in the PRI path. Link: https://patch.msgid.link/r/20250321171940.7213-2-yi.l.liu@intel.com Reviewed-by: Lu Baolu <baolu.lu@linux.intel.com> Reviewed-by: Jason Gunthorpe <jgg@nvidia.com> Signed-off-by: Yi Liu <yi.l.liu@intel.com> Tested-by: Nicolin Chen <nicolinc@nvidia.com> Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
1 parent 06d54f0 commit ada14b9

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

drivers/iommu/iommu.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3365,6 +3365,9 @@ static void __iommu_remove_group_pasid(struct iommu_group *group,
33653365
* @pasid: the pasid of the device.
33663366
* @handle: the attach handle.
33673367
*
3368+
* Caller should always provide a new handle to avoid race with the paths
3369+
* that have lockless reference to handle if it intends to pass a valid handle.
3370+
*
33683371
* Return: 0 on success, or an error.
33693372
*/
33703373
int iommu_attach_device_pasid(struct iommu_domain *domain,
@@ -3525,6 +3528,9 @@ EXPORT_SYMBOL_NS_GPL(iommu_attach_handle_get, "IOMMUFD_INTERNAL");
35253528
* This is a variant of iommu_attach_group(). It allows the caller to provide
35263529
* an attach handle and use it when the domain is attached. This is currently
35273530
* used by IOMMUFD to deliver the I/O page faults.
3531+
*
3532+
* Caller should always provide a new handle to avoid race with the paths
3533+
* that have lockless reference to handle.
35283534
*/
35293535
int iommu_attach_group_handle(struct iommu_domain *domain,
35303536
struct iommu_group *group,
@@ -3594,6 +3600,9 @@ EXPORT_SYMBOL_NS_GPL(iommu_detach_group_handle, "IOMMUFD_INTERNAL");
35943600
*
35953601
* If the currently attached domain is a core domain (e.g. a default_domain),
35963602
* it will act just like the iommu_attach_group_handle().
3603+
*
3604+
* Caller should always provide a new handle to avoid race with the paths
3605+
* that have lockless reference to handle.
35973606
*/
35983607
int iommu_replace_group_handle(struct iommu_group *group,
35993608
struct iommu_domain *new_domain,

0 commit comments

Comments
 (0)