From: Eric Biggers <ebiggers@kernel.org>
To: Mimi Zohar <zohar@linux.ibm.com>
Cc: linux-integrity@vger.kernel.org, linux-fscrypt@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v1 1/5] fs-verity: define a function to return the integrity protected file digest
Date: Thu, 2 Dec 2021 14:15:07 -0800 [thread overview]
Message-ID: <YalFa3eBR/8tp0AP@sol.localdomain> (raw)
In-Reply-To: <20211202215507.298415-2-zohar@linux.ibm.com>
On Thu, Dec 02, 2021 at 04:55:03PM -0500, Mimi Zohar wrote:
> +
> +/**
> + * fsverity_collect_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_collect_digest(struct inode *inode,
> + u8 digest[FS_VERITY_MAX_DIGEST_SIZE],
> + enum hash_algo *alg)
I'd still prefer that this be named fsverity_get_digest(), but this is fine too.
> +{
> + 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;
> +
> + /* convert hash algorithm to hash_algo_name */
> + for (i = 0; i < HASH_ALGO__LAST; i++) {
> + pr_debug("name %s hash_algo_name[%d] %s\n",
> + hash_alg->name, i, hash_algo_name[i]);
> +
> + if (!strcmp(hash_alg->name, hash_algo_name[i])) {
> + *alg = i;
> + break;
> + }
> + }
How about using match_string() here?
> + pr_debug("file digest:%s %*phN\n", hash_algo_name[*alg],
> + hash_digest_size[*alg], digest);
Other log messages in fs/verity/ use the format alg:hash. How about using
"file_digest %s:%*phN\n" as the format string here?
- Eric
next prev parent reply other threads:[~2021-12-02 22:15 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-12-02 21:55 [PATCH v1 0/5] ima: support fs-verity signatures stored as Mimi Zohar
2021-12-02 21:55 ` [PATCH v1 1/5] fs-verity: define a function to return the integrity protected file digest Mimi Zohar
2021-12-02 22:15 ` Eric Biggers [this message]
2021-12-02 21:55 ` [PATCH v1 2/5] ima: define a new signature type named IMA_VERITY_DIGSIG Mimi Zohar
2021-12-02 21:55 ` [PATCH v1 3/5] ima: limit including fs-verity's file digest in measurement list Mimi Zohar
2021-12-02 22:22 ` Eric Biggers
2021-12-02 22:55 ` Mimi Zohar
2021-12-02 21:55 ` [PATCH v1 4/5] ima: support fs-verity file digest based signatures Mimi Zohar
2021-12-02 22:07 ` Eric Biggers
2021-12-02 22:13 ` Mimi Zohar
2021-12-02 22:18 ` Eric Biggers
2021-12-31 15:35 ` Mimi Zohar
2022-01-05 23:37 ` Eric Biggers
2022-01-09 20:45 ` Vitaly Chikunov
2022-01-09 21:07 ` Eric Biggers
2022-01-15 5:31 ` Vitaly Chikunov
2022-01-15 6:21 ` Eric Biggers
2022-01-16 3:31 ` Stefan Berger
2022-01-16 5:24 ` Stefan Berger
2022-01-19 0:49 ` Eric Biggers
2022-01-19 15:41 ` Stefan Berger
2022-01-16 17:01 ` Mimi Zohar
2022-01-19 0:39 ` Eric Biggers
2022-01-20 16:39 ` Mimi Zohar
2022-01-20 21:05 ` Eric Biggers
2021-12-02 21:55 ` [PATCH v1 5/5] fsverity: update the documentation Mimi Zohar
2021-12-02 22:09 ` Eric Biggers
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=YalFa3eBR/8tp0AP@sol.localdomain \
--to=ebiggers@kernel.org \
--cc=linux-fscrypt@vger.kernel.org \
--cc=linux-integrity@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=zohar@linux.ibm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.