Skip to content

Commit e7250ab

Browse files
Koichiro Denjgunthorpe
authored andcommitted
iommufd: Fix missing update of domains_itree after splitting iopt_area
In iopt_area_split(), if the original iopt_area has filled a domain and is linked to domains_itree, pages_nodes have to be properly reinserted. Otherwise the domains_itree becomes corrupted and we will UAF. Fixes: 51fe614 ("iommufd: Data structure to provide IOVA to PFN mapping") Link: https://lore.kernel.org/r/20231027162941.2864615-2-den@valinux.co.jp Cc: stable@vger.kernel.org Signed-off-by: Koichiro Den <den@valinux.co.jp> Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
1 parent 03476e6 commit e7250ab

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

drivers/iommu/iommufd/io_pagetable.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1220,6 +1220,16 @@ static int iopt_area_split(struct iopt_area *area, unsigned long iova)
12201220
if (WARN_ON(rc))
12211221
goto err_remove_lhs;
12221222

1223+
/*
1224+
* If the original area has filled a domain, domains_itree has to be
1225+
* updated.
1226+
*/
1227+
if (area->storage_domain) {
1228+
interval_tree_remove(&area->pages_node, &pages->domains_itree);
1229+
interval_tree_insert(&lhs->pages_node, &pages->domains_itree);
1230+
interval_tree_insert(&rhs->pages_node, &pages->domains_itree);
1231+
}
1232+
12231233
lhs->storage_domain = area->storage_domain;
12241234
lhs->pages = area->pages;
12251235
rhs->storage_domain = area->storage_domain;

0 commit comments

Comments
 (0)