Re: [PATCH 1/2] ntfs: do not read ahead encrypted files
From: liubaolin
Date: Mon Oct 12 2026 - 04:49:42 EST
在 2026/10/12 14:20, Zhan Xusheng 写道:
From: Zhan Xusheng <zhanxusheng@xxxxxxxxxx>
ntfs_read_folio() refuses EFS-encrypted files with -EOPNOTSUPP because
decryption is not implemented. ntfs_readahead() has no NInoEncrypted()
test and passes them to iomap_readahead(), which maps the runlist and
fills the folios with the raw on-disk ciphertext. The folios are
marked uptodate, so the read that follows never reaches ->read_folio
and returns ciphertext instead of -EOPNOTSUPP.
ntfs_read_locked_inode() sets NInoEncrypted() and NInoNonResident() for
a non-resident encrypted $DATA attribute and rejects the
encrypted-and-compressed combination, so none of the three existing
conditions fires. read(), mmap(), splice() and fadvise() all populate
the page cache through readahead.
Skipping readahead leaves the folio unpopulated, so the read falls back
to ntfs_read_folio() and gets the intended error.
Signed-off-by: Zhan Xusheng <zhanxusheng@xxxxxxxxxx>
Fixes: b041ca562526 ("ntfs: update iomap and address space operations")
---
fs/ntfs/aops.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/fs/ntfs/aops.c b/fs/ntfs/aops.c
index 517d9a1563e7d..ad781674fef1a 100644
--- a/fs/ntfs/aops.c
+++ b/fs/ntfs/aops.c
@@ -240,10 +240,11 @@ static void ntfs_readahead(struct readahead_control *rac)
};
/*
- * Resident files are not cached in the page cache,
- * and readahead is not implemented for compressed files.
+ * Resident files are not cached in the page cache, readahead is not
+ * implemented for compressed files, and ntfs_read_folio() refuses
+ * encrypted files because decryption is not implemented.
*/
- if (!NInoNonResident(ni) || NInoCompressed(ni) ||
+ if (!NInoNonResident(ni) || NInoEncrypted(ni) || NInoCompressed(ni) ||
NInoWofCompressed(ni))
return;
iomap_readahead(&ntfs_read_iomap_ops, &ctx, NULL);
Looks good to me.
Reviewed-by: Baolin Liu <liubaolin@xxxxxxxxxx>