diff options
author | Joe Perches <joe@perches.com> | 2010-11-10 18:46:16 -0500 |
---|---|---|
committer | Tyler Hicks <tyhicks@linux.vnet.ibm.com> | 2011-01-17 14:01:23 -0500 |
commit | 888d57bbc91ebd031451d4ab1c669baee826a06c (patch) | |
tree | a446e3d6f7134a50d5118702fadba04ab5ee3c14 /fs/ecryptfs | |
parent | 0abe1169470571c473ee720c35fe5b3481c46c46 (diff) |
fs/ecryptfs: Add printf format/argument verification and fix fallout
Add __attribute__((format... to __ecryptfs_printk
Make formats and arguments match.
Add casts to (unsigned long long) for %llu.
Signed-off-by: Joe Perches <joe@perches.com>
[tyhicks: 80 columns cleanup and fixed typo]
Signed-off-by: Tyler Hicks <tyhicks@linux.vnet.ibm.com>
Diffstat (limited to 'fs/ecryptfs')
-rw-r--r-- | fs/ecryptfs/crypto.c | 26 | ||||
-rw-r--r-- | fs/ecryptfs/ecryptfs_kernel.h | 1 | ||||
-rw-r--r-- | fs/ecryptfs/file.c | 6 | ||||
-rw-r--r-- | fs/ecryptfs/keystore.c | 6 | ||||
-rw-r--r-- | fs/ecryptfs/main.c | 7 | ||||
-rw-r--r-- | fs/ecryptfs/mmap.c | 13 |
6 files changed, 30 insertions, 29 deletions
diff --git a/fs/ecryptfs/crypto.c b/fs/ecryptfs/crypto.c index cbadc1bee6e7..57bdd7a13207 100644 --- a/fs/ecryptfs/crypto.c +++ b/fs/ecryptfs/crypto.c | |||
@@ -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) |
diff --git a/fs/ecryptfs/ecryptfs_kernel.h b/fs/ecryptfs/ecryptfs_kernel.h index bc530a81e4ce..dbc84ed96336 100644 --- a/fs/ecryptfs/ecryptfs_kernel.h +++ b/fs/ecryptfs/ecryptfs_kernel.h | |||
@@ -583,6 +583,7 @@ ecryptfs_set_dentry_lower_mnt(struct dentry *dentry, struct vfsmount *lower_mnt) | |||
583 | 583 | ||
584 | #define ecryptfs_printk(type, fmt, arg...) \ | 584 | #define ecryptfs_printk(type, fmt, arg...) \ |
585 | __ecryptfs_printk(type "%s: " fmt, __func__, ## arg); | 585 | __ecryptfs_printk(type "%s: " fmt, __func__, ## arg); |
586 | __attribute__ ((format(printf, 1, 2))) | ||
586 | void __ecryptfs_printk(const char *fmt, ...); | 587 | void __ecryptfs_printk(const char *fmt, ...); |
587 | 588 | ||
588 | 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 e069e786da43..81e10e6a9443 100644 --- a/fs/ecryptfs/file.c +++ b/fs/ecryptfs/file.c | |||
@@ -241,9 +241,9 @@ static int ecryptfs_open(struct inode *inode, struct file *file) | |||
241 | } | 241 | } |
242 | } | 242 | } |
243 | mutex_unlock(&crypt_stat->cs_mutex); | 243 | mutex_unlock(&crypt_stat->cs_mutex); |
244 | 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 = " |
245 | "size: [0x%.16x]\n", inode, inode->i_ino, | 245 | "[0x%.16lx] size: [0x%.16llx]\n", inode, inode->i_ino, |
246 | i_size_read(inode)); | 246 | (unsigned long long)i_size_read(inode)); |
247 | goto out; | 247 | goto out; |
248 | out_free: | 248 | out_free: |
249 | kmem_cache_free(ecryptfs_file_info_cache, | 249 | kmem_cache_free(ecryptfs_file_info_cache, |
diff --git a/fs/ecryptfs/keystore.c b/fs/ecryptfs/keystore.c index b1f6858a5223..25fd7f595c99 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; |
@@ -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) { |
diff --git a/fs/ecryptfs/main.c b/fs/ecryptfs/main.c index 19f04504f625..758323a0f09a 100644 --- a/fs/ecryptfs/main.c +++ b/fs/ecryptfs/main.c | |||
@@ -810,9 +810,10 @@ static int __init ecryptfs_init(void) | |||
810 | ecryptfs_printk(KERN_ERR, "The eCryptfs extent size is " | 810 | ecryptfs_printk(KERN_ERR, "The eCryptfs extent size is " |
811 | "larger than the host's page size, and so " | 811 | "larger than the host's page size, and so " |
812 | "eCryptfs cannot run on this system. The " | 812 | "eCryptfs cannot run on this system. The " |
813 | "default eCryptfs extent size is [%d] bytes; " | 813 | "default eCryptfs extent size is [%u] bytes; " |
814 | "the page size is [%d] bytes.\n", | 814 | "the page size is [%lu] bytes.\n", |
815 | ECRYPTFS_DEFAULT_EXTENT_SIZE, PAGE_CACHE_SIZE); | 815 | ECRYPTFS_DEFAULT_EXTENT_SIZE, |
816 | (unsigned long)PAGE_CACHE_SIZE); | ||
816 | goto out; | 817 | goto out; |
817 | } | 818 | } |
818 | 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..4b9011392736 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; |
@@ -488,7 +488,7 @@ static int ecryptfs_write_end(struct file *file, | |||
488 | } else | 488 | } else |
489 | ecryptfs_printk(KERN_DEBUG, "Not a new file\n"); | 489 | ecryptfs_printk(KERN_DEBUG, "Not a new file\n"); |
490 | ecryptfs_printk(KERN_DEBUG, "Calling fill_zeros_to_end_of_page" | 490 | ecryptfs_printk(KERN_DEBUG, "Calling fill_zeros_to_end_of_page" |
491 | "(page w/ index = [0x%.16x], to = [%d])\n", index, to); | 491 | "(page w/ index = [0x%.16lx], to = [%d])\n", index, to); |
492 | if (!(crypt_stat->flags & ECRYPTFS_ENCRYPTED)) { | 492 | if (!(crypt_stat->flags & ECRYPTFS_ENCRYPTED)) { |
493 | rc = ecryptfs_write_lower_page_segment(ecryptfs_inode, page, 0, | 493 | rc = ecryptfs_write_lower_page_segment(ecryptfs_inode, page, 0, |
494 | to); | 494 | to); |
@@ -503,19 +503,20 @@ static int ecryptfs_write_end(struct file *file, | |||
503 | rc = fill_zeros_to_end_of_page(page, to); | 503 | rc = fill_zeros_to_end_of_page(page, to); |
504 | if (rc) { | 504 | if (rc) { |
505 | ecryptfs_printk(KERN_WARNING, "Error attempting to fill " | 505 | ecryptfs_printk(KERN_WARNING, "Error attempting to fill " |
506 | "zeros in page with index = [0x%.16x]\n", index); | 506 | "zeros in page with index = [0x%.16lx]\n", index); |
507 | goto out; | 507 | goto out; |
508 | } | 508 | } |
509 | rc = ecryptfs_encrypt_page(page); | 509 | rc = ecryptfs_encrypt_page(page); |
510 | if (rc) { | 510 | if (rc) { |
511 | ecryptfs_printk(KERN_WARNING, "Error encrypting page (upper " | 511 | ecryptfs_printk(KERN_WARNING, "Error encrypting page (upper " |
512 | "index [0x%.16x])\n", index); | 512 | "index [0x%.16lx])\n", index); |
513 | goto out; | 513 | goto out; |
514 | } | 514 | } |
515 | if (pos + copied > i_size_read(ecryptfs_inode)) { | 515 | if (pos + copied > i_size_read(ecryptfs_inode)) { |
516 | i_size_write(ecryptfs_inode, pos + copied); | 516 | i_size_write(ecryptfs_inode, pos + copied); |
517 | ecryptfs_printk(KERN_DEBUG, "Expanded file size to " | 517 | ecryptfs_printk(KERN_DEBUG, "Expanded file size to " |
518 | "[0x%.16x]\n", i_size_read(ecryptfs_inode)); | 518 | "[0x%.16llx]\n", |
519 | (unsigned long long)i_size_read(ecryptfs_inode)); | ||
519 | } | 520 | } |
520 | rc = ecryptfs_write_inode_size_to_metadata(ecryptfs_inode); | 521 | rc = ecryptfs_write_inode_size_to_metadata(ecryptfs_inode); |
521 | if (rc) | 522 | if (rc) |