lkml.org 
[lkml]   [2022]   [Jan]   [31]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v3 3/8] fs-verity: define a function to return the integrity protected file digest
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

\
 
 \ /
  Last update: 2022-02-01 01:45    [W:0.205 / U:1.940 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site