diff options
author | Matthew Wilcox (Oracle) <willy@infradead.org> | 2024-10-25 20:08:20 +0100 |
---|---|---|
committer | Christian Brauner <brauner@kernel.org> | 2024-11-05 17:20:00 +0100 |
commit | 9b4bb822448b473394bef8049cf86850fa2dd904 (patch) | |
tree | 0b34432895278c75c9db118649459f69339967f4 /fs/ecryptfs | |
parent | bf64913dfe623d6325329e42fb621b3f358ce40e (diff) | |
download | linux-stable-9b4bb822448b473394bef8049cf86850fa2dd904.tar.gz linux-stable-9b4bb822448b473394bef8049cf86850fa2dd904.tar.bz2 linux-stable-9b4bb822448b473394bef8049cf86850fa2dd904.zip |
ecryptfs: Pass the folio index to crypt_extent()
We need to pass pages, not folios, to crypt_extent() as we may be
working with a plain page rather than a folio. But we need to know the
index in the file, so pass it in from the caller.
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Link: https://lore.kernel.org/r/20241025190822.1319162-11-willy@infradead.org
Signed-off-by: Christian Brauner <brauner@kernel.org>
Diffstat (limited to 'fs/ecryptfs')
-rw-r--r-- | fs/ecryptfs/crypto.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/fs/ecryptfs/crypto.c b/fs/ecryptfs/crypto.c index bb65a3a5ee9b..69536cacdea8 100644 --- a/fs/ecryptfs/crypto.c +++ b/fs/ecryptfs/crypto.c @@ -340,6 +340,7 @@ static loff_t lower_offset_for_page(struct ecryptfs_crypt_stat *crypt_stat, * encryption operation * @dst_page: The page to write the result into * @src_page: The page to read from + * @page_index: The offset in the file (in units of PAGE_SIZE) * @extent_offset: Page extent offset for use in generating IV * @op: ENCRYPT or DECRYPT to indicate the desired operation * @@ -350,9 +351,9 @@ static loff_t lower_offset_for_page(struct ecryptfs_crypt_stat *crypt_stat, static int crypt_extent(struct ecryptfs_crypt_stat *crypt_stat, struct page *dst_page, struct page *src_page, + pgoff_t page_index, unsigned long extent_offset, int op) { - pgoff_t page_index = op == ENCRYPT ? src_page->index : dst_page->index; loff_t extent_base; char extent_iv[ECRYPTFS_MAX_IV_BYTES]; struct scatterlist src_sg, dst_sg; @@ -432,7 +433,8 @@ int ecryptfs_encrypt_page(struct folio *folio) extent_offset < (PAGE_SIZE / crypt_stat->extent_size); extent_offset++) { rc = crypt_extent(crypt_stat, enc_extent_page, - folio_page(folio, 0), extent_offset, ENCRYPT); + folio_page(folio, 0), folio->index, + extent_offset, ENCRYPT); if (rc) { printk(KERN_ERR "%s: Error encrypting extent; " "rc = [%d]\n", __func__, rc); @@ -505,8 +507,8 @@ int ecryptfs_decrypt_page(struct folio *folio) extent_offset < (PAGE_SIZE / crypt_stat->extent_size); extent_offset++) { struct page *page = folio_page(folio, 0); - rc = crypt_extent(crypt_stat, page, page, - extent_offset, DECRYPT); + rc = crypt_extent(crypt_stat, page, page, folio->index, + extent_offset, DECRYPT); if (rc) { printk(KERN_ERR "%s: Error decrypting extent; " "rc = [%d]\n", __func__, rc); |