summaryrefslogtreecommitdiff
path: root/fs/ecryptfs
diff options
context:
space:
mode:
authorTyler Hicks <tyhicks@canonical.com>2013-04-17 10:21:24 +0400
committerTyler Hicks <tyhicks@canonical.com>2013-06-08 04:28:21 +0400
commit12003e5b18ca33807b3f9448309ec92184192b85 (patch)
treed4c9ddf9ff9e70956286c369f4ed0b48edb5da2d /fs/ecryptfs
parentfc8b14d338f6265533a8f82db1325fa112b530ba (diff)
downloadlinux-12003e5b18ca33807b3f9448309ec92184192b85.tar.xz
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: Tyler Hicks <tyhicks@canonical.com>
Diffstat (limited to 'fs/ecryptfs')
-rw-r--r--fs/ecryptfs/crypto.c29
1 files changed, 16 insertions, 13 deletions
diff --git a/fs/ecryptfs/crypto.c b/fs/ecryptfs/crypto.c
index f71ec125290d..e8976c004669 100644
--- a/fs/ecryptfs/crypto.c
+++ b/fs/ecryptfs/crypto.c
@@ -450,10 +450,11 @@ static int ecryptfs_encrypt_extent(struct page *enc_extent_page,
(unsigned long long)(extent_base + extent_offset), rc);
goto out;
}
- rc = ecryptfs_encrypt_page_offset(crypt_stat, enc_extent_page, 0,
- page, (extent_offset
- * crypt_stat->extent_size),
- crypt_stat->extent_size, extent_iv);
+ rc = ecryptfs_encrypt_page_offset(crypt_stat, enc_extent_page,
+ extent_offset * crypt_stat->extent_size,
+ page,
+ extent_offset * crypt_stat->extent_size,
+ crypt_stat->extent_size, extent_iv);
if (rc < 0) {
printk(KERN_ERR "%s: Error attempting to encrypt page with "
"page->index = [%ld], extent_offset = [%ld]; "
@@ -520,8 +521,9 @@ int ecryptfs_encrypt_page(struct page *page)
* (PAGE_CACHE_SIZE
/ crypt_stat->extent_size))
+ extent_offset), crypt_stat);
- rc = ecryptfs_write_lower(ecryptfs_inode, enc_extent_virt,
- offset, crypt_stat->extent_size);
+ rc = ecryptfs_write_lower(ecryptfs_inode, (enc_extent_virt +
+ extent_offset * crypt_stat->extent_size),
+ offset, crypt_stat->extent_size);
if (rc < 0) {
ecryptfs_printk(KERN_ERR, "Error attempting "
"to write lower page; rc = [%d]"
@@ -558,10 +560,10 @@ static int ecryptfs_decrypt_extent(struct page *page,
goto out;
}
rc = ecryptfs_decrypt_page_offset(crypt_stat, page,
- (extent_offset
- * crypt_stat->extent_size),
- enc_extent_page, 0,
- crypt_stat->extent_size, extent_iv);
+ extent_offset * crypt_stat->extent_size,
+ enc_extent_page,
+ extent_offset * crypt_stat->extent_size,
+ crypt_stat->extent_size, extent_iv);
if (rc < 0) {
printk(KERN_ERR "%s: Error attempting to decrypt to page with "
"page->index = [%ld], extent_offset = [%ld]; "
@@ -620,9 +622,10 @@ int ecryptfs_decrypt_page(struct page *page)
&offset, ((page->index * (PAGE_CACHE_SIZE
/ crypt_stat->extent_size))
+ extent_offset), crypt_stat);
- rc = ecryptfs_read_lower(enc_extent_virt, offset,
- crypt_stat->extent_size,
- ecryptfs_inode);
+ rc = ecryptfs_read_lower((enc_extent_virt +
+ extent_offset * crypt_stat->extent_size),
+ offset, crypt_stat->extent_size,
+ ecryptfs_inode);
if (rc < 0) {
ecryptfs_printk(KERN_ERR, "Error attempting "
"to read lower page; rc = [%d]"