Re: [PATCH] iommufd: take dma_resv lock before dma_buf_unpin() in release path

From: Jason Gunthorpe

Date: Tue May 26 2026 - 08:29:04 EST


On Tue, May 26, 2026 at 11:10:34AM +0000, Ankit Soni wrote:
> dma_buf_unpin() requires the caller to hold the exporter's dma_resv
> lock:
>
> void dma_buf_unpin(struct dma_buf_attachment *attach)
> {
> ...
> dma_resv_assert_held(dmabuf->resv);
> ...
> }
>
> iopt_release_pages() calls dma_buf_unpin() without taking that lock,
> so every iommufd_ioas_destroy()/iommufd_ioas_unmap() that releases
> the last reference on a DMABUF-backed iopt_pages triggers a WARN.
> This was hit while running tools/testing/selftests/iommu/iommufd:

Any idea why this is comming up now? Did I run the tests without some
kind of debug option to turn on that assertion maybe?

Jason