[RFC PATCH v3 11/13] dax: refuse dma-buf iterators in dax_iomap_rw()

From: Nitesh Shetty

Date: Tue Dec 01 2026 - 11:56:41 EST


From: Mengmeng Zhao <zhaomengmeng@xxxxxxxxxx>

DAX copies data through the CPU, so it can't use a dma-buf iterator.
XFS and ext4 give DAX inodes no tag, so this is a safety net for other
callers.

Signed-off-by: Mengmeng Zhao <zhaomengmeng@xxxxxxxxxx>
Signed-off-by: Li Wang <liwang@xxxxxxxxxx>
Signed-off-by: Anuj Gupta <anuj20.g@xxxxxxxxxxx>
Signed-off-by: Nitesh Shetty <nj.shetty@xxxxxxxxxxx>
---
fs/dax.c | 4 ++++
1 file changed, 4 insertions(+)

diff --git a/fs/dax.c b/fs/dax.c
index 9d161d7ef3ef..feea8eae52c1 100644
--- a/fs/dax.c
+++ b/fs/dax.c
@@ -1753,6 +1753,10 @@ dax_iomap_rw(struct kiocb *iocb, struct iov_iter *iter,
if (!iomi.len)
return 0;

+ /* a dma-buf iterator has no CPU-visible pages to copy through */
+ if (iov_iter_is_dmabuf_map(iter))
+ return -EOPNOTSUPP;
+
if (iov_iter_rw(iter) == WRITE) {
lockdep_assert_held_write(&iomi.inode->i_rwsem);
iomi.flags |= IOMAP_WRITE;
--
2.47.3