Skip to contentSkip to conversation

iommu: fix KASAN use-after-free in iommu_insert_resv_region

PATCH New Eric Auger 1 participant 1 message Nov 26, 2019 IOMMU

lore
Share & tools
lore

Eric Auger

author
#0 lore raw

PATCH v4 1/1 iommu: fix KASAN use-after-free in iommu_insert_resv_region

In case the new region gets merged into another one, the nr list node is freed. Checking its type while completing the merge algorithm leads to a use-after-free. Use new->type instead.

Fixes 4dbd258ff63e ("iommu: Revisit iommu_insert_resv_region()

implementation")

---

v3 -> v4:
- s/nr/new in the comment
- Added Jerry's R-b

v2 -> v3:
- directly use new->type

v1 -> v2:
- remove spurious new line

---
 drivers/iommu/iommu.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/iommu/iommu.c +2 -2
index d658c7c6a2ab..dea1069334a4 100644
@@ -312,8 +312,8 @@ int iommu_insert_resv_region(struct iommu_resv_region *new,
 	list_for_each_entry_safe(iter, tmp, regions, list) {
 		phys_addr_t top_end, iter_end = iter->start + iter->length - 1;
 
-		/* no merge needed on elements of different types than @nr */
-		if (iter->type != nr->type) {
+		/* no merge needed on elements of different types than @new */
+		if (iter->type != new->type) {
 			list_move_tail(&iter->list, &stack);
 			continue;
 		}
Signature · 1 line
2.20.1