lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Mon, 10 Jan 2022 07:13:22 -0500
From:   Mimi Zohar <zohar@...ux.ibm.com>
To:     Vitaly Chikunov <vt@...linux.org>
Cc:     linux-integrity@...r.kernel.org,
        Eric Biggers <ebiggers@...nel.org>,
        linux-fscrypt@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v2 2/6] fs-verity: define a function to return the
 integrity protected file digest

Hi Vitaly,

On Mon, 2022-01-10 at 03:47 +0300, Vitaly Chikunov wrote:
> Mimi,
> 
> On Sun, Jan 09, 2022 at 01:55:13PM -0500, Mimi Zohar wrote:
> > Define a function named fsverity_get_digest() to return the verity file
> > digest and the associated hash algorithm (enum hash_algo).
> > 
> > Signed-off-by: Mimi Zohar <zohar@...ux.ibm.com>
> > ---
> >  fs/verity/Kconfig            |  1 +
> >  fs/verity/fsverity_private.h |  7 -------
> >  fs/verity/measure.c          | 40 ++++++++++++++++++++++++++++++++++++
> >  include/linux/fsverity.h     | 18 ++++++++++++++++
> >  4 files changed, 59 insertions(+), 7 deletions(-)
> > 
> > diff --git a/fs/verity/measure.c b/fs/verity/measure.c
> > index f0d7b30c62db..52906b2e5811 100644
> > --- a/fs/verity/measure.c
> > +++ b/fs/verity/measure.c
> > @@ -57,3 +57,43 @@ int fsverity_ioctl_measure(struct file *filp, void __user *_uarg)
> >  	return 0;
> >  }
> >  EXPORT_SYMBOL_GPL(fsverity_ioctl_measure);
> > +
> > +/**
> > + * fsverity_get_digest() - get a verity file's digest
> > + * @inode: inode to get digest of
> > + * @digest: (out) pointer to the digest
> > + * @alg: (out) pointer to the hash algorithm enumeration
> > + *
> > + * Return the file hash algorithm and digest of an fsverity protected file.
> > + *
> > + * Return: 0 on success, -errno on failure
> > + */
> > +int fsverity_get_digest(struct inode *inode,
> > +			    u8 digest[FS_VERITY_MAX_DIGEST_SIZE],
> > +			    enum hash_algo *alg)
> > +{
> > +	const struct fsverity_info *vi;
> > +	const struct fsverity_hash_alg *hash_alg;
> > +	int i;
> > +
> > +	vi = fsverity_get_info(inode);
> > +	if (!vi)
> > +		return -ENODATA; /* not a verity file */
> > +
> > +	hash_alg = vi->tree_params.hash_alg;
> > +	memset(digest, 0, FS_VERITY_MAX_DIGEST_SIZE);
> > +	*alg = HASH_ALGO__LAST;
> 
> Perhaps this line is redundant (*alg is overwritten later) and would
> needlessly mangle output value in case of -EINVAL while it's being
> untouched on -ENODATA.
> 

Thanks!

Mimi

> 
> > +
> > +	/* 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;
> > +
> > +	memcpy(digest, vi->file_digest, hash_alg->digest_size);
> > +
> > +	pr_debug("file digest %s:%*phN\n", hash_algo_name[*alg],
> > +		  hash_digest_size[*alg], digest);
> > +
> > +	return 0;
> > +}


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ