iommufd: Check the domain owner of the parent before creating a nesting domain
Jason Gunthorpe
maintainerPATCH 1/1 iommufd: Check the domain owner of the parent before creating a nesting domain
This check was missed, before we can pass a struct iommu_domain to a driver callback we need to validate that the domain was created by that driver.
Fixes bd529dbb661d ("iommufd: Add a nested HW pagetable object")
Signed-off-by Jason Gunthorpe <[email protected]>
--- drivers/iommu/iommufd/hw_pagetable.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/iommu/iommufd/hw_pagetable.c +2 -1
@@ -225,7 +225,8 @@ iommufd_hwpt_nested_alloc(struct iommufd_ctx *ictx,if ((flags & ~IOMMU_HWPT_FAULT_ID_VALID ) || !user_data->len || !ops->domain_alloc_user)return ERR_PTR (-EOPNOTSUPP ); -if (parent->auto_domain || !parent->nest_parent) +if (parent->auto_domain || !parent->nest_parent || + parent->common.domain->owner != ops)return ERR_PTR (-EINVAL ); hwpt_nested = __iommufd_object_alloc(
base-commit: d2138b9e6ff3f3261b68066313b69adc05af1929
Signature · 1 line
2.46.0
Quoted 6 lines · Jason Gunthorpe
This check was missed, before we can pass a struct
iommu_domainto a driver callback we need to validate that the domain was created by that driver.Fixes bd529dbb661d ("iommufd: Add a nested HW pagetable object")Signed-off-by Jason Gunthorpe <[email protected]>
Reviewed-by Nicolin Chen <[email protected]>
Quoted 9 lines · Jason Gunthorpe
This check was missed, before we can pass a struct
iommu_domainto a driver callback we need to validate that the domain was created by that driver.Fixes bd529dbb661d ("iommufd: Add a nested HW pagetable object")Signed-off-by Jason Gunthorpe <[email protected]>--- drivers/iommu/iommufd/hw_pagetable.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
Applied to for-next, thanks
Jason