[PATCH 1/2] iommu: debug-pagealloc: Check map overflow in a phys_addr_t

From: Mostafa Saleh

Date: Mon Nov 30 2026 - 11:47:36 EST


__iommu_debug_map() checks phys + size for overflow into a size_t.
On a 32-bit kernel with a 64-bit phys_addr_t (as ARM_LPAE) this would
reprot an overflow for every mapping that ends at or above 4 GiB.
The mapping warns and is not counted, and its unmap then underflows
the page refcounts.

Do the check in a phys_addr_t.

Reported by the Sashiko review of an unrelated series.

Fixes: 7e84593795b3 ("iommu: debug-pagealloc: Track IOMMU pages")
Link: https://sashiko.dev/#/patchset/20261111185931.94882-1-griffoul%40gmail.com
Signed-off-by: Mostafa Saleh <smostafa@xxxxxxxxxx>
---
drivers/iommu/iommu-debug-pagealloc.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/iommu/iommu-debug-pagealloc.c b/drivers/iommu/iommu-debug-pagealloc.c
index 80164df5bab1..fb6e06d42102 100644
--- a/drivers/iommu/iommu-debug-pagealloc.c
+++ b/drivers/iommu/iommu-debug-pagealloc.c
@@ -98,7 +98,8 @@ void __iommu_debug_check_unmapped(const struct page *page, int numpages)

void __iommu_debug_map(struct iommu_domain *domain, phys_addr_t phys, size_t size)
{
- size_t off, end;
+ size_t off;
+ phys_addr_t end;
size_t page_size = iommu_debug_page_size(domain);

if (WARN_ON(!phys || check_add_overflow(phys, size, &end)))
--
2.56.1.839.g22a8290db9-goog