diff options
Diffstat (limited to 'fs/ecryptfs/crypto.c')
-rw-r--r-- | fs/ecryptfs/crypto.c | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/fs/ecryptfs/crypto.c b/fs/ecryptfs/crypto.c index bae20ad1a504..fbb6e5eed697 100644 --- a/fs/ecryptfs/crypto.c +++ b/fs/ecryptfs/crypto.c | |||
@@ -509,13 +509,14 @@ int ecryptfs_encrypt_page(struct page *page) | |||
509 | + extent_offset), crypt_stat); | 509 | + extent_offset), crypt_stat); |
510 | rc = ecryptfs_write_lower(ecryptfs_inode, enc_extent_virt, | 510 | rc = ecryptfs_write_lower(ecryptfs_inode, enc_extent_virt, |
511 | offset, crypt_stat->extent_size); | 511 | offset, crypt_stat->extent_size); |
512 | if (rc) { | 512 | if (rc < 0) { |
513 | ecryptfs_printk(KERN_ERR, "Error attempting " | 513 | ecryptfs_printk(KERN_ERR, "Error attempting " |
514 | "to write lower page; rc = [%d]" | 514 | "to write lower page; rc = [%d]" |
515 | "\n", rc); | 515 | "\n", rc); |
516 | goto out; | 516 | goto out; |
517 | } | 517 | } |
518 | } | 518 | } |
519 | rc = 0; | ||
519 | out: | 520 | out: |
520 | if (enc_extent_page) { | 521 | if (enc_extent_page) { |
521 | kunmap(enc_extent_page); | 522 | kunmap(enc_extent_page); |
@@ -631,7 +632,7 @@ int ecryptfs_decrypt_page(struct page *page) | |||
631 | rc = ecryptfs_read_lower(enc_extent_virt, offset, | 632 | rc = ecryptfs_read_lower(enc_extent_virt, offset, |
632 | crypt_stat->extent_size, | 633 | crypt_stat->extent_size, |
633 | ecryptfs_inode); | 634 | ecryptfs_inode); |
634 | if (rc) { | 635 | if (rc < 0) { |
635 | ecryptfs_printk(KERN_ERR, "Error attempting " | 636 | ecryptfs_printk(KERN_ERR, "Error attempting " |
636 | "to read lower page; rc = [%d]" | 637 | "to read lower page; rc = [%d]" |
637 | "\n", rc); | 638 | "\n", rc); |
@@ -1213,14 +1214,15 @@ int ecryptfs_read_and_validate_header_region(char *data, | |||
1213 | crypt_stat->extent_size = ECRYPTFS_DEFAULT_EXTENT_SIZE; | 1214 | crypt_stat->extent_size = ECRYPTFS_DEFAULT_EXTENT_SIZE; |
1214 | rc = ecryptfs_read_lower(data, 0, crypt_stat->extent_size, | 1215 | rc = ecryptfs_read_lower(data, 0, crypt_stat->extent_size, |
1215 | ecryptfs_inode); | 1216 | ecryptfs_inode); |
1216 | if (rc) { | 1217 | if (rc < 0) { |
1217 | printk(KERN_ERR "%s: Error reading header region; rc = [%d]\n", | 1218 | printk(KERN_ERR "%s: Error reading header region; rc = [%d]\n", |
1218 | __func__, rc); | 1219 | __func__, rc); |
1219 | goto out; | 1220 | goto out; |
1220 | } | 1221 | } |
1221 | if (!contains_ecryptfs_marker(data + ECRYPTFS_FILE_SIZE_BYTES)) { | 1222 | if (!contains_ecryptfs_marker(data + ECRYPTFS_FILE_SIZE_BYTES)) { |
1222 | rc = -EINVAL; | 1223 | rc = -EINVAL; |
1223 | } | 1224 | } else |
1225 | rc = 0; | ||
1224 | out: | 1226 | out: |
1225 | return rc; | 1227 | return rc; |
1226 | } | 1228 | } |
@@ -1315,10 +1317,11 @@ ecryptfs_write_metadata_to_contents(struct dentry *ecryptfs_dentry, | |||
1315 | 1317 | ||
1316 | rc = ecryptfs_write_lower(ecryptfs_dentry->d_inode, virt, | 1318 | rc = ecryptfs_write_lower(ecryptfs_dentry->d_inode, virt, |
1317 | 0, virt_len); | 1319 | 0, virt_len); |
1318 | if (rc) | 1320 | if (rc < 0) |
1319 | printk(KERN_ERR "%s: Error attempting to write header " | 1321 | printk(KERN_ERR "%s: Error attempting to write header " |
1320 | "information to lower file; rc = [%d]\n", __func__, | 1322 | "information to lower file; rc = [%d]\n", __func__, rc); |
1321 | rc); | 1323 | else |
1324 | rc = 0; | ||
1322 | return rc; | 1325 | return rc; |
1323 | } | 1326 | } |
1324 | 1327 | ||
@@ -1598,7 +1601,7 @@ int ecryptfs_read_metadata(struct dentry *ecryptfs_dentry) | |||
1598 | } | 1601 | } |
1599 | rc = ecryptfs_read_lower(page_virt, 0, crypt_stat->extent_size, | 1602 | rc = ecryptfs_read_lower(page_virt, 0, crypt_stat->extent_size, |
1600 | ecryptfs_inode); | 1603 | ecryptfs_inode); |
1601 | if (!rc) | 1604 | if (rc >= 0) |
1602 | rc = ecryptfs_read_headers_virt(page_virt, crypt_stat, | 1605 | rc = ecryptfs_read_headers_virt(page_virt, crypt_stat, |
1603 | ecryptfs_dentry, | 1606 | ecryptfs_dentry, |
1604 | ECRYPTFS_VALIDATE_HEADER_SIZE); | 1607 | ECRYPTFS_VALIDATE_HEADER_SIZE); |