Skip to content

Commit 4bd70b5

Browse files
author
Eric Biggers
committed
fsverity: Remove inode parameter from fsverity_hash_block()
Due to the conversion from crypto_shash to the library API, fsverity_hash_block() can no longer fail. Therefore, the inode parameter, which was used only to print an error message in the case of a failure, is no longer necessary. Remove it. Reviewed-by: Ard Biesheuvel <ardb@kernel.org> Link: https://lore.kernel.org/r/20250915160819.140019-6-ebiggers@kernel.org Signed-off-by: Eric Biggers <ebiggers@kernel.org>
1 parent 6733968 commit 4bd70b5

4 files changed

Lines changed: 9 additions & 12 deletions

File tree

fs/verity/enable.c

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,7 @@ struct block_buffer {
1919
};
2020

2121
/* Hash a block, writing the result to the next level's pending block buffer. */
22-
static int hash_one_block(struct inode *inode,
23-
const struct merkle_tree_params *params,
22+
static int hash_one_block(const struct merkle_tree_params *params,
2423
struct block_buffer *cur)
2524
{
2625
struct block_buffer *next = cur + 1;
@@ -36,8 +35,7 @@ static int hash_one_block(struct inode *inode,
3635
/* Zero-pad the block if it's shorter than the block size. */
3736
memset(&cur->data[cur->filled], 0, params->block_size - cur->filled);
3837

39-
fsverity_hash_block(params, inode, cur->data,
40-
&next->data[next->filled]);
38+
fsverity_hash_block(params, cur->data, &next->data[next->filled]);
4139
next->filled += params->digest_size;
4240
cur->filled = 0;
4341
return 0;
@@ -123,7 +121,7 @@ static int build_merkle_tree(struct file *filp,
123121
fsverity_err(inode, "Short read of file data");
124122
goto out;
125123
}
126-
err = hash_one_block(inode, params, &buffers[-1]);
124+
err = hash_one_block(params, &buffers[-1]);
127125
if (err)
128126
goto out;
129127
for (level = 0; level < num_levels; level++) {
@@ -134,7 +132,7 @@ static int build_merkle_tree(struct file *filp,
134132
}
135133
/* Next block at @level is full */
136134

137-
err = hash_one_block(inode, params, &buffers[level]);
135+
err = hash_one_block(params, &buffers[level]);
138136
if (err)
139137
goto out;
140138
err = write_merkle_tree_block(inode,
@@ -154,7 +152,7 @@ static int build_merkle_tree(struct file *filp,
154152
/* Finish all nonempty pending tree blocks. */
155153
for (level = 0; level < num_levels; level++) {
156154
if (buffers[level].filled != 0) {
157-
err = hash_one_block(inode, params, &buffers[level]);
155+
err = hash_one_block(params, &buffers[level]);
158156
if (err)
159157
goto out;
160158
err = write_merkle_tree_block(inode,

fs/verity/fsverity_private.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ union fsverity_hash_ctx *
9090
fsverity_prepare_hash_state(const struct fsverity_hash_alg *alg,
9191
const u8 *salt, size_t salt_size);
9292
void fsverity_hash_block(const struct merkle_tree_params *params,
93-
const struct inode *inode, const void *data, u8 *out);
93+
const void *data, u8 *out);
9494
void fsverity_hash_buffer(const struct fsverity_hash_alg *alg,
9595
const void *data, size_t size, u8 *out);
9696
void __init fsverity_check_hash_algs(void);

fs/verity/hash_algs.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,15 +94,14 @@ fsverity_prepare_hash_state(const struct fsverity_hash_alg *alg,
9494
/**
9595
* fsverity_hash_block() - hash a single data or hash block
9696
* @params: the Merkle tree's parameters
97-
* @inode: inode for which the hashing is being done
9897
* @data: virtual address of a buffer containing the block to hash
9998
* @out: output digest, size 'params->digest_size' bytes
10099
*
101100
* Hash a single data or hash block. The hash is salted if a salt is specified
102101
* in the Merkle tree parameters.
103102
*/
104103
void fsverity_hash_block(const struct merkle_tree_params *params,
105-
const struct inode *inode, const void *data, u8 *out)
104+
const void *data, u8 *out)
106105
{
107106
union fsverity_hash_ctx ctx;
108107

fs/verity/verify.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ verify_data_block(struct inode *inode, struct fsverity_info *vi,
202202
unsigned long hblock_idx = hblocks[level - 1].index;
203203
unsigned int hoffset = hblocks[level - 1].hoffset;
204204

205-
fsverity_hash_block(params, inode, haddr, real_hash);
205+
fsverity_hash_block(params, haddr, real_hash);
206206
if (memcmp(want_hash, real_hash, hsize) != 0)
207207
goto corrupted;
208208
/*
@@ -221,7 +221,7 @@ verify_data_block(struct inode *inode, struct fsverity_info *vi,
221221
}
222222

223223
/* Finally, verify the data block. */
224-
fsverity_hash_block(params, inode, data, real_hash);
224+
fsverity_hash_block(params, data, real_hash);
225225
if (memcmp(want_hash, real_hash, hsize) != 0)
226226
goto corrupted;
227227
return true;

0 commit comments

Comments
 (0)