iommu/amd: Remove amd_iommu_domain_update() from page table freeing
authorJason Gunthorpe <jgg@nvidia.com>
Fri, 30 Aug 2024 00:06:13 +0000 (21:06 -0300)
committerJoerg Roedel <jroedel@suse.de>
Wed, 4 Sep 2024 09:37:43 +0000 (11:37 +0200)
commit322d889ae7d39f8538a6deac35869aa3be1855bd
tree5cceeefd1073a8ccb9f45b7c2c1273244cbebaff
parent7a41dcb52f9de6079621fc31c3b84c7fc290934b
iommu/amd: Remove amd_iommu_domain_update() from page table freeing

It is a serious bug if the domain is still mapped to any DTEs when it is
freed as we immediately start freeing page table memory, so any remaining
HW touch will UAF.

If it is not mapped then dev_list is empty and amd_iommu_domain_update()
does nothing.

Remove it and add a WARN_ON() to catch this class of bug.

Reviewed-by: Vasant Hegde <vasant.hegde@amd.com>
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
Link: https://lore.kernel.org/r/4-v2-831cdc4d00f3+1a315-amd_iopgtbl_jgg@nvidia.com
Signed-off-by: Joerg Roedel <jroedel@suse.de>
drivers/iommu/amd/io_pgtable.c
drivers/iommu/amd/iommu.c