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]
Message-ID: <152f1bfa9a07354183ca808a036d5e3fef664ea8.camel@linux.ibm.com>
Date:   Mon, 28 Mar 2022 09:51:01 -0400
From:   Mimi Zohar <zohar@...ux.ibm.com>
To:     "Guozihua (Scott)" <guozihua@...wei.com>,
        linux-integrity@...r.kernel.org
Cc:     Eric Biggers <ebiggers@...nel.org>,
        Stefan Berger <stefanb@...ux.ibm.com>,
        linux-fscrypt@...r.kernel.org, linux-kernel@...r.kernel.org,
        Eric Biggers <ebiggers@...gle.com>
Subject: Re: [PATCH v7 1/5] fs-verity: define a function to return the
 integrity protected file digest

Hi Scott,

On Mon, 2022-03-28 at 11:45 +0800, Guozihua (Scott) wrote:
> > +
> > +/**
> > + * 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.
> > + * Assumption: before calling fsverity_get_digest(), the file must have been
> > + * opened.
> > + *
> > + * 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);
> 
> Hi Mimi,
> 
> I would suggest moving this memset downward right before the memcpy.

By doing it here, any existing garbage stored in the digest is cleared
before returning a failure.

thanks,

Mimi
> 
> > +
> > +     /* convert the verity hash algorithm name to a hash_algo_name enum */
> > +     i = match_string(hash_algo_name, HASH_ALGO__LAST, hash_alg->name);
> > +     if (i < 0)
> > +             return -EINVAL;
> > +     *alg = i;
> > +
> > +     if (WARN_ON_ONCE(hash_alg->digest_size != hash_digest_size[*alg]))
> > +             return -EINVAL;
> > +     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