diff options
| author | Linus Torvalds <torvalds@linux-foundation.org> | 2011-01-17 15:39:57 -0500 |
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2011-01-17 15:39:57 -0500 |
| commit | 9e8a462a0141b12e22c4a2f0c12e0542770401f0 (patch) | |
| tree | c0e32e5877f099b43e75afc5faecc944207dd51c | |
| parent | cf78859f520f8275318f47d7864f4459d940cb6b (diff) | |
| parent | 24562486be76cf223b8d911f45e1d26eb3364b13 (diff) | |
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/ecryptfs/ecryptfs-2.6
* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/ecryptfs/ecryptfs-2.6:
ecryptfs: remove unnecessary decrypt when extending a file
ecryptfs: Fix ecryptfs_printk() size_t warnings
fs/ecryptfs: Add printf format/argument verification and fix fallout
ecryptfs: fixed testing of file descriptor flags
ecryptfs: test lower_file pointer when lower_file_mutex is locked
ecryptfs: missing initialization of the superblock 'magic' field
ecryptfs: moved ECRYPTFS_SUPER_MAGIC definition to linux/magic.h
ecryptfs: fix truncation error in ecryptfs_read_update_atime
| -rw-r--r-- | fs/ecryptfs/crypto.c | 30 | ||||
| -rw-r--r-- | fs/ecryptfs/ecryptfs_kernel.h | 2 | ||||
| -rw-r--r-- | fs/ecryptfs/file.c | 28 | ||||
| -rw-r--r-- | fs/ecryptfs/inode.c | 32 | ||||
| -rw-r--r-- | fs/ecryptfs/keystore.c | 26 | ||||
| -rw-r--r-- | fs/ecryptfs/main.c | 9 | ||||
| -rw-r--r-- | fs/ecryptfs/mmap.c | 35 | ||||
| -rw-r--r-- | include/linux/magic.h | 1 |
8 files changed, 83 insertions, 80 deletions
diff --git a/fs/ecryptfs/crypto.c b/fs/ecryptfs/crypto.c index cbadc1bee6e7..bfd8b680e648 100644 --- a/fs/ecryptfs/crypto.c +++ b/fs/ecryptfs/crypto.c | |||
| @@ -348,7 +348,7 @@ static int encrypt_scatterlist(struct ecryptfs_crypt_stat *crypt_stat, | |||
| 348 | BUG_ON(!crypt_stat || !crypt_stat->tfm | 348 | BUG_ON(!crypt_stat || !crypt_stat->tfm |
| 349 | || !(crypt_stat->flags & ECRYPTFS_STRUCT_INITIALIZED)); | 349 | || !(crypt_stat->flags & ECRYPTFS_STRUCT_INITIALIZED)); |
| 350 | if (unlikely(ecryptfs_verbosity > 0)) { | 350 | if (unlikely(ecryptfs_verbosity > 0)) { |
| 351 | ecryptfs_printk(KERN_DEBUG, "Key size [%d]; key:\n", | 351 | ecryptfs_printk(KERN_DEBUG, "Key size [%zd]; key:\n", |
| 352 | crypt_stat->key_size); | 352 | crypt_stat->key_size); |
| 353 | ecryptfs_dump_hex(crypt_stat->key, | 353 | ecryptfs_dump_hex(crypt_stat->key, |
| 354 | crypt_stat->key_size); | 354 | crypt_stat->key_size); |
| @@ -413,10 +413,9 @@ static int ecryptfs_encrypt_extent(struct page *enc_extent_page, | |||
| 413 | rc = ecryptfs_derive_iv(extent_iv, crypt_stat, | 413 | rc = ecryptfs_derive_iv(extent_iv, crypt_stat, |
| 414 | (extent_base + extent_offset)); | 414 | (extent_base + extent_offset)); |
| 415 | if (rc) { | 415 | if (rc) { |
| 416 | ecryptfs_printk(KERN_ERR, "Error attempting to " | 416 | ecryptfs_printk(KERN_ERR, "Error attempting to derive IV for " |
| 417 | "derive IV for extent [0x%.16x]; " | 417 | "extent [0x%.16llx]; rc = [%d]\n", |
| 418 | "rc = [%d]\n", (extent_base + extent_offset), | 418 | (unsigned long long)(extent_base + extent_offset), rc); |
| 419 | rc); | ||
| 420 | goto out; | 419 | goto out; |
| 421 | } | 420 | } |
| 422 | if (unlikely(ecryptfs_verbosity > 0)) { | 421 | if (unlikely(ecryptfs_verbosity > 0)) { |
| @@ -443,9 +442,9 @@ static int ecryptfs_encrypt_extent(struct page *enc_extent_page, | |||
| 443 | } | 442 | } |
| 444 | rc = 0; | 443 | rc = 0; |
| 445 | if (unlikely(ecryptfs_verbosity > 0)) { | 444 | if (unlikely(ecryptfs_verbosity > 0)) { |
| 446 | ecryptfs_printk(KERN_DEBUG, "Encrypt extent [0x%.16x]; " | 445 | ecryptfs_printk(KERN_DEBUG, "Encrypt extent [0x%.16llx]; " |
| 447 | "rc = [%d]\n", (extent_base + extent_offset), | 446 | "rc = [%d]\n", |
| 448 | rc); | 447 | (unsigned long long)(extent_base + extent_offset), rc); |
| 449 | ecryptfs_printk(KERN_DEBUG, "First 8 bytes after " | 448 | ecryptfs_printk(KERN_DEBUG, "First 8 bytes after " |
| 450 | "encryption:\n"); | 449 | "encryption:\n"); |
| 451 | ecryptfs_dump_hex((char *)(page_address(enc_extent_page)), 8); | 450 | ecryptfs_dump_hex((char *)(page_address(enc_extent_page)), 8); |
| @@ -540,10 +539,9 @@ static int ecryptfs_decrypt_extent(struct page *page, | |||
| 540 | rc = ecryptfs_derive_iv(extent_iv, crypt_stat, | 539 | rc = ecryptfs_derive_iv(extent_iv, crypt_stat, |
| 541 | (extent_base + extent_offset)); | 540 | (extent_base + extent_offset)); |
| 542 | if (rc) { | 541 | if (rc) { |
| 543 | ecryptfs_printk(KERN_ERR, "Error attempting to " | 542 | ecryptfs_printk(KERN_ERR, "Error attempting to derive IV for " |
| 544 | "derive IV for extent [0x%.16x]; " | 543 | "extent [0x%.16llx]; rc = [%d]\n", |
| 545 | "rc = [%d]\n", (extent_base + extent_offset), | 544 | (unsigned long long)(extent_base + extent_offset), rc); |
| 546 | rc); | ||
| 547 | goto out; | 545 | goto out; |
| 548 | } | 546 | } |
| 549 | if (unlikely(ecryptfs_verbosity > 0)) { | 547 | if (unlikely(ecryptfs_verbosity > 0)) { |
| @@ -571,9 +569,9 @@ static int ecryptfs_decrypt_extent(struct page *page, | |||
| 571 | } | 569 | } |
| 572 | rc = 0; | 570 | rc = 0; |
| 573 | if (unlikely(ecryptfs_verbosity > 0)) { | 571 | if (unlikely(ecryptfs_verbosity > 0)) { |
| 574 | ecryptfs_printk(KERN_DEBUG, "Decrypt extent [0x%.16x]; " | 572 | ecryptfs_printk(KERN_DEBUG, "Decrypt extent [0x%.16llx]; " |
| 575 | "rc = [%d]\n", (extent_base + extent_offset), | 573 | "rc = [%d]\n", |
| 576 | rc); | 574 | (unsigned long long)(extent_base + extent_offset), rc); |
| 577 | ecryptfs_printk(KERN_DEBUG, "First 8 bytes after " | 575 | ecryptfs_printk(KERN_DEBUG, "First 8 bytes after " |
| 578 | "decryption:\n"); | 576 | "decryption:\n"); |
| 579 | ecryptfs_dump_hex((char *)(page_address(page) | 577 | ecryptfs_dump_hex((char *)(page_address(page) |
| @@ -780,7 +778,7 @@ int ecryptfs_init_crypt_ctx(struct ecryptfs_crypt_stat *crypt_stat) | |||
| 780 | } | 778 | } |
| 781 | ecryptfs_printk(KERN_DEBUG, | 779 | ecryptfs_printk(KERN_DEBUG, |
| 782 | "Initializing cipher [%s]; strlen = [%d]; " | 780 | "Initializing cipher [%s]; strlen = [%d]; " |
| 783 | "key_size_bits = [%d]\n", | 781 | "key_size_bits = [%zd]\n", |
| 784 | crypt_stat->cipher, (int)strlen(crypt_stat->cipher), | 782 | crypt_stat->cipher, (int)strlen(crypt_stat->cipher), |
| 785 | crypt_stat->key_size << 3); | 783 | crypt_stat->key_size << 3); |
| 786 | if (crypt_stat->tfm) { | 784 | if (crypt_stat->tfm) { |
diff --git a/fs/ecryptfs/ecryptfs_kernel.h b/fs/ecryptfs/ecryptfs_kernel.h index 413a3c48f0bb..dbc84ed96336 100644 --- a/fs/ecryptfs/ecryptfs_kernel.h +++ b/fs/ecryptfs/ecryptfs_kernel.h | |||
| @@ -192,7 +192,6 @@ ecryptfs_get_key_payload_data(struct key *key) | |||
| 192 | (((struct user_key_payload*)key->payload.data)->data); | 192 | (((struct user_key_payload*)key->payload.data)->data); |
| 193 | } | 193 | } |
| 194 | 194 | ||
| 195 | #define ECRYPTFS_SUPER_MAGIC 0xf15f | ||
| 196 | #define ECRYPTFS_MAX_KEYSET_SIZE 1024 | 195 | #define ECRYPTFS_MAX_KEYSET_SIZE 1024 |
| 197 | #define ECRYPTFS_MAX_CIPHER_NAME_SIZE 32 | 196 | #define ECRYPTFS_MAX_CIPHER_NAME_SIZE 32 |
| 198 | #define ECRYPTFS_MAX_NUM_ENC_KEYS 64 | 197 | #define ECRYPTFS_MAX_NUM_ENC_KEYS 64 |
| @@ -584,6 +583,7 @@ ecryptfs_set_dentry_lower_mnt(struct dentry *dentry, struct vfsmount *lower_mnt) | |||
| 584 | 583 | ||
| 585 | #define ecryptfs_printk(type, fmt, arg...) \ | 584 | #define ecryptfs_printk(type, fmt, arg...) \ |
| 586 | __ecryptfs_printk(type "%s: " fmt, __func__, ## arg); | 585 | __ecryptfs_printk(type "%s: " fmt, __func__, ## arg); |
| 586 | __attribute__ ((format(printf, 1, 2))) | ||
| 587 | void __ecryptfs_printk(const char *fmt, ...); | 587 | void __ecryptfs_printk(const char *fmt, ...); |
| 588 | 588 | ||
| 589 | extern const struct file_operations ecryptfs_main_fops; | 589 | extern const struct file_operations ecryptfs_main_fops; |
diff --git a/fs/ecryptfs/file.c b/fs/ecryptfs/file.c index 91da02987bff..81e10e6a9443 100644 --- a/fs/ecryptfs/file.c +++ b/fs/ecryptfs/file.c | |||
| @@ -47,7 +47,7 @@ static ssize_t ecryptfs_read_update_atime(struct kiocb *iocb, | |||
| 47 | const struct iovec *iov, | 47 | const struct iovec *iov, |
| 48 | unsigned long nr_segs, loff_t pos) | 48 | unsigned long nr_segs, loff_t pos) |
| 49 | { | 49 | { |
| 50 | int rc; | 50 | ssize_t rc; |
| 51 | struct dentry *lower_dentry; | 51 | struct dentry *lower_dentry; |
| 52 | struct vfsmount *lower_vfsmount; | 52 | struct vfsmount *lower_vfsmount; |
| 53 | struct file *file = iocb->ki_filp; | 53 | struct file *file = iocb->ki_filp; |
| @@ -191,18 +191,16 @@ static int ecryptfs_open(struct inode *inode, struct file *file) | |||
| 191 | | ECRYPTFS_ENCRYPTED); | 191 | | ECRYPTFS_ENCRYPTED); |
| 192 | } | 192 | } |
| 193 | mutex_unlock(&crypt_stat->cs_mutex); | 193 | mutex_unlock(&crypt_stat->cs_mutex); |
| 194 | if (!ecryptfs_inode_to_private(inode)->lower_file) { | 194 | rc = ecryptfs_init_persistent_file(ecryptfs_dentry); |
| 195 | rc = ecryptfs_init_persistent_file(ecryptfs_dentry); | 195 | if (rc) { |
| 196 | if (rc) { | 196 | printk(KERN_ERR "%s: Error attempting to initialize " |
| 197 | printk(KERN_ERR "%s: Error attempting to initialize " | 197 | "the persistent file for the dentry with name " |
| 198 | "the persistent file for the dentry with name " | 198 | "[%s]; rc = [%d]\n", __func__, |
| 199 | "[%s]; rc = [%d]\n", __func__, | 199 | ecryptfs_dentry->d_name.name, rc); |
| 200 | ecryptfs_dentry->d_name.name, rc); | 200 | goto out_free; |
| 201 | goto out_free; | ||
| 202 | } | ||
| 203 | } | 201 | } |
| 204 | if ((ecryptfs_inode_to_private(inode)->lower_file->f_flags & O_RDONLY) | 202 | if ((ecryptfs_inode_to_private(inode)->lower_file->f_flags & O_ACCMODE) |
| 205 | && !(file->f_flags & O_RDONLY)) { | 203 | == O_RDONLY && (file->f_flags & O_ACCMODE) != O_RDONLY) { |
| 206 | rc = -EPERM; | 204 | rc = -EPERM; |
| 207 | printk(KERN_WARNING "%s: Lower persistent file is RO; eCryptfs " | 205 | printk(KERN_WARNING "%s: Lower persistent file is RO; eCryptfs " |
| 208 | "file must hence be opened RO\n", __func__); | 206 | "file must hence be opened RO\n", __func__); |
| @@ -243,9 +241,9 @@ static int ecryptfs_open(struct inode *inode, struct file *file) | |||
| 243 | } | 241 | } |
| 244 | } | 242 | } |
| 245 | mutex_unlock(&crypt_stat->cs_mutex); | 243 | mutex_unlock(&crypt_stat->cs_mutex); |
| 246 | ecryptfs_printk(KERN_DEBUG, "inode w/ addr = [0x%p], i_ino = [0x%.16x] " | 244 | ecryptfs_printk(KERN_DEBUG, "inode w/ addr = [0x%p], i_ino = " |
| 247 | "size: [0x%.16x]\n", inode, inode->i_ino, | 245 | "[0x%.16lx] size: [0x%.16llx]\n", inode, inode->i_ino, |
| 248 | i_size_read(inode)); | 246 | (unsigned long long)i_size_read(inode)); |
| 249 | goto out; | 247 | goto out; |
| 250 | out_free: | 248 | out_free: |
| 251 | kmem_cache_free(ecryptfs_file_info_cache, | 249 | kmem_cache_free(ecryptfs_file_info_cache, |
diff --git a/fs/ecryptfs/inode.c b/fs/ecryptfs/inode.c index 64ff02330752..bd33f87a1907 100644 --- a/fs/ecryptfs/inode.c +++ b/fs/ecryptfs/inode.c | |||
| @@ -185,15 +185,13 @@ static int ecryptfs_initialize_file(struct dentry *ecryptfs_dentry) | |||
| 185 | "context; rc = [%d]\n", rc); | 185 | "context; rc = [%d]\n", rc); |
| 186 | goto out; | 186 | goto out; |
| 187 | } | 187 | } |
| 188 | if (!ecryptfs_inode_to_private(ecryptfs_dentry->d_inode)->lower_file) { | 188 | rc = ecryptfs_init_persistent_file(ecryptfs_dentry); |
| 189 | rc = ecryptfs_init_persistent_file(ecryptfs_dentry); | 189 | if (rc) { |
| 190 | if (rc) { | 190 | printk(KERN_ERR "%s: Error attempting to initialize " |
| 191 | printk(KERN_ERR "%s: Error attempting to initialize " | 191 | "the persistent file for the dentry with name " |
| 192 | "the persistent file for the dentry with name " | 192 | "[%s]; rc = [%d]\n", __func__, |
| 193 | "[%s]; rc = [%d]\n", __func__, | 193 | ecryptfs_dentry->d_name.name, rc); |
| 194 | ecryptfs_dentry->d_name.name, rc); | 194 | goto out; |
| 195 | goto out; | ||
| 196 | } | ||
| 197 | } | 195 | } |
| 198 | rc = ecryptfs_write_metadata(ecryptfs_dentry); | 196 | rc = ecryptfs_write_metadata(ecryptfs_dentry); |
| 199 | if (rc) { | 197 | if (rc) { |
| @@ -302,15 +300,13 @@ int ecryptfs_lookup_and_interpose_lower(struct dentry *ecryptfs_dentry, | |||
| 302 | rc = -ENOMEM; | 300 | rc = -ENOMEM; |
| 303 | goto out; | 301 | goto out; |
| 304 | } | 302 | } |
| 305 | if (!ecryptfs_inode_to_private(ecryptfs_dentry->d_inode)->lower_file) { | 303 | rc = ecryptfs_init_persistent_file(ecryptfs_dentry); |
| 306 | rc = ecryptfs_init_persistent_file(ecryptfs_dentry); | 304 | if (rc) { |
| 307 | if (rc) { | 305 | printk(KERN_ERR "%s: Error attempting to initialize " |
| 308 | printk(KERN_ERR "%s: Error attempting to initialize " | 306 | "the persistent file for the dentry with name " |
| 309 | "the persistent file for the dentry with name " | 307 | "[%s]; rc = [%d]\n", __func__, |
| 310 | "[%s]; rc = [%d]\n", __func__, | 308 | ecryptfs_dentry->d_name.name, rc); |
| 311 | ecryptfs_dentry->d_name.name, rc); | 309 | goto out_free_kmem; |
| 312 | goto out_free_kmem; | ||
| 313 | } | ||
| 314 | } | 310 | } |
| 315 | crypt_stat = &ecryptfs_inode_to_private( | 311 | crypt_stat = &ecryptfs_inode_to_private( |
| 316 | ecryptfs_dentry->d_inode)->crypt_stat; | 312 | ecryptfs_dentry->d_inode)->crypt_stat; |
diff --git a/fs/ecryptfs/keystore.c b/fs/ecryptfs/keystore.c index b1f6858a5223..c1436cff6f2d 100644 --- a/fs/ecryptfs/keystore.c +++ b/fs/ecryptfs/keystore.c | |||
| @@ -59,7 +59,7 @@ static int process_request_key_err(long err_code) | |||
| 59 | break; | 59 | break; |
| 60 | default: | 60 | default: |
| 61 | ecryptfs_printk(KERN_WARNING, "Unknown error code: " | 61 | ecryptfs_printk(KERN_WARNING, "Unknown error code: " |
| 62 | "[0x%.16x]\n", err_code); | 62 | "[0x%.16lx]\n", err_code); |
| 63 | rc = -EINVAL; | 63 | rc = -EINVAL; |
| 64 | } | 64 | } |
| 65 | return rc; | 65 | return rc; |
| @@ -130,7 +130,7 @@ int ecryptfs_write_packet_length(char *dest, size_t size, | |||
| 130 | } else { | 130 | } else { |
| 131 | rc = -EINVAL; | 131 | rc = -EINVAL; |
| 132 | ecryptfs_printk(KERN_WARNING, | 132 | ecryptfs_printk(KERN_WARNING, |
| 133 | "Unsupported packet size: [%d]\n", size); | 133 | "Unsupported packet size: [%zd]\n", size); |
| 134 | } | 134 | } |
| 135 | return rc; | 135 | return rc; |
| 136 | } | 136 | } |
| @@ -1672,7 +1672,7 @@ decrypt_passphrase_encrypted_session_key(struct ecryptfs_auth_tok *auth_tok, | |||
| 1672 | auth_tok->session_key.decrypted_key_size); | 1672 | auth_tok->session_key.decrypted_key_size); |
| 1673 | crypt_stat->flags |= ECRYPTFS_KEY_VALID; | 1673 | crypt_stat->flags |= ECRYPTFS_KEY_VALID; |
| 1674 | if (unlikely(ecryptfs_verbosity > 0)) { | 1674 | if (unlikely(ecryptfs_verbosity > 0)) { |
| 1675 | ecryptfs_printk(KERN_DEBUG, "FEK of size [%d]:\n", | 1675 | ecryptfs_printk(KERN_DEBUG, "FEK of size [%zd]:\n", |
| 1676 | crypt_stat->key_size); | 1676 | crypt_stat->key_size); |
| 1677 | ecryptfs_dump_hex(crypt_stat->key, | 1677 | ecryptfs_dump_hex(crypt_stat->key, |
| 1678 | crypt_stat->key_size); | 1678 | crypt_stat->key_size); |
| @@ -1754,7 +1754,7 @@ int ecryptfs_parse_packet_set(struct ecryptfs_crypt_stat *crypt_stat, | |||
| 1754 | if (ECRYPTFS_SIG_SIZE != tag_11_contents_size) { | 1754 | if (ECRYPTFS_SIG_SIZE != tag_11_contents_size) { |
| 1755 | ecryptfs_printk(KERN_ERR, "Expected " | 1755 | ecryptfs_printk(KERN_ERR, "Expected " |
| 1756 | "signature of size [%d]; " | 1756 | "signature of size [%d]; " |
| 1757 | "read size [%d]\n", | 1757 | "read size [%zd]\n", |
| 1758 | ECRYPTFS_SIG_SIZE, | 1758 | ECRYPTFS_SIG_SIZE, |
| 1759 | tag_11_contents_size); | 1759 | tag_11_contents_size); |
| 1760 | rc = -EIO; | 1760 | rc = -EIO; |
| @@ -1787,8 +1787,8 @@ int ecryptfs_parse_packet_set(struct ecryptfs_crypt_stat *crypt_stat, | |||
| 1787 | goto out_wipe_list; | 1787 | goto out_wipe_list; |
| 1788 | break; | 1788 | break; |
| 1789 | default: | 1789 | default: |
| 1790 | ecryptfs_printk(KERN_DEBUG, "No packet at offset " | 1790 | ecryptfs_printk(KERN_DEBUG, "No packet at offset [%zd] " |
| 1791 | "[%d] of the file header; hex value of " | 1791 | "of the file header; hex value of " |
| 1792 | "character is [0x%.2x]\n", i, src[i]); | 1792 | "character is [0x%.2x]\n", i, src[i]); |
| 1793 | next_packet_is_auth_tok_packet = 0; | 1793 | next_packet_is_auth_tok_packet = 0; |
| 1794 | } | 1794 | } |
| @@ -1864,8 +1864,8 @@ found_matching_auth_tok: | |||
| 1864 | "session key for authentication token with sig " | 1864 | "session key for authentication token with sig " |
| 1865 | "[%.*s]; rc = [%d]. Removing auth tok " | 1865 | "[%.*s]; rc = [%d]. Removing auth tok " |
| 1866 | "candidate from the list and searching for " | 1866 | "candidate from the list and searching for " |
| 1867 | "the next match.\n", candidate_auth_tok_sig, | 1867 | "the next match.\n", ECRYPTFS_SIG_SIZE_HEX, |
| 1868 | ECRYPTFS_SIG_SIZE_HEX, rc); | 1868 | candidate_auth_tok_sig, rc); |
| 1869 | list_for_each_entry_safe(auth_tok_list_item, | 1869 | list_for_each_entry_safe(auth_tok_list_item, |
| 1870 | auth_tok_list_item_tmp, | 1870 | auth_tok_list_item_tmp, |
| 1871 | &auth_tok_list, list) { | 1871 | &auth_tok_list, list) { |
| @@ -2168,7 +2168,7 @@ write_tag_3_packet(char *dest, size_t *remaining_bytes, | |||
| 2168 | if (encrypted_session_key_valid) { | 2168 | if (encrypted_session_key_valid) { |
| 2169 | ecryptfs_printk(KERN_DEBUG, "encrypted_session_key_valid != 0; " | 2169 | ecryptfs_printk(KERN_DEBUG, "encrypted_session_key_valid != 0; " |
| 2170 | "using auth_tok->session_key.encrypted_key, " | 2170 | "using auth_tok->session_key.encrypted_key, " |
| 2171 | "where key_rec->enc_key_size = [%d]\n", | 2171 | "where key_rec->enc_key_size = [%zd]\n", |
| 2172 | key_rec->enc_key_size); | 2172 | key_rec->enc_key_size); |
| 2173 | memcpy(key_rec->enc_key, | 2173 | memcpy(key_rec->enc_key, |
| 2174 | auth_tok->session_key.encrypted_key, | 2174 | auth_tok->session_key.encrypted_key, |
| @@ -2198,7 +2198,7 @@ write_tag_3_packet(char *dest, size_t *remaining_bytes, | |||
| 2198 | if (rc < 1 || rc > 2) { | 2198 | if (rc < 1 || rc > 2) { |
| 2199 | ecryptfs_printk(KERN_ERR, "Error generating scatterlist " | 2199 | ecryptfs_printk(KERN_ERR, "Error generating scatterlist " |
| 2200 | "for crypt_stat session key; expected rc = 1; " | 2200 | "for crypt_stat session key; expected rc = 1; " |
| 2201 | "got rc = [%d]. key_rec->enc_key_size = [%d]\n", | 2201 | "got rc = [%d]. key_rec->enc_key_size = [%zd]\n", |
| 2202 | rc, key_rec->enc_key_size); | 2202 | rc, key_rec->enc_key_size); |
| 2203 | rc = -ENOMEM; | 2203 | rc = -ENOMEM; |
| 2204 | goto out; | 2204 | goto out; |
| @@ -2209,7 +2209,7 @@ write_tag_3_packet(char *dest, size_t *remaining_bytes, | |||
| 2209 | ecryptfs_printk(KERN_ERR, "Error generating scatterlist " | 2209 | ecryptfs_printk(KERN_ERR, "Error generating scatterlist " |
| 2210 | "for crypt_stat encrypted session key; " | 2210 | "for crypt_stat encrypted session key; " |
| 2211 | "expected rc = 1; got rc = [%d]. " | 2211 | "expected rc = 1; got rc = [%d]. " |
| 2212 | "key_rec->enc_key_size = [%d]\n", rc, | 2212 | "key_rec->enc_key_size = [%zd]\n", rc, |
| 2213 | key_rec->enc_key_size); | 2213 | key_rec->enc_key_size); |
| 2214 | rc = -ENOMEM; | 2214 | rc = -ENOMEM; |
| 2215 | goto out; | 2215 | goto out; |
| @@ -2224,7 +2224,7 @@ write_tag_3_packet(char *dest, size_t *remaining_bytes, | |||
| 2224 | goto out; | 2224 | goto out; |
| 2225 | } | 2225 | } |
| 2226 | rc = 0; | 2226 | rc = 0; |
| 2227 | ecryptfs_printk(KERN_DEBUG, "Encrypting [%d] bytes of the key\n", | 2227 | ecryptfs_printk(KERN_DEBUG, "Encrypting [%zd] bytes of the key\n", |
| 2228 | crypt_stat->key_size); | 2228 | crypt_stat->key_size); |
| 2229 | rc = crypto_blkcipher_encrypt(&desc, dst_sg, src_sg, | 2229 | rc = crypto_blkcipher_encrypt(&desc, dst_sg, src_sg, |
| 2230 | (*key_rec).enc_key_size); | 2230 | (*key_rec).enc_key_size); |
| @@ -2235,7 +2235,7 @@ write_tag_3_packet(char *dest, size_t *remaining_bytes, | |||
| 2235 | } | 2235 | } |
| 2236 | ecryptfs_printk(KERN_DEBUG, "This should be the encrypted key:\n"); | 2236 | ecryptfs_printk(KERN_DEBUG, "This should be the encrypted key:\n"); |
| 2237 | if (ecryptfs_verbosity > 0) { | 2237 | if (ecryptfs_verbosity > 0) { |
| 2238 | ecryptfs_printk(KERN_DEBUG, "EFEK of size [%d]:\n", | 2238 | ecryptfs_printk(KERN_DEBUG, "EFEK of size [%zd]:\n", |
| 2239 | key_rec->enc_key_size); | 2239 | key_rec->enc_key_size); |
| 2240 | ecryptfs_dump_hex(key_rec->enc_key, | 2240 | ecryptfs_dump_hex(key_rec->enc_key, |
| 2241 | key_rec->enc_key_size); | 2241 | key_rec->enc_key_size); |
diff --git a/fs/ecryptfs/main.c b/fs/ecryptfs/main.c index d3b28abdd6aa..758323a0f09a 100644 --- a/fs/ecryptfs/main.c +++ b/fs/ecryptfs/main.c | |||
| @@ -36,6 +36,7 @@ | |||
| 36 | #include <linux/parser.h> | 36 | #include <linux/parser.h> |
| 37 | #include <linux/fs_stack.h> | 37 | #include <linux/fs_stack.h> |
| 38 | #include <linux/slab.h> | 38 | #include <linux/slab.h> |
| 39 | #include <linux/magic.h> | ||
| 39 | #include "ecryptfs_kernel.h" | 40 | #include "ecryptfs_kernel.h" |
| 40 | 41 | ||
| 41 | /** | 42 | /** |
| @@ -564,6 +565,7 @@ static struct dentry *ecryptfs_mount(struct file_system_type *fs_type, int flags | |||
| 564 | ecryptfs_set_superblock_lower(s, path.dentry->d_sb); | 565 | ecryptfs_set_superblock_lower(s, path.dentry->d_sb); |
| 565 | s->s_maxbytes = path.dentry->d_sb->s_maxbytes; | 566 | s->s_maxbytes = path.dentry->d_sb->s_maxbytes; |
| 566 | s->s_blocksize = path.dentry->d_sb->s_blocksize; | 567 | s->s_blocksize = path.dentry->d_sb->s_blocksize; |
| 568 | s->s_magic = ECRYPTFS_SUPER_MAGIC; | ||
| 567 | 569 | ||
| 568 | inode = ecryptfs_get_inode(path.dentry->d_inode, s); | 570 | inode = ecryptfs_get_inode(path.dentry->d_inode, s); |
| 569 | rc = PTR_ERR(inode); | 571 | rc = PTR_ERR(inode); |
| @@ -808,9 +810,10 @@ static int __init ecryptfs_init(void) | |||
| 808 | ecryptfs_printk(KERN_ERR, "The eCryptfs extent size is " | 810 | ecryptfs_printk(KERN_ERR, "The eCryptfs extent size is " |
| 809 | "larger than the host's page size, and so " | 811 | "larger than the host's page size, and so " |
| 810 | "eCryptfs cannot run on this system. The " | 812 | "eCryptfs cannot run on this system. The " |
| 811 | "default eCryptfs extent size is [%d] bytes; " | 813 | "default eCryptfs extent size is [%u] bytes; " |
| 812 | "the page size is [%d] bytes.\n", | 814 | "the page size is [%lu] bytes.\n", |
| 813 | ECRYPTFS_DEFAULT_EXTENT_SIZE, PAGE_CACHE_SIZE); | 815 | ECRYPTFS_DEFAULT_EXTENT_SIZE, |
| 816 | (unsigned long)PAGE_CACHE_SIZE); | ||
| 814 | goto out; | 817 | goto out; |
| 815 | } | 818 | } |
| 816 | rc = ecryptfs_init_kmem_caches(); | 819 | rc = ecryptfs_init_kmem_caches(); |
diff --git a/fs/ecryptfs/mmap.c b/fs/ecryptfs/mmap.c index b1d82756544b..cc64fca89f8d 100644 --- a/fs/ecryptfs/mmap.c +++ b/fs/ecryptfs/mmap.c | |||
| @@ -65,7 +65,7 @@ static int ecryptfs_writepage(struct page *page, struct writeback_control *wbc) | |||
| 65 | rc = ecryptfs_encrypt_page(page); | 65 | rc = ecryptfs_encrypt_page(page); |
| 66 | if (rc) { | 66 | if (rc) { |
| 67 | ecryptfs_printk(KERN_WARNING, "Error encrypting " | 67 | ecryptfs_printk(KERN_WARNING, "Error encrypting " |
| 68 | "page (upper index [0x%.16x])\n", page->index); | 68 | "page (upper index [0x%.16lx])\n", page->index); |
| 69 | ClearPageUptodate(page); | 69 | ClearPageUptodate(page); |
| 70 | goto out; | 70 | goto out; |
| 71 | } | 71 | } |
| @@ -237,7 +237,7 @@ out: | |||
| 237 | ClearPageUptodate(page); | 237 | ClearPageUptodate(page); |
| 238 | else | 238 | else |
| 239 | SetPageUptodate(page); | 239 | SetPageUptodate(page); |
| 240 | ecryptfs_printk(KERN_DEBUG, "Unlocking page with index = [0x%.16x]\n", | 240 | ecryptfs_printk(KERN_DEBUG, "Unlocking page with index = [0x%.16lx]\n", |
| 241 | page->index); | 241 | page->index); |
| 242 | unlock_page(page); | 242 | unlock_page(page); |
| 243 | return rc; | 243 | return rc; |
| @@ -290,6 +290,7 @@ static int ecryptfs_write_begin(struct file *file, | |||
| 290 | return -ENOMEM; | 290 | return -ENOMEM; |
| 291 | *pagep = page; | 291 | *pagep = page; |
| 292 | 292 | ||
| 293 | prev_page_end_size = ((loff_t)index << PAGE_CACHE_SHIFT); | ||
| 293 | if (!PageUptodate(page)) { | 294 | if (!PageUptodate(page)) { |
| 294 | struct ecryptfs_crypt_stat *crypt_stat = | 295 | struct ecryptfs_crypt_stat *crypt_stat = |
| 295 | &ecryptfs_inode_to_private(mapping->host)->crypt_stat; | 296 | &ecryptfs_inode_to_private(mapping->host)->crypt_stat; |
| @@ -335,18 +336,23 @@ static int ecryptfs_write_begin(struct file *file, | |||
| 335 | SetPageUptodate(page); | 336 | SetPageUptodate(page); |
| 336 | } | 337 | } |
| 337 | } else { | 338 | } else { |
| 338 | rc = ecryptfs_decrypt_page(page); | 339 | if (prev_page_end_size |
| 339 | if (rc) { | 340 | >= i_size_read(page->mapping->host)) { |
| 340 | printk(KERN_ERR "%s: Error decrypting page " | 341 | zero_user(page, 0, PAGE_CACHE_SIZE); |
| 341 | "at index [%ld]; rc = [%d]\n", | 342 | } else { |
| 342 | __func__, page->index, rc); | 343 | rc = ecryptfs_decrypt_page(page); |
| 343 | ClearPageUptodate(page); | 344 | if (rc) { |
| 344 | goto out; | 345 | printk(KERN_ERR "%s: Error decrypting " |
| 346 | "page at index [%ld]; " | ||
| 347 | "rc = [%d]\n", | ||
| 348 | __func__, page->index, rc); | ||
| 349 | ClearPageUptodate(page); | ||
| 350 | goto out; | ||
| 351 | } | ||
| 345 | } | 352 | } |
| 346 | SetPageUptodate(page); | 353 | SetPageUptodate(page); |
| 347 | } | 354 | } |
| 348 | } | 355 | } |
| 349 | prev_page_end_size = ((loff_t)index << PAGE_CACHE_SHIFT); | ||
| 350 | /* If creating a page or more of holes, zero them out via truncate. | 356 | /* If creating a page or more of holes, zero them out via truncate. |
| 351 | * Note, this will increase i_size. */ | 357 | * Note, this will increase i_size. */ |
| 352 | if (index != 0) { | 358 | if (index != 0) { |
| @@ -488,7 +494,7 @@ static int ecryptfs_write_end(struct file *file, | |||
| 488 | } else | 494 | } else |
| 489 | ecryptfs_printk(KERN_DEBUG, "Not a new file\n"); | 495 | ecryptfs_printk(KERN_DEBUG, "Not a new file\n"); |
| 490 | ecryptfs_printk(KERN_DEBUG, "Calling fill_zeros_to_end_of_page" | 496 | ecryptfs_printk(KERN_DEBUG, "Calling fill_zeros_to_end_of_page" |
| 491 | "(page w/ index = [0x%.16x], to = [%d])\n", index, to); | 497 | "(page w/ index = [0x%.16lx], to = [%d])\n", index, to); |
| 492 | if (!(crypt_stat->flags & ECRYPTFS_ENCRYPTED)) { | 498 | if (!(crypt_stat->flags & ECRYPTFS_ENCRYPTED)) { |
| 493 | rc = ecryptfs_write_lower_page_segment(ecryptfs_inode, page, 0, | 499 | rc = ecryptfs_write_lower_page_segment(ecryptfs_inode, page, 0, |
| 494 | to); | 500 | to); |
| @@ -503,19 +509,20 @@ static int ecryptfs_write_end(struct file *file, | |||
| 503 | rc = fill_zeros_to_end_of_page(page, to); | 509 | rc = fill_zeros_to_end_of_page(page, to); |
| 504 | if (rc) { | 510 | if (rc) { |
| 505 | ecryptfs_printk(KERN_WARNING, "Error attempting to fill " | 511 | ecryptfs_printk(KERN_WARNING, "Error attempting to fill " |
| 506 | "zeros in page with index = [0x%.16x]\n", index); | 512 | "zeros in page with index = [0x%.16lx]\n", index); |
| 507 | goto out; | 513 | goto out; |
| 508 | } | 514 | } |
| 509 | rc = ecryptfs_encrypt_page(page); | 515 | rc = ecryptfs_encrypt_page(page); |
| 510 | if (rc) { | 516 | if (rc) { |
| 511 | ecryptfs_printk(KERN_WARNING, "Error encrypting page (upper " | 517 | ecryptfs_printk(KERN_WARNING, "Error encrypting page (upper " |
| 512 | "index [0x%.16x])\n", index); | 518 | "index [0x%.16lx])\n", index); |
| 513 | goto out; | 519 | goto out; |
| 514 | } | 520 | } |
| 515 | if (pos + copied > i_size_read(ecryptfs_inode)) { | 521 | if (pos + copied > i_size_read(ecryptfs_inode)) { |
| 516 | i_size_write(ecryptfs_inode, pos + copied); | 522 | i_size_write(ecryptfs_inode, pos + copied); |
| 517 | ecryptfs_printk(KERN_DEBUG, "Expanded file size to " | 523 | ecryptfs_printk(KERN_DEBUG, "Expanded file size to " |
| 518 | "[0x%.16x]\n", i_size_read(ecryptfs_inode)); | 524 | "[0x%.16llx]\n", |
| 525 | (unsigned long long)i_size_read(ecryptfs_inode)); | ||
| 519 | } | 526 | } |
| 520 | rc = ecryptfs_write_inode_size_to_metadata(ecryptfs_inode); | 527 | rc = ecryptfs_write_inode_size_to_metadata(ecryptfs_inode); |
| 521 | if (rc) | 528 | if (rc) |
diff --git a/include/linux/magic.h b/include/linux/magic.h index ff690d05f129..62730ea2b56e 100644 --- a/include/linux/magic.h +++ b/include/linux/magic.h | |||
| @@ -16,6 +16,7 @@ | |||
| 16 | #define TMPFS_MAGIC 0x01021994 | 16 | #define TMPFS_MAGIC 0x01021994 |
| 17 | #define HUGETLBFS_MAGIC 0x958458f6 /* some random number */ | 17 | #define HUGETLBFS_MAGIC 0x958458f6 /* some random number */ |
| 18 | #define SQUASHFS_MAGIC 0x73717368 | 18 | #define SQUASHFS_MAGIC 0x73717368 |
| 19 | #define ECRYPTFS_SUPER_MAGIC 0xf15f | ||
| 19 | #define EFS_SUPER_MAGIC 0x414A53 | 20 | #define EFS_SUPER_MAGIC 0x414A53 |
| 20 | #define EXT2_SUPER_MAGIC 0xEF53 | 21 | #define EXT2_SUPER_MAGIC 0xEF53 |
| 21 | #define EXT3_SUPER_MAGIC 0xEF53 | 22 | #define EXT3_SUPER_MAGIC 0xEF53 |
