mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-12-28 16:56:26 +00:00
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>
This commit is contained in:
parent
bf64913dfe
commit
9b4bb82244
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user