linux-imx/drivers/iommu/iommufd
Jason Gunthorpe b547cab1eb iommufd: Do not allow creating areas without READ or WRITE
commit 996dc53ac2 upstream.

This results in passing 0 or just IOMMU_CACHE to iommu_map(). Most of
the page table formats don't like this:

  amdv1 - -EINVAL
  armv7s - returns 0, doesn't update mapped
  arm-lpae - returns 0 doesn't update mapped
  dart - returns 0, doesn't update mapped
  VT-D - returns -EINVAL

Unfortunately the three formats that return 0 cause serious problems:

 - Returning ret = but not uppdating mapped from domain->map_pages()
   causes an infinite loop in __iommu_map()

 - Not writing ioptes means that VFIO/iommufd have no way to recover them
   and we will have memory leaks and worse during unmap

Since almost nothing can support this, and it is a useless thing to do,
block it early in iommufd.

Cc: stable@kernel.org
Fixes: aad37e71d5 ("iommufd: IOCTLs for the io_pagetable")
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
Reviewed-by: Nicolin Chen <nicolinc@nvidia.com>
Reviewed-by: Kevin Tian <kevin.tian@intel.com>
Link: https://lore.kernel.org/r/1-v1-1211e1294c27+4b1-iommu_no_prot_jgg@nvidia.com
Signed-off-by: Joerg Roedel <jroedel@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2024-09-04 13:28:24 +02:00
..
device.c VFIO updates for v6.6-rc1 2023-08-30 20:36:01 -07:00
double_span.h
hw_pagetable.c iommufd: Add IOMMU_HWPT_ALLOC 2023-07-26 10:20:31 -03:00
io_pagetable.c iommufd: Fix iopt_access_list_id overwrite bug 2024-03-06 14:48:41 +00:00
io_pagetable.h
ioas.c iommufd: Do not allow creating areas without READ or WRITE 2024-09-04 13:28:24 +02:00
iommufd_private.h VFIO updates for v6.6-rc1 2023-08-30 20:36:01 -07:00
iommufd_test.h iommufd/selftest: Add coverage for IOMMU_GET_HW_INFO ioctl 2023-08-18 12:52:15 -03:00
Kconfig vfio: Compile vfio_group infrastructure optionally 2023-07-25 10:20:50 -06:00
main.c VFIO updates for v6.6-rc1 2023-08-30 20:36:01 -07:00
Makefile
pages.c iommufd: Add iopt_area_alloc() 2023-11-20 11:59:17 +01:00
selftest.c iommufd/selftest: Don't leak the platform device memory when unloading the module 2023-08-18 12:56:24 -03:00
vfio_compat.c vfio: align capability structures 2023-08-17 12:17:44 -06:00