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

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