]> Gentwo Git Trees - linux/.git/commit
iommufd: Verify object in iommufd_object_finalize/abort()
authorNicolin Chen <nicolinc@nvidia.com>
Tue, 5 Nov 2024 20:04:20 +0000 (12:04 -0800)
committerJason Gunthorpe <jgg@nvidia.com>
Tue, 12 Nov 2024 15:46:18 +0000 (11:46 -0400)
commitd56d1e8405a9e154a30f4a055eb7ef55516b32b0
tree43779b406e16652abb8de05a73c1ff95d4327cea
parent6b22d562fcd6e3d1cc1c265b0596840946d16a09
iommufd: Verify object in iommufd_object_finalize/abort()

To support driver-allocated vIOMMU objects, it's required for IOMMU driver
to call the provided iommufd_viommu_alloc helper to embed the core struct.
However, there is no guarantee that every driver will call it and allocate
objects properly.

Make the iommufd_object_finalize/abort functions more robust to verify if
the xarray slot indexed by the input obj->id is having an XA_ZERO_ENTRY,
which is the reserved value stored by xa_alloc via iommufd_object_alloc.

Link: https://patch.msgid.link/r/334bd4dde8e0a88eb30fa67eeef61827cdb546f9.1730836219.git.nicolinc@nvidia.com
Suggested-by: Jason Gunthorpe <jgg@nvidia.com>
Reviewed-by: Jason Gunthorpe <jgg@nvidia.com>
Signed-off-by: Nicolin Chen <nicolinc@nvidia.com>
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
drivers/iommu/iommufd/main.c