Skip to content

Commit 322d889

Browse files
jgunthorpejoergroedel
authored andcommitted
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 <[email protected]> Signed-off-by: Jason Gunthorpe <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Joerg Roedel <[email protected]>
1 parent 7a41dcb commit 322d889

File tree

2 files changed

+2
-3
lines changed

2 files changed

+2
-3
lines changed

drivers/iommu/amd/io_pgtable.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -577,9 +577,6 @@ static void v1_free_pgtable(struct io_pgtable *iop)
577577

578578
/* Update data structure */
579579
amd_iommu_domain_clr_pt_root(dom);
580-
581-
/* Make changes visible to IOMMUs */
582-
amd_iommu_domain_update(dom);
583580
}
584581

585582
static struct io_pgtable *v1_alloc_pgtable(struct io_pgtable_cfg *cfg, void *cookie)

drivers/iommu/amd/iommu.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2255,6 +2255,8 @@ void protection_domain_free(struct protection_domain *domain)
22552255
if (!domain)
22562256
return;
22572257

2258+
WARN_ON(!list_empty(&domain->dev_list));
2259+
22582260
if (domain->iop.pgtbl_cfg.tlb)
22592261
free_io_pgtable_ops(&domain->iop.iop.ops);
22602262

0 commit comments

Comments
 (0)