Skip to content

Commit 32ab3c5

Browse files
committed
fsverity: constify fsverity_hash_alg
Now that fsverity_hash_alg doesn't have an embedded mempool, it can be 'const' almost everywhere. Add it. Link: https://lore.kernel.org/r/20230604022348.48658-1-ebiggers@kernel.org Signed-off-by: Eric Biggers <ebiggers@google.com>
1 parent 8fcd94a commit 32ab3c5

File tree

3 files changed

+11
-11
lines changed

3 files changed

+11
-11
lines changed

fs/verity/fsverity_private.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ struct fsverity_hash_alg {
3333

3434
/* Merkle tree parameters: hash algorithm, initial hash state, and topology */
3535
struct merkle_tree_params {
36-
struct fsverity_hash_alg *hash_alg; /* the hash algorithm */
36+
const struct fsverity_hash_alg *hash_alg; /* the hash algorithm */
3737
const u8 *hashstate; /* initial hash state or NULL */
3838
unsigned int digest_size; /* same as hash_alg->digest_size */
3939
unsigned int block_size; /* size of data and tree blocks */
@@ -79,13 +79,13 @@ struct fsverity_info {
7979

8080
extern struct fsverity_hash_alg fsverity_hash_algs[];
8181

82-
struct fsverity_hash_alg *fsverity_get_hash_alg(const struct inode *inode,
83-
unsigned int num);
84-
const u8 *fsverity_prepare_hash_state(struct fsverity_hash_alg *alg,
82+
const struct fsverity_hash_alg *fsverity_get_hash_alg(const struct inode *inode,
83+
unsigned int num);
84+
const u8 *fsverity_prepare_hash_state(const struct fsverity_hash_alg *alg,
8585
const u8 *salt, size_t salt_size);
8686
int fsverity_hash_block(const struct merkle_tree_params *params,
8787
const struct inode *inode, const void *data, u8 *out);
88-
int fsverity_hash_buffer(struct fsverity_hash_alg *alg,
88+
int fsverity_hash_buffer(const struct fsverity_hash_alg *alg,
8989
const void *data, size_t size, u8 *out);
9090
void __init fsverity_check_hash_algs(void);
9191

fs/verity/hash_algs.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ static DEFINE_MUTEX(fsverity_hash_alg_init_mutex);
3939
*
4040
* Return: pointer to the hash alg on success, else an ERR_PTR()
4141
*/
42-
struct fsverity_hash_alg *fsverity_get_hash_alg(const struct inode *inode,
43-
unsigned int num)
42+
const struct fsverity_hash_alg *fsverity_get_hash_alg(const struct inode *inode,
43+
unsigned int num)
4444
{
4545
struct fsverity_hash_alg *alg;
4646
struct crypto_shash *tfm;
@@ -108,7 +108,7 @@ struct fsverity_hash_alg *fsverity_get_hash_alg(const struct inode *inode,
108108
* Return: NULL if the salt is empty, otherwise the kmalloc()'ed precomputed
109109
* initial hash state on success or an ERR_PTR() on failure.
110110
*/
111-
const u8 *fsverity_prepare_hash_state(struct fsverity_hash_alg *alg,
111+
const u8 *fsverity_prepare_hash_state(const struct fsverity_hash_alg *alg,
112112
const u8 *salt, size_t salt_size)
113113
{
114114
u8 *hashstate = NULL;
@@ -206,7 +206,7 @@ int fsverity_hash_block(const struct merkle_tree_params *params,
206206
*
207207
* Return: 0 on success, -errno on failure
208208
*/
209-
int fsverity_hash_buffer(struct fsverity_hash_alg *alg,
209+
int fsverity_hash_buffer(const struct fsverity_hash_alg *alg,
210210
const void *data, size_t size, u8 *out)
211211
{
212212
return crypto_shash_tfm_digest(alg->tfm, data, size, out);

fs/verity/open.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ int fsverity_init_merkle_tree_params(struct merkle_tree_params *params,
3232
unsigned int log_blocksize,
3333
const u8 *salt, size_t salt_size)
3434
{
35-
struct fsverity_hash_alg *hash_alg;
35+
const struct fsverity_hash_alg *hash_alg;
3636
int err;
3737
u64 blocks;
3838
u64 blocks_in_level[FS_VERITY_MAX_LEVELS];
@@ -158,7 +158,7 @@ int fsverity_init_merkle_tree_params(struct merkle_tree_params *params,
158158
* Compute the file digest by hashing the fsverity_descriptor excluding the
159159
* signature and with the sig_size field set to 0.
160160
*/
161-
static int compute_file_digest(struct fsverity_hash_alg *hash_alg,
161+
static int compute_file_digest(const struct fsverity_hash_alg *hash_alg,
162162
struct fsverity_descriptor *desc,
163163
u8 *file_digest)
164164
{

0 commit comments

Comments
 (0)