Re: [PATCH] vfio: fix VFIO_IOMMU_UNMAP_DMA when end of range would overflow u64
From: Jason Gunthorpe
Date: Tue Oct 07 2025 - 07:48:11 EST
On Mon, Oct 06, 2025 at 09:23:56PM -0400, Alejandro Jimenez wrote:
> I mentioned this issue on the cover letter for:
> https://lore.kernel.org/qemu-devel/20250919213515.917111-1-alejandro.j.jimenez@xxxxxxxxxx/
Use iommufd for this kind of work?
> I mentioned in the notes for the patch above why I chose a slightly more
> complex method than the '- 1' approach, since there is a chance that
> iova+size could also go beyond the end of the address space and actually
> wrap around.
At the uapi boundary it should check that size != 0 and
!check_add_overflow(iova+size). It is much easier to understand if the
input from userspace is validated immediately at userspace.
Then the rest of the code safely computes the last with 'iova+size-1'
and does range logic based on last not end.
Jason