Commit 86f66569 authored by Eric Biggers's avatar Eric Biggers

fsverity: remove debug messages and CONFIG_FS_VERITY_DEBUG

I've gotten very little use out of these debug messages, and I'm not
aware of anyone else having used them.

Indeed, sprinkling pr_debug around is not really a best practice these
days, especially for filesystem code.  Tracepoints are used instead.

Let's just remove these and start from a clean slate.

This change does not affect info, warning, and error messages.
Signed-off-by: default avatarEric Biggers <ebiggers@google.com>
Link: https://lore.kernel.org/r/20221215060420.60692-1-ebiggers@kernel.org
parent 72ea15f0
...@@ -34,14 +34,6 @@ config FS_VERITY ...@@ -34,14 +34,6 @@ config FS_VERITY
If unsure, say N. If unsure, say N.
config FS_VERITY_DEBUG
bool "FS Verity debugging"
depends on FS_VERITY
help
Enable debugging messages related to fs-verity by default.
Say N unless you are an fs-verity developer.
config FS_VERITY_BUILTIN_SIGNATURES config FS_VERITY_BUILTIN_SIGNATURES
bool "FS Verity builtin signature support" bool "FS Verity builtin signature support"
depends on FS_VERITY depends on FS_VERITY
......
...@@ -70,10 +70,6 @@ static int build_merkle_tree_level(struct file *filp, unsigned int level, ...@@ -70,10 +70,6 @@ static int build_merkle_tree_level(struct file *filp, unsigned int level,
for (i = 0; i < num_blocks_to_hash; i++) { for (i = 0; i < num_blocks_to_hash; i++) {
struct page *src_page; struct page *src_page;
if ((pgoff_t)i % 10000 == 0 || i + 1 == num_blocks_to_hash)
pr_debug("Hashing block %llu of %llu for level %u\n",
i + 1, num_blocks_to_hash, level);
if (level == 0) { if (level == 0) {
/* Leaf: hashing a data block */ /* Leaf: hashing a data block */
src_page = read_file_data_page(filp, i, &ra, src_page = read_file_data_page(filp, i, &ra,
...@@ -263,15 +259,12 @@ static int enable_verity(struct file *filp, ...@@ -263,15 +259,12 @@ static int enable_verity(struct file *filp,
* ->begin_enable_verity() and ->end_enable_verity() using the inode * ->begin_enable_verity() and ->end_enable_verity() using the inode
* lock and only allow one process to be here at a time on a given file. * lock and only allow one process to be here at a time on a given file.
*/ */
pr_debug("Building Merkle tree...\n");
BUILD_BUG_ON(sizeof(desc->root_hash) < FS_VERITY_MAX_DIGEST_SIZE); BUILD_BUG_ON(sizeof(desc->root_hash) < FS_VERITY_MAX_DIGEST_SIZE);
err = build_merkle_tree(filp, &params, desc->root_hash); err = build_merkle_tree(filp, &params, desc->root_hash);
if (err) { if (err) {
fsverity_err(inode, "Error %d building Merkle tree", err); fsverity_err(inode, "Error %d building Merkle tree", err);
goto rollback; goto rollback;
} }
pr_debug("Done building Merkle tree. Root hash is %s:%*phN\n",
params.hash_alg->name, params.digest_size, desc->root_hash);
/* /*
* Create the fsverity_info. Don't bother trying to save work by * Create the fsverity_info. Don't bother trying to save work by
...@@ -286,10 +279,6 @@ static int enable_verity(struct file *filp, ...@@ -286,10 +279,6 @@ static int enable_verity(struct file *filp,
goto rollback; goto rollback;
} }
if (arg->sig_size)
pr_debug("Storing a %u-byte PKCS#7 signature alongside the file\n",
arg->sig_size);
/* /*
* Tell the filesystem to finish enabling verity on the file. * Tell the filesystem to finish enabling verity on the file.
* Serialized with ->begin_enable_verity() by the inode lock. * Serialized with ->begin_enable_verity() by the inode lock.
......
...@@ -8,10 +8,6 @@ ...@@ -8,10 +8,6 @@
#ifndef _FSVERITY_PRIVATE_H #ifndef _FSVERITY_PRIVATE_H
#define _FSVERITY_PRIVATE_H #define _FSVERITY_PRIVATE_H
#ifdef CONFIG_FS_VERITY_DEBUG
#define DEBUG
#endif
#define pr_fmt(fmt) "fs-verity: " fmt #define pr_fmt(fmt) "fs-verity: " fmt
#include <linux/fsverity.h> #include <linux/fsverity.h>
......
...@@ -49,7 +49,6 @@ static int __init fsverity_init(void) ...@@ -49,7 +49,6 @@ static int __init fsverity_init(void)
if (err) if (err)
goto err_exit_workqueue; goto err_exit_workqueue;
pr_debug("Initialized fs-verity\n");
return 0; return 0;
err_exit_workqueue: err_exit_workqueue:
......
...@@ -77,10 +77,6 @@ int fsverity_init_merkle_tree_params(struct merkle_tree_params *params, ...@@ -77,10 +77,6 @@ int fsverity_init_merkle_tree_params(struct merkle_tree_params *params,
params->log_arity = params->log_blocksize - ilog2(params->digest_size); params->log_arity = params->log_blocksize - ilog2(params->digest_size);
params->hashes_per_block = 1 << params->log_arity; params->hashes_per_block = 1 << params->log_arity;
pr_debug("Merkle tree uses %s with %u-byte blocks (%u hashes/block), salt=%*phN\n",
hash_alg->name, params->block_size, params->hashes_per_block,
(int)salt_size, salt);
/* /*
* Compute the number of levels in the Merkle tree and create a map from * Compute the number of levels in the Merkle tree and create a map from
* level to the starting block of that level. Level 'num_levels - 1' is * level to the starting block of that level. Level 'num_levels - 1' is
...@@ -90,7 +86,6 @@ int fsverity_init_merkle_tree_params(struct merkle_tree_params *params, ...@@ -90,7 +86,6 @@ int fsverity_init_merkle_tree_params(struct merkle_tree_params *params,
/* Compute number of levels and the number of blocks in each level */ /* Compute number of levels and the number of blocks in each level */
blocks = ((u64)inode->i_size + params->block_size - 1) >> log_blocksize; blocks = ((u64)inode->i_size + params->block_size - 1) >> log_blocksize;
pr_debug("Data is %lld bytes (%llu blocks)\n", inode->i_size, blocks);
while (blocks > 1) { while (blocks > 1) {
if (params->num_levels >= FS_VERITY_MAX_LEVELS) { if (params->num_levels >= FS_VERITY_MAX_LEVELS) {
fsverity_err(inode, "Too many levels in Merkle tree"); fsverity_err(inode, "Too many levels in Merkle tree");
...@@ -109,8 +104,6 @@ int fsverity_init_merkle_tree_params(struct merkle_tree_params *params, ...@@ -109,8 +104,6 @@ int fsverity_init_merkle_tree_params(struct merkle_tree_params *params,
for (level = (int)params->num_levels - 1; level >= 0; level--) { for (level = (int)params->num_levels - 1; level >= 0; level--) {
blocks = params->level_start[level]; blocks = params->level_start[level];
params->level_start[level] = offset; params->level_start[level] = offset;
pr_debug("Level %d is %llu blocks starting at index %llu\n",
level, blocks, offset);
offset += blocks; offset += blocks;
} }
...@@ -176,9 +169,6 @@ struct fsverity_info *fsverity_create_info(const struct inode *inode, ...@@ -176,9 +169,6 @@ struct fsverity_info *fsverity_create_info(const struct inode *inode,
fsverity_err(inode, "Error %d computing file digest", err); fsverity_err(inode, "Error %d computing file digest", err);
goto out; goto out;
} }
pr_debug("Computed file digest: %s:%*phN\n",
vi->tree_params.hash_alg->name,
vi->tree_params.digest_size, vi->file_digest);
err = fsverity_verify_signature(vi, desc->signature, err = fsverity_verify_signature(vi, desc->signature,
le32_to_cpu(desc->sig_size)); le32_to_cpu(desc->sig_size));
...@@ -327,23 +317,16 @@ static int ensure_verity_info(struct inode *inode) ...@@ -327,23 +317,16 @@ static int ensure_verity_info(struct inode *inode)
int __fsverity_file_open(struct inode *inode, struct file *filp) int __fsverity_file_open(struct inode *inode, struct file *filp)
{ {
if (filp->f_mode & FMODE_WRITE) { if (filp->f_mode & FMODE_WRITE)
pr_debug("Denying opening verity file (ino %lu) for write\n",
inode->i_ino);
return -EPERM; return -EPERM;
}
return ensure_verity_info(inode); return ensure_verity_info(inode);
} }
EXPORT_SYMBOL_GPL(__fsverity_file_open); EXPORT_SYMBOL_GPL(__fsverity_file_open);
int __fsverity_prepare_setattr(struct dentry *dentry, struct iattr *attr) int __fsverity_prepare_setattr(struct dentry *dentry, struct iattr *attr)
{ {
if (attr->ia_valid & ATTR_SIZE) { if (attr->ia_valid & ATTR_SIZE)
pr_debug("Denying truncate of verity file (ino %lu)\n",
d_inode(dentry)->i_ino);
return -EPERM; return -EPERM;
}
return 0; return 0;
} }
EXPORT_SYMBOL_GPL(__fsverity_prepare_setattr); EXPORT_SYMBOL_GPL(__fsverity_prepare_setattr);
......
...@@ -82,8 +82,6 @@ int fsverity_verify_signature(const struct fsverity_info *vi, ...@@ -82,8 +82,6 @@ int fsverity_verify_signature(const struct fsverity_info *vi,
return err; return err;
} }
pr_debug("Valid signature for file digest %s:%*phN\n",
hash_alg->name, hash_alg->digest_size, vi->file_digest);
return 0; return 0;
} }
......
...@@ -9,7 +9,6 @@ ...@@ -9,7 +9,6 @@
#include <crypto/hash.h> #include <crypto/hash.h>
#include <linux/bio.h> #include <linux/bio.h>
#include <linux/ratelimit.h>
static struct workqueue_struct *fsverity_read_workqueue; static struct workqueue_struct *fsverity_read_workqueue;
...@@ -91,8 +90,6 @@ static bool verify_page(struct inode *inode, const struct fsverity_info *vi, ...@@ -91,8 +90,6 @@ static bool verify_page(struct inode *inode, const struct fsverity_info *vi,
if (WARN_ON_ONCE(!PageLocked(data_page) || PageUptodate(data_page))) if (WARN_ON_ONCE(!PageLocked(data_page) || PageUptodate(data_page)))
return false; return false;
pr_debug_ratelimited("Verifying data page %lu...\n", index);
/* /*
* Starting at the leaf level, ascend the tree saving hash pages along * Starting at the leaf level, ascend the tree saving hash pages along
* the way until we find a verified hash page, indicated by PageChecked; * the way until we find a verified hash page, indicated by PageChecked;
...@@ -105,9 +102,6 @@ static bool verify_page(struct inode *inode, const struct fsverity_info *vi, ...@@ -105,9 +102,6 @@ static bool verify_page(struct inode *inode, const struct fsverity_info *vi,
hash_at_level(params, index, level, &hindex, &hoffset); hash_at_level(params, index, level, &hindex, &hoffset);
pr_debug_ratelimited("Level %d: hindex=%lu, hoffset=%u\n",
level, hindex, hoffset);
hpage = inode->i_sb->s_vop->read_merkle_tree_page(inode, hindex, hpage = inode->i_sb->s_vop->read_merkle_tree_page(inode, hindex,
level == 0 ? level0_ra_pages : 0); level == 0 ? level0_ra_pages : 0);
if (IS_ERR(hpage)) { if (IS_ERR(hpage)) {
...@@ -122,19 +116,13 @@ static bool verify_page(struct inode *inode, const struct fsverity_info *vi, ...@@ -122,19 +116,13 @@ static bool verify_page(struct inode *inode, const struct fsverity_info *vi,
memcpy_from_page(_want_hash, hpage, hoffset, hsize); memcpy_from_page(_want_hash, hpage, hoffset, hsize);
want_hash = _want_hash; want_hash = _want_hash;
put_page(hpage); put_page(hpage);
pr_debug_ratelimited("Hash page already checked, want %s:%*phN\n",
params->hash_alg->name,
hsize, want_hash);
goto descend; goto descend;
} }
pr_debug_ratelimited("Hash page not yet checked\n");
hpages[level] = hpage; hpages[level] = hpage;
hoffsets[level] = hoffset; hoffsets[level] = hoffset;
} }
want_hash = vi->root_hash; want_hash = vi->root_hash;
pr_debug("Want root hash: %s:%*phN\n",
params->hash_alg->name, hsize, want_hash);
descend: descend:
/* Descend the tree verifying hash pages */ /* Descend the tree verifying hash pages */
for (; level > 0; level--) { for (; level > 0; level--) {
...@@ -151,8 +139,6 @@ static bool verify_page(struct inode *inode, const struct fsverity_info *vi, ...@@ -151,8 +139,6 @@ static bool verify_page(struct inode *inode, const struct fsverity_info *vi,
memcpy_from_page(_want_hash, hpage, hoffset, hsize); memcpy_from_page(_want_hash, hpage, hoffset, hsize);
want_hash = _want_hash; want_hash = _want_hash;
put_page(hpage); put_page(hpage);
pr_debug("Verified hash page at level %d, now want %s:%*phN\n",
level - 1, params->hash_alg->name, hsize, want_hash);
} }
/* Finally, verify the data page */ /* Finally, verify the data page */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment