Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

+9 -12
+5 -7
fs/verity/enable.c
··· 19 19 }; 20 20 21 21 /* 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, 24 23 struct block_buffer *cur) 25 24 { 26 25 struct block_buffer *next = cur + 1; ··· 35 36 /* Zero-pad the block if it's shorter than the block size. */ 36 37 memset(&cur->data[cur->filled], 0, params->block_size - cur->filled); 37 38 38 - fsverity_hash_block(params, inode, cur->data, 39 - &next->data[next->filled]); 39 + fsverity_hash_block(params, cur->data, &next->data[next->filled]); 40 40 next->filled += params->digest_size; 41 41 cur->filled = 0; 42 42 return 0; ··· 121 123 fsverity_err(inode, "Short read of file data"); 122 124 goto out; 123 125 } 124 - err = hash_one_block(inode, params, &buffers[-1]); 126 + err = hash_one_block(params, &buffers[-1]); 125 127 if (err) 126 128 goto out; 127 129 for (level = 0; level < num_levels; level++) { ··· 132 134 } 133 135 /* Next block at @level is full */ 134 136 135 - err = hash_one_block(inode, params, &buffers[level]); 137 + err = hash_one_block(params, &buffers[level]); 136 138 if (err) 137 139 goto out; 138 140 err = write_merkle_tree_block(inode, ··· 152 154 /* Finish all nonempty pending tree blocks. */ 153 155 for (level = 0; level < num_levels; level++) { 154 156 if (buffers[level].filled != 0) { 155 - err = hash_one_block(inode, params, &buffers[level]); 157 + err = hash_one_block(params, &buffers[level]); 156 158 if (err) 157 159 goto out; 158 160 err = write_merkle_tree_block(inode,
+1 -1
fs/verity/fsverity_private.h
··· 90 90 fsverity_prepare_hash_state(const struct fsverity_hash_alg *alg, 91 91 const u8 *salt, size_t salt_size); 92 92 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); 94 94 void fsverity_hash_buffer(const struct fsverity_hash_alg *alg, 95 95 const void *data, size_t size, u8 *out); 96 96 void __init fsverity_check_hash_algs(void);
+1 -2
fs/verity/hash_algs.c
··· 94 94 /** 95 95 * fsverity_hash_block() - hash a single data or hash block 96 96 * @params: the Merkle tree's parameters 97 - * @inode: inode for which the hashing is being done 98 97 * @data: virtual address of a buffer containing the block to hash 99 98 * @out: output digest, size 'params->digest_size' bytes 100 99 * ··· 101 102 * in the Merkle tree parameters. 102 103 */ 103 104 void fsverity_hash_block(const struct merkle_tree_params *params, 104 - const struct inode *inode, const void *data, u8 *out) 105 + const void *data, u8 *out) 105 106 { 106 107 union fsverity_hash_ctx ctx; 107 108
+2 -2
fs/verity/verify.c
··· 202 202 unsigned long hblock_idx = hblocks[level - 1].index; 203 203 unsigned int hoffset = hblocks[level - 1].hoffset; 204 204 205 - fsverity_hash_block(params, inode, haddr, real_hash); 205 + fsverity_hash_block(params, haddr, real_hash); 206 206 if (memcmp(want_hash, real_hash, hsize) != 0) 207 207 goto corrupted; 208 208 /* ··· 221 221 } 222 222 223 223 /* Finally, verify the data block. */ 224 - fsverity_hash_block(params, inode, data, real_hash); 224 + fsverity_hash_block(params, data, real_hash); 225 225 if (memcmp(want_hash, real_hash, hsize) != 0) 226 226 goto corrupted; 227 227 return true;