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>
This commit is contained in:
parent
0abe116947
commit
888d57bbc9
6 changed files with 30 additions and 29 deletions
|
@ -413,10 +413,9 @@ static int ecryptfs_encrypt_extent(struct page *enc_extent_page,
|
||||||
rc = ecryptfs_derive_iv(extent_iv, crypt_stat,
|
rc = ecryptfs_derive_iv(extent_iv, crypt_stat,
|
||||||
(extent_base + extent_offset));
|
(extent_base + extent_offset));
|
||||||
if (rc) {
|
if (rc) {
|
||||||
ecryptfs_printk(KERN_ERR, "Error attempting to "
|
ecryptfs_printk(KERN_ERR, "Error attempting to derive IV for "
|
||||||
"derive IV for extent [0x%.16x]; "
|
"extent [0x%.16llx]; rc = [%d]\n",
|
||||||
"rc = [%d]\n", (extent_base + extent_offset),
|
(unsigned long long)(extent_base + extent_offset), rc);
|
||||||
rc);
|
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
if (unlikely(ecryptfs_verbosity > 0)) {
|
if (unlikely(ecryptfs_verbosity > 0)) {
|
||||||
|
@ -443,9 +442,9 @@ static int ecryptfs_encrypt_extent(struct page *enc_extent_page,
|
||||||
}
|
}
|
||||||
rc = 0;
|
rc = 0;
|
||||||
if (unlikely(ecryptfs_verbosity > 0)) {
|
if (unlikely(ecryptfs_verbosity > 0)) {
|
||||||
ecryptfs_printk(KERN_DEBUG, "Encrypt extent [0x%.16x]; "
|
ecryptfs_printk(KERN_DEBUG, "Encrypt extent [0x%.16llx]; "
|
||||||
"rc = [%d]\n", (extent_base + extent_offset),
|
"rc = [%d]\n",
|
||||||
rc);
|
(unsigned long long)(extent_base + extent_offset), rc);
|
||||||
ecryptfs_printk(KERN_DEBUG, "First 8 bytes after "
|
ecryptfs_printk(KERN_DEBUG, "First 8 bytes after "
|
||||||
"encryption:\n");
|
"encryption:\n");
|
||||||
ecryptfs_dump_hex((char *)(page_address(enc_extent_page)), 8);
|
ecryptfs_dump_hex((char *)(page_address(enc_extent_page)), 8);
|
||||||
|
@ -540,10 +539,9 @@ static int ecryptfs_decrypt_extent(struct page *page,
|
||||||
rc = ecryptfs_derive_iv(extent_iv, crypt_stat,
|
rc = ecryptfs_derive_iv(extent_iv, crypt_stat,
|
||||||
(extent_base + extent_offset));
|
(extent_base + extent_offset));
|
||||||
if (rc) {
|
if (rc) {
|
||||||
ecryptfs_printk(KERN_ERR, "Error attempting to "
|
ecryptfs_printk(KERN_ERR, "Error attempting to derive IV for "
|
||||||
"derive IV for extent [0x%.16x]; "
|
"extent [0x%.16llx]; rc = [%d]\n",
|
||||||
"rc = [%d]\n", (extent_base + extent_offset),
|
(unsigned long long)(extent_base + extent_offset), rc);
|
||||||
rc);
|
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
if (unlikely(ecryptfs_verbosity > 0)) {
|
if (unlikely(ecryptfs_verbosity > 0)) {
|
||||||
|
@ -571,9 +569,9 @@ static int ecryptfs_decrypt_extent(struct page *page,
|
||||||
}
|
}
|
||||||
rc = 0;
|
rc = 0;
|
||||||
if (unlikely(ecryptfs_verbosity > 0)) {
|
if (unlikely(ecryptfs_verbosity > 0)) {
|
||||||
ecryptfs_printk(KERN_DEBUG, "Decrypt extent [0x%.16x]; "
|
ecryptfs_printk(KERN_DEBUG, "Decrypt extent [0x%.16llx]; "
|
||||||
"rc = [%d]\n", (extent_base + extent_offset),
|
"rc = [%d]\n",
|
||||||
rc);
|
(unsigned long long)(extent_base + extent_offset), rc);
|
||||||
ecryptfs_printk(KERN_DEBUG, "First 8 bytes after "
|
ecryptfs_printk(KERN_DEBUG, "First 8 bytes after "
|
||||||
"decryption:\n");
|
"decryption:\n");
|
||||||
ecryptfs_dump_hex((char *)(page_address(page)
|
ecryptfs_dump_hex((char *)(page_address(page)
|
||||||
|
|
|
@ -583,6 +583,7 @@ ecryptfs_set_dentry_lower_mnt(struct dentry *dentry, struct vfsmount *lower_mnt)
|
||||||
|
|
||||||
#define ecryptfs_printk(type, fmt, arg...) \
|
#define ecryptfs_printk(type, fmt, arg...) \
|
||||||
__ecryptfs_printk(type "%s: " fmt, __func__, ## arg);
|
__ecryptfs_printk(type "%s: " fmt, __func__, ## arg);
|
||||||
|
__attribute__ ((format(printf, 1, 2)))
|
||||||
void __ecryptfs_printk(const char *fmt, ...);
|
void __ecryptfs_printk(const char *fmt, ...);
|
||||||
|
|
||||||
extern const struct file_operations ecryptfs_main_fops;
|
extern const struct file_operations ecryptfs_main_fops;
|
||||||
|
|
|
@ -241,9 +241,9 @@ static int ecryptfs_open(struct inode *inode, struct file *file)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
mutex_unlock(&crypt_stat->cs_mutex);
|
mutex_unlock(&crypt_stat->cs_mutex);
|
||||||
ecryptfs_printk(KERN_DEBUG, "inode w/ addr = [0x%p], i_ino = [0x%.16x] "
|
ecryptfs_printk(KERN_DEBUG, "inode w/ addr = [0x%p], i_ino = "
|
||||||
"size: [0x%.16x]\n", inode, inode->i_ino,
|
"[0x%.16lx] size: [0x%.16llx]\n", inode, inode->i_ino,
|
||||||
i_size_read(inode));
|
(unsigned long long)i_size_read(inode));
|
||||||
goto out;
|
goto out;
|
||||||
out_free:
|
out_free:
|
||||||
kmem_cache_free(ecryptfs_file_info_cache,
|
kmem_cache_free(ecryptfs_file_info_cache,
|
||||||
|
|
|
@ -59,7 +59,7 @@ static int process_request_key_err(long err_code)
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
ecryptfs_printk(KERN_WARNING, "Unknown error code: "
|
ecryptfs_printk(KERN_WARNING, "Unknown error code: "
|
||||||
"[0x%.16x]\n", err_code);
|
"[0x%.16lx]\n", err_code);
|
||||||
rc = -EINVAL;
|
rc = -EINVAL;
|
||||||
}
|
}
|
||||||
return rc;
|
return rc;
|
||||||
|
@ -1864,8 +1864,8 @@ found_matching_auth_tok:
|
||||||
"session key for authentication token with sig "
|
"session key for authentication token with sig "
|
||||||
"[%.*s]; rc = [%d]. Removing auth tok "
|
"[%.*s]; rc = [%d]. Removing auth tok "
|
||||||
"candidate from the list and searching for "
|
"candidate from the list and searching for "
|
||||||
"the next match.\n", candidate_auth_tok_sig,
|
"the next match.\n", ECRYPTFS_SIG_SIZE_HEX,
|
||||||
ECRYPTFS_SIG_SIZE_HEX, rc);
|
candidate_auth_tok_sig, rc);
|
||||||
list_for_each_entry_safe(auth_tok_list_item,
|
list_for_each_entry_safe(auth_tok_list_item,
|
||||||
auth_tok_list_item_tmp,
|
auth_tok_list_item_tmp,
|
||||||
&auth_tok_list, list) {
|
&auth_tok_list, list) {
|
||||||
|
|
|
@ -810,9 +810,10 @@ static int __init ecryptfs_init(void)
|
||||||
ecryptfs_printk(KERN_ERR, "The eCryptfs extent size is "
|
ecryptfs_printk(KERN_ERR, "The eCryptfs extent size is "
|
||||||
"larger than the host's page size, and so "
|
"larger than the host's page size, and so "
|
||||||
"eCryptfs cannot run on this system. The "
|
"eCryptfs cannot run on this system. The "
|
||||||
"default eCryptfs extent size is [%d] bytes; "
|
"default eCryptfs extent size is [%u] bytes; "
|
||||||
"the page size is [%d] bytes.\n",
|
"the page size is [%lu] bytes.\n",
|
||||||
ECRYPTFS_DEFAULT_EXTENT_SIZE, PAGE_CACHE_SIZE);
|
ECRYPTFS_DEFAULT_EXTENT_SIZE,
|
||||||
|
(unsigned long)PAGE_CACHE_SIZE);
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
rc = ecryptfs_init_kmem_caches();
|
rc = ecryptfs_init_kmem_caches();
|
||||||
|
|
|
@ -65,7 +65,7 @@ static int ecryptfs_writepage(struct page *page, struct writeback_control *wbc)
|
||||||
rc = ecryptfs_encrypt_page(page);
|
rc = ecryptfs_encrypt_page(page);
|
||||||
if (rc) {
|
if (rc) {
|
||||||
ecryptfs_printk(KERN_WARNING, "Error encrypting "
|
ecryptfs_printk(KERN_WARNING, "Error encrypting "
|
||||||
"page (upper index [0x%.16x])\n", page->index);
|
"page (upper index [0x%.16lx])\n", page->index);
|
||||||
ClearPageUptodate(page);
|
ClearPageUptodate(page);
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
@ -237,7 +237,7 @@ out:
|
||||||
ClearPageUptodate(page);
|
ClearPageUptodate(page);
|
||||||
else
|
else
|
||||||
SetPageUptodate(page);
|
SetPageUptodate(page);
|
||||||
ecryptfs_printk(KERN_DEBUG, "Unlocking page with index = [0x%.16x]\n",
|
ecryptfs_printk(KERN_DEBUG, "Unlocking page with index = [0x%.16lx]\n",
|
||||||
page->index);
|
page->index);
|
||||||
unlock_page(page);
|
unlock_page(page);
|
||||||
return rc;
|
return rc;
|
||||||
|
@ -488,7 +488,7 @@ static int ecryptfs_write_end(struct file *file,
|
||||||
} else
|
} else
|
||||||
ecryptfs_printk(KERN_DEBUG, "Not a new file\n");
|
ecryptfs_printk(KERN_DEBUG, "Not a new file\n");
|
||||||
ecryptfs_printk(KERN_DEBUG, "Calling fill_zeros_to_end_of_page"
|
ecryptfs_printk(KERN_DEBUG, "Calling fill_zeros_to_end_of_page"
|
||||||
"(page w/ index = [0x%.16x], to = [%d])\n", index, to);
|
"(page w/ index = [0x%.16lx], to = [%d])\n", index, to);
|
||||||
if (!(crypt_stat->flags & ECRYPTFS_ENCRYPTED)) {
|
if (!(crypt_stat->flags & ECRYPTFS_ENCRYPTED)) {
|
||||||
rc = ecryptfs_write_lower_page_segment(ecryptfs_inode, page, 0,
|
rc = ecryptfs_write_lower_page_segment(ecryptfs_inode, page, 0,
|
||||||
to);
|
to);
|
||||||
|
@ -503,19 +503,20 @@ static int ecryptfs_write_end(struct file *file,
|
||||||
rc = fill_zeros_to_end_of_page(page, to);
|
rc = fill_zeros_to_end_of_page(page, to);
|
||||||
if (rc) {
|
if (rc) {
|
||||||
ecryptfs_printk(KERN_WARNING, "Error attempting to fill "
|
ecryptfs_printk(KERN_WARNING, "Error attempting to fill "
|
||||||
"zeros in page with index = [0x%.16x]\n", index);
|
"zeros in page with index = [0x%.16lx]\n", index);
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
rc = ecryptfs_encrypt_page(page);
|
rc = ecryptfs_encrypt_page(page);
|
||||||
if (rc) {
|
if (rc) {
|
||||||
ecryptfs_printk(KERN_WARNING, "Error encrypting page (upper "
|
ecryptfs_printk(KERN_WARNING, "Error encrypting page (upper "
|
||||||
"index [0x%.16x])\n", index);
|
"index [0x%.16lx])\n", index);
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
if (pos + copied > i_size_read(ecryptfs_inode)) {
|
if (pos + copied > i_size_read(ecryptfs_inode)) {
|
||||||
i_size_write(ecryptfs_inode, pos + copied);
|
i_size_write(ecryptfs_inode, pos + copied);
|
||||||
ecryptfs_printk(KERN_DEBUG, "Expanded file size to "
|
ecryptfs_printk(KERN_DEBUG, "Expanded file size to "
|
||||||
"[0x%.16x]\n", i_size_read(ecryptfs_inode));
|
"[0x%.16llx]\n",
|
||||||
|
(unsigned long long)i_size_read(ecryptfs_inode));
|
||||||
}
|
}
|
||||||
rc = ecryptfs_write_inode_size_to_metadata(ecryptfs_inode);
|
rc = ecryptfs_write_inode_size_to_metadata(ecryptfs_inode);
|
||||||
if (rc)
|
if (rc)
|
||||||
|
|
Loading…
Add table
Reference in a new issue