Skip to content

Commit

Permalink
iommu: fix KASAN use-after-free in iommu_insert_resv_region
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
eauger authored and torvalds committed Dec 16, 2019
1 parent 7de7de7 commit 4c80ba3
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions drivers/iommu/iommu.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 4c80ba3

Please sign in to comment.