[PATCH 2/2] ntfs: reject direct I/O reads of encrypted files
From: Zhan Xusheng
Date: Mon Oct 12 2026 - 02:21:28 EST
From: Zhan Xusheng <zhanxusheng@xxxxxxxxxx>
ntfs_file_read_iter() refuses direct I/O for compressed and WOF
compressed attributes but lets encrypted ones reach iomap_dio_rw().
ntfs_read_iomap_begin_non_resident() has no NInoEncrypted() test, so it
reports IOMAP_MAPPED for the attribute's real clusters and the raw
on-disk ciphertext is copied to the caller. Buffered reads are refused
by ntfs_read_folio(), but direct I/O never calls it.
Signed-off-by: Zhan Xusheng <zhanxusheng@xxxxxxxxxx>
Fixes: 9c87959601e8 ("ntfs: update file operations")
---
fs/ntfs/file.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/fs/ntfs/file.c b/fs/ntfs/file.c
index 007d1614b9ac6..eb8ed1959cd4c 100644
--- a/fs/ntfs/file.c
+++ b/fs/ntfs/file.c
@@ -460,8 +460,8 @@ static ssize_t ntfs_file_read_iter(struct kiocb *iocb, struct iov_iter *to)
if (NVolShutdown(NTFS_SB(sb)))
return -EIO;
- if ((NInoCompressed(NTFS_I(vi)) || NInoWofCompressed(NTFS_I(vi))) &&
- iocb->ki_flags & IOCB_DIRECT)
+ if ((NInoCompressed(NTFS_I(vi)) || NInoWofCompressed(NTFS_I(vi)) ||
+ NInoEncrypted(NTFS_I(vi))) && iocb->ki_flags & IOCB_DIRECT)
return -EOPNOTSUPP;
inode_lock_shared(vi);
--
2.43.0