Commit 12003e5b authored by Tyler Hicks's avatar Tyler Hicks

eCryptfs: Use entire helper page during page crypto operations

When encrypting eCryptfs pages and decrypting pages from the lower
filesystem, utilize the entire helper page rather than only the first
4096 bytes.

This only affects architectures where PAGE_CACHE_SIZE is larger than
4096 bytes.
Signed-off-by: default avatarTyler Hicks <tyhicks@canonical.com>
parent fc8b14d3
...@@ -450,9 +450,10 @@ static int ecryptfs_encrypt_extent(struct page *enc_extent_page, ...@@ -450,9 +450,10 @@ static int ecryptfs_encrypt_extent(struct page *enc_extent_page,
(unsigned long long)(extent_base + extent_offset), rc); (unsigned long long)(extent_base + extent_offset), rc);
goto out; goto out;
} }
rc = ecryptfs_encrypt_page_offset(crypt_stat, enc_extent_page, 0, rc = ecryptfs_encrypt_page_offset(crypt_stat, enc_extent_page,
page, (extent_offset extent_offset * crypt_stat->extent_size,
* crypt_stat->extent_size), page,
extent_offset * crypt_stat->extent_size,
crypt_stat->extent_size, extent_iv); crypt_stat->extent_size, extent_iv);
if (rc < 0) { if (rc < 0) {
printk(KERN_ERR "%s: Error attempting to encrypt page with " printk(KERN_ERR "%s: Error attempting to encrypt page with "
...@@ -520,7 +521,8 @@ int ecryptfs_encrypt_page(struct page *page) ...@@ -520,7 +521,8 @@ int ecryptfs_encrypt_page(struct page *page)
* (PAGE_CACHE_SIZE * (PAGE_CACHE_SIZE
/ crypt_stat->extent_size)) / crypt_stat->extent_size))
+ extent_offset), crypt_stat); + extent_offset), crypt_stat);
rc = ecryptfs_write_lower(ecryptfs_inode, enc_extent_virt, rc = ecryptfs_write_lower(ecryptfs_inode, (enc_extent_virt +
extent_offset * crypt_stat->extent_size),
offset, crypt_stat->extent_size); offset, crypt_stat->extent_size);
if (rc < 0) { if (rc < 0) {
ecryptfs_printk(KERN_ERR, "Error attempting " ecryptfs_printk(KERN_ERR, "Error attempting "
...@@ -558,9 +560,9 @@ static int ecryptfs_decrypt_extent(struct page *page, ...@@ -558,9 +560,9 @@ static int ecryptfs_decrypt_extent(struct page *page,
goto out; goto out;
} }
rc = ecryptfs_decrypt_page_offset(crypt_stat, page, rc = ecryptfs_decrypt_page_offset(crypt_stat, page,
(extent_offset extent_offset * crypt_stat->extent_size,
* crypt_stat->extent_size), enc_extent_page,
enc_extent_page, 0, extent_offset * crypt_stat->extent_size,
crypt_stat->extent_size, extent_iv); crypt_stat->extent_size, extent_iv);
if (rc < 0) { if (rc < 0) {
printk(KERN_ERR "%s: Error attempting to decrypt to page with " printk(KERN_ERR "%s: Error attempting to decrypt to page with "
...@@ -620,8 +622,9 @@ int ecryptfs_decrypt_page(struct page *page) ...@@ -620,8 +622,9 @@ int ecryptfs_decrypt_page(struct page *page)
&offset, ((page->index * (PAGE_CACHE_SIZE &offset, ((page->index * (PAGE_CACHE_SIZE
/ crypt_stat->extent_size)) / crypt_stat->extent_size))
+ extent_offset), crypt_stat); + extent_offset), crypt_stat);
rc = ecryptfs_read_lower(enc_extent_virt, offset, rc = ecryptfs_read_lower((enc_extent_virt +
crypt_stat->extent_size, extent_offset * crypt_stat->extent_size),
offset, crypt_stat->extent_size,
ecryptfs_inode); ecryptfs_inode);
if (rc < 0) { if (rc < 0) {
ecryptfs_printk(KERN_ERR, "Error attempting " ecryptfs_printk(KERN_ERR, "Error attempting "
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment