[PATCH rc 1/2] iommufd: Do not allow creating areas without READ or WRITE

Nicolin Chen nicolinc at nvidia.com
Fri Aug 23 09:29:32 PDT 2024


On Thu, Aug 22, 2024 at 11:45:54AM -0300, Jason Gunthorpe wrote:
> 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 at kernel.org
> Fixes: aad37e71d5c4 ("iommufd: IOCTLs for the io_pagetable")
> Signed-off-by: Jason Gunthorpe <jgg at nvidia.com>

Reviewed-by: Nicolin Chen <nicolinc at nvidia.com>

I also tried both patches with io-pgtable-arm and didn't see any
issue, since they tends to fix a corner case I think.

Nicolin



More information about the linux-arm-kernel mailing list