Skip to content

Commit 4c80ba3

Browse files
eaugertorvalds
authored andcommitted
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: 4dbd258 ("iommu: Revisit iommu_insert_resv_region() implementation") Signed-off-by: Eric Auger <[email protected]> Reported-by: Qian Cai <[email protected]> Reviewed-by: Jerry Snitselaar <[email protected]> Cc: Stable <[email protected]> #v5.3+ Signed-off-by: Linus Torvalds <[email protected]>
1 parent 7de7de7 commit 4c80ba3

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

drivers/iommu/iommu.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -312,8 +312,8 @@ int iommu_insert_resv_region(struct iommu_resv_region *new,
312312
list_for_each_entry_safe(iter, tmp, regions, list) {
313313
phys_addr_t top_end, iter_end = iter->start + iter->length - 1;
314314

315-
/* no merge needed on elements of different types than @nr */
316-
if (iter->type != nr->type) {
315+
/* no merge needed on elements of different types than @new */
316+
if (iter->type != new->type) {
317317
list_move_tail(&iter->list, &stack);
318318
continue;
319319
}

0 commit comments

Comments
 (0)