On Tue, Jan 25, 2022 at 07:06:53PM -0500, Mimi Zohar wrote: > + hash_alg = vi->tree_params.hash_alg; > + memset(digest, 0, FS_VERITY_MAX_DIGEST_SIZE); > + > + /* convert hash algorithm to hash_algo_name */ > + i = match_string(hash_algo_name, HASH_ALGO__LAST, hash_alg->name); > + if (i < 0) > + return -EINVAL; > + *alg = i; The above comment is backwards. This code is converting a hash algorithm name to an ID. The comment is unclear, but it sounds like it's saying the opposite. > + > + memcpy(digest, vi->file_digest, hash_alg->digest_size); Here there are two "sources of truth" for the digest size. How about checking that they are the same: if (WARN_ON_ONCE(hash_alg->digest_size != hash_digest_size[*alg])) return -EINVAL; - Eric