[RFC PATCH v2 7/8] dax: refuse dma-buf iterators in dax_iomap_rw()
From: Mengmeng Zhao
Date: Fri Nov 13 2026 - 02:34:13 EST
From: Mengmeng Zhao <zhaomengmeng@xxxxxxxxxx>
DAX copies data through the CPU, so a dma-buf iterator has no meaning
in the DAX I/O path and must be refused. A DAX inode does not get
FMODE_CAN_DMABUF_IO at open time, but DAX can be enabled later, so
check per I/O.
Signed-off-by: Mengmeng Zhao <zhaomengmeng@xxxxxxxxxx>
Signed-off-by: Li Wang <liwang@xxxxxxxxxx>
---
fs/dax.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/fs/dax.c b/fs/dax.c
index 94ba41273347..84d24db5ed35 100644
--- a/fs/dax.c
+++ b/fs/dax.c
@@ -1752,6 +1752,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.43.0