From 5db65a43ed8bd1a4c0b01a20e494384bc45e4312 Mon Sep 17 00:00:00 2001 From: Zhan Xusheng Date: Mon, 12 Oct 2026 14:20:39 +0800 Subject: [PATCH] ntfs: do not read ahead encrypted files 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. Fixes: b041ca562526 ("ntfs: update iomap and address space operations") Signed-off-by: Zhan Xusheng Reviewed-by: Baolin Liu Reviewed-by: Hyunchul Lee Signed-off-by: Namjae Jeon --- 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 517d9a1563e7..ad781674fef1 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);