[PATCH] dax: fix assertion in dax_iomap_rw()

Jan Kara jack at suse.cz
Thu Oct 2 18:13:12 AEST 2025


dax_iomap_rw() asserts that inode lock is held when reading from it. The
assert triggers on erofs as it indeed doesn't hold any locks in this
case - naturally because there's nothing to race against when the
filesystem is read-only. Check the locking only if the filesystem is
actually writeable.

Reported-by: syzbot+47680984f2d4969027ea at syzkaller.appspotmail.com
Signed-off-by: Jan Kara <jack at suse.cz>
---
 fs/dax.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/dax.c b/fs/dax.c
index 20ecf652c129..187f8c325744 100644
--- a/fs/dax.c
+++ b/fs/dax.c
@@ -1752,7 +1752,7 @@ dax_iomap_rw(struct kiocb *iocb, struct iov_iter *iter,
 	if (iov_iter_rw(iter) == WRITE) {
 		lockdep_assert_held_write(&iomi.inode->i_rwsem);
 		iomi.flags |= IOMAP_WRITE;
-	} else {
+	} else if (!IS_RDONLY(iomi.inode)) {
 		lockdep_assert_held(&iomi.inode->i_rwsem);
 	}
 
-- 
2.51.0



More information about the Linux-erofs mailing list