public inbox for virtualization@lists.linux-foundation.org
 help / color / mirror / Atom feed
* [PATCH v3 0/7] dma-buf: Use revoke mechanism to invalidate shared buffers
@ 2026-01-20 14:07 Leon Romanovsky
  2026-01-20 14:07 ` [PATCH v3 1/7] dma-buf: Rename .move_notify() callback to a clearer identifier Leon Romanovsky
                   ` (6 more replies)
  0 siblings, 7 replies; 40+ messages in thread
From: Leon Romanovsky @ 2026-01-20 14:07 UTC (permalink / raw)
  To: Sumit Semwal, Christian König, Alex Deucher, David Airlie,
	Simona Vetter, Gerd Hoffmann, Dmitry Osipenko, Gurchetan Singh,
	Chia-I Wu, Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
	Lucas De Marchi, Thomas Hellström, Rodrigo Vivi,
	Jason Gunthorpe, Leon Romanovsky, Kevin Tian, Joerg Roedel,
	Will Deacon, Robin Murphy, Felix Kuehling, Alex Williamson,
	Ankit Agrawal, Vivek Kasireddy
  Cc: linux-media, dri-devel, linaro-mm-sig, linux-kernel, amd-gfx,
	virtualization, intel-xe, linux-rdma, iommu, kvm

Changelog:
v3:
 * Used Jason's wordings for commits and cover letter.
 * Removed IOMMUFD patch.
 * Renamed dma_buf_attachment_is_revoke() to be dma_buf_attach_revocable().
 * Added patch to remove CONFIG_DMABUF_MOVE_NOTIFY.
 * Added Reviewed-by tags.
 * Called to dma_resv_wait_timeout() after dma_buf_move_notify() in VFIO.
 * Added dma_buf_attach_revocable() check to VFIO DMABUF attach function.
 * Slightly changed commit messages.
v2: https://patch.msgid.link/20260118-dmabuf-revoke-v2-0-a03bb27c0875@nvidia.com
 * Changed series to document the revoke semantics instead of
   implementing it.
v1: https://patch.msgid.link/20260111-dmabuf-revoke-v1-0-fb4bcc8c259b@nvidia.com

-------------------------------------------------------------------------
This series documents a dma-buf “revoke” mechanism: to allow a dma-buf
exporter to explicitly invalidate (“kill”) a shared buffer after it has
been distributed to importers, so that further CPU and device access is
prevented and importers reliably observe failure.

The change in this series is to properly document and use existing core
“revoked” state on the dma-buf object and a corresponding exporter-triggered
revoke operation.

dma-buf has quietly allowed calling move_notify on pinned dma-bufs, even
though legacy importers using dma_buf_attach() would simply ignore
these calls.

RDMA saw this and needed to use allow_peer2peer=true, so implemented a
new-style pinned importer with an explicitly non-working move_notify()
callback.

This has been tolerable because the existing exporters are thought to
only call move_notify() on a pinned DMABUF under RAS events and we
have been willing to tolerate the UAF that results by allowing the
importer to continue to use the mapping in this rare case.

VFIO wants to implement a pin supporting exporter that will issue a
revoking move_notify() around FLRs and a few other user triggerable
operations. Since this is much more common we are not willing to
tolerate the security UAF caused by interworking with non-move_notify()
supporting drivers. Thus till now VFIO has required dynamic importers,
even though it never actually moves the buffer location.

To allow VFIO to work with pinned importers, according to how dma-buf
was intended, we need to allow VFIO to detect if an importer is legacy
or RDMA and does not actually implement move_notify().

Introduce a new function that exporters can call to detect these less
capable importers. VFIO can then refuse to accept them during attach.

In theory all exporters that call move_notify() on pinned dma-buf's
should call this function, however that would break a number of widely
used NIC/GPU flows. Thus for now do not spread this further than VFIO
until we can understand how much of RDMA can implement the full
semantic.

In the process clarify how move_notify is intended to be used with
pinned dma-bufs.

Thanks

Signed-off-by: Leon Romanovsky <leonro@nvidia.com>
---
Leon Romanovsky (7):
      dma-buf: Rename .move_notify() callback to a clearer identifier
      dma-buf: Always build with DMABUF_MOVE_NOTIFY
      dma-buf: Document RDMA non-ODP invalidate_mapping() special case
      dma-buf: Add check function for revoke semantics
      iommufd: Pin dma-buf importer for revoke semantics
      vfio: Wait for dma-buf invalidation to complete
      vfio: Validate dma-buf revocation semantics

 drivers/dma-buf/Kconfig                     | 12 -----
 drivers/dma-buf/dma-buf.c                   | 69 +++++++++++++++++++++++------
 drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c | 14 +++---
 drivers/gpu/drm/amd/amdkfd/Kconfig          |  2 +-
 drivers/gpu/drm/virtio/virtgpu_prime.c      |  2 +-
 drivers/gpu/drm/xe/tests/xe_dma_buf.c       |  7 ++-
 drivers/gpu/drm/xe/xe_dma_buf.c             | 14 +++---
 drivers/infiniband/core/umem_dmabuf.c       | 13 +-----
 drivers/infiniband/hw/mlx5/mr.c             |  2 +-
 drivers/iommu/iommufd/pages.c               | 11 ++++-
 drivers/vfio/pci/vfio_pci_dmabuf.c          |  8 ++++
 include/linux/dma-buf.h                     |  9 ++--
 12 files changed, 96 insertions(+), 67 deletions(-)
---
base-commit: 9ace4753a5202b02191d54e9fdf7f9e3d02b85eb
change-id: 20251221-dmabuf-revoke-b90ef16e4236

Best regards,
--  
Leon Romanovsky <leonro@nvidia.com>


^ permalink raw reply	[flat|nested] 40+ messages in thread

end of thread, other threads:[~2026-01-23 16:31 UTC | newest]

Thread overview: 40+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-01-20 14:07 [PATCH v3 0/7] dma-buf: Use revoke mechanism to invalidate shared buffers Leon Romanovsky
2026-01-20 14:07 ` [PATCH v3 1/7] dma-buf: Rename .move_notify() callback to a clearer identifier Leon Romanovsky
2026-01-21  8:33   ` Christian König
2026-01-21  8:41     ` Leon Romanovsky
2026-01-20 14:07 ` [PATCH v3 2/7] dma-buf: Always build with DMABUF_MOVE_NOTIFY Leon Romanovsky
2026-01-21  8:55   ` Christian König
2026-01-21 10:14     ` Leon Romanovsky
2026-01-21 10:57       ` Christian König
2026-01-20 14:07 ` [PATCH v3 3/7] dma-buf: Document RDMA non-ODP invalidate_mapping() special case Leon Romanovsky
2026-01-21  8:59   ` Christian König
2026-01-21  9:14     ` Leon Romanovsky
2026-01-21  9:17       ` Christian König
2026-01-21 13:18         ` Jason Gunthorpe
2026-01-21 13:52           ` Christian König
2026-01-21 13:59             ` Jason Gunthorpe
2026-01-21 14:15               ` Christian König
2026-01-21 14:31                 ` Leon Romanovsky
2026-01-21 15:39                 ` Jason Gunthorpe
2026-01-20 14:07 ` [PATCH v3 4/7] dma-buf: Add check function for revoke semantics Leon Romanovsky
2026-01-20 14:07 ` [PATCH v3 5/7] iommufd: Pin dma-buf importer " Leon Romanovsky
2026-01-21  9:01   ` Christian König
2026-01-20 14:07 ` [PATCH v3 6/7] vfio: Wait for dma-buf invalidation to complete Leon Romanovsky
2026-01-20 20:44   ` Matthew Brost
2026-01-21  7:59     ` Leon Romanovsky
2026-01-21 10:41     ` Christian König
2026-01-21 10:44       ` Leon Romanovsky
2026-01-21 17:18         ` Matthew Brost
2026-01-21  9:20   ` Christian König
2026-01-21  9:36     ` Thomas Hellström
2026-01-21 10:55       ` Christian König
2026-01-21 13:31     ` Jason Gunthorpe
2026-01-21 15:28       ` Christian König
2026-01-21 16:01         ` Jason Gunthorpe
2026-01-21 19:45           ` Leon Romanovsky
2026-01-22 11:32           ` Christian König
2026-01-22 23:44             ` Jason Gunthorpe
2026-01-23 14:11               ` Jason Gunthorpe
2026-01-23 16:23                 ` Christian König
2026-01-23 16:31                   ` Jason Gunthorpe
2026-01-20 14:07 ` [PATCH v3 7/7] vfio: Validate dma-buf revocation semantics Leon Romanovsky

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox