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: b041ca5625 ("ntfs: update iomap and address space operations")
Signed-off-by: Zhan Xusheng <zhanxusheng@xiaomi.com>
Reviewed-by: Baolin Liu <liubaolin@kylinos.cn>
Reviewed-by: Hyunchul Lee <hyc.lee@gmail.com>
Signed-off-by: Namjae Jeon <linkinjeon@kernel.org>
This commit is contained in:
Zhan Xusheng 2026-10-12 14:20:39 +08:00 committed by Namjae Jeon
parent eb75ab5474
commit 5db65a43ed

View File

@ -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);