From: Jaegeuk Kim <jaegeuk@kernel.org>
To: Eric Biggers <ebiggers@kernel.org>
Cc: linux-fscrypt@vger.kernel.org, linux-fsdevel@vger.kernel.org,
linux-ext4@vger.kernel.org,
linux-f2fs-devel@lists.sourceforge.net,
linux-api@vger.kernel.org, Theodore Ts'o <tytso@mit.edu>,
Victor Hsieh <victorhsieh@google.com>
Subject: Re: [PATCH 2/6] fs-verity: don't pass whole descriptor to fsverity_verify_signature()
Date: Wed, 27 Jan 2021 17:04:15 -0800 [thread overview]
Message-ID: <YBINj74g4Qhgwr9L@google.com> (raw)
In-Reply-To: <20210115181819.34732-3-ebiggers@kernel.org>
On 01/15, Eric Biggers wrote:
> From: Eric Biggers <ebiggers@google.com>
>
> Now that fsverity_get_descriptor() validates the sig_size field,
> fsverity_verify_signature() doesn't need to do it.
>
> Just change the prototype of fsverity_verify_signature() to take the
> signature directly rather than take a fsverity_descriptor.
>
> Signed-off-by: Eric Biggers <ebiggers@google.com>
Reviewed-by: Jaegeuk Kim <jaegeuk@kernel.org>
> ---
> fs/verity/fsverity_private.h | 6 ++----
> fs/verity/open.c | 3 ++-
> fs/verity/signature.c | 20 ++++++--------------
> 3 files changed, 10 insertions(+), 19 deletions(-)
>
> diff --git a/fs/verity/fsverity_private.h b/fs/verity/fsverity_private.h
> index 6c9caccc06021..a7920434bae50 100644
> --- a/fs/verity/fsverity_private.h
> +++ b/fs/verity/fsverity_private.h
> @@ -140,15 +140,13 @@ void __init fsverity_exit_info_cache(void);
>
> #ifdef CONFIG_FS_VERITY_BUILTIN_SIGNATURES
> int fsverity_verify_signature(const struct fsverity_info *vi,
> - const struct fsverity_descriptor *desc,
> - size_t desc_size);
> + const u8 *signature, size_t sig_size);
>
> int __init fsverity_init_signature(void);
> #else /* !CONFIG_FS_VERITY_BUILTIN_SIGNATURES */
> static inline int
> fsverity_verify_signature(const struct fsverity_info *vi,
> - const struct fsverity_descriptor *desc,
> - size_t desc_size)
> + const u8 *signature, size_t sig_size)
> {
> return 0;
> }
> diff --git a/fs/verity/open.c b/fs/verity/open.c
> index a987bb785e9b0..60ff8af7219fe 100644
> --- a/fs/verity/open.c
> +++ b/fs/verity/open.c
> @@ -181,7 +181,8 @@ struct fsverity_info *fsverity_create_info(const struct inode *inode,
> vi->tree_params.hash_alg->name,
> vi->tree_params.digest_size, vi->file_digest);
>
> - err = fsverity_verify_signature(vi, desc, desc_size);
> + err = fsverity_verify_signature(vi, desc->signature,
> + le32_to_cpu(desc->sig_size));
> out:
> if (err) {
> fsverity_free_info(vi);
> diff --git a/fs/verity/signature.c b/fs/verity/signature.c
> index 012468eda2a78..143a530a80088 100644
> --- a/fs/verity/signature.c
> +++ b/fs/verity/signature.c
> @@ -29,21 +29,19 @@ static struct key *fsverity_keyring;
> /**
> * fsverity_verify_signature() - check a verity file's signature
> * @vi: the file's fsverity_info
> - * @desc: the file's fsverity_descriptor
> - * @desc_size: size of @desc
> + * @signature: the file's built-in signature
> + * @sig_size: size of signature in bytes, or 0 if no signature
> *
> - * If the file's fs-verity descriptor includes a signature of the file digest,
> - * verify it against the certificates in the fs-verity keyring.
> + * If the file includes a signature of its fs-verity file digest, verify it
> + * against the certificates in the fs-verity keyring.
> *
> * Return: 0 on success (signature valid or not required); -errno on failure
> */
> int fsverity_verify_signature(const struct fsverity_info *vi,
> - const struct fsverity_descriptor *desc,
> - size_t desc_size)
> + const u8 *signature, size_t sig_size)
> {
> const struct inode *inode = vi->inode;
> const struct fsverity_hash_alg *hash_alg = vi->tree_params.hash_alg;
> - const u32 sig_size = le32_to_cpu(desc->sig_size);
> struct fsverity_formatted_digest *d;
> int err;
>
> @@ -56,11 +54,6 @@ int fsverity_verify_signature(const struct fsverity_info *vi,
> return 0;
> }
>
> - if (sig_size > desc_size - sizeof(*desc)) {
> - fsverity_err(inode, "Signature overflows verity descriptor");
> - return -EBADMSG;
> - }
> -
> d = kzalloc(sizeof(*d) + hash_alg->digest_size, GFP_KERNEL);
> if (!d)
> return -ENOMEM;
> @@ -70,8 +63,7 @@ int fsverity_verify_signature(const struct fsverity_info *vi,
> memcpy(d->digest, vi->file_digest, hash_alg->digest_size);
>
> err = verify_pkcs7_signature(d, sizeof(*d) + hash_alg->digest_size,
> - desc->signature, sig_size,
> - fsverity_keyring,
> + signature, sig_size, fsverity_keyring,
> VERIFYING_UNSPECIFIED_SIGNATURE,
> NULL, NULL);
> kfree(d);
> --
> 2.30.0
next prev parent reply other threads:[~2021-01-28 1:12 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-15 18:18 [PATCH 0/6] fs-verity: add an ioctl to read verity metadata Eric Biggers
2021-01-15 18:18 ` [PATCH 1/6] fs-verity: factor out fsverity_get_descriptor() Eric Biggers
2021-01-28 1:04 ` Jaegeuk Kim
2021-01-15 18:18 ` [PATCH 2/6] fs-verity: don't pass whole descriptor to fsverity_verify_signature() Eric Biggers
2021-01-28 1:04 ` Jaegeuk Kim [this message]
2021-01-28 3:24 ` Amy Parker
2021-01-15 18:18 ` [PATCH 3/6] fs-verity: add FS_IOC_READ_VERITY_METADATA ioctl Eric Biggers
2021-01-28 1:03 ` Jaegeuk Kim
2021-02-07 7:46 ` [f2fs-dev] " Chao Yu
2021-02-07 8:01 ` Eric Biggers
2021-02-07 8:32 ` Chao Yu
2021-01-15 18:18 ` [PATCH 4/6] fs-verity: support reading Merkle tree with ioctl Eric Biggers
2021-01-28 1:10 ` Jaegeuk Kim
2021-01-28 2:17 ` Eric Biggers
2021-01-15 18:18 ` [PATCH 5/6] fs-verity: support reading descriptor " Eric Biggers
2021-01-28 1:11 ` Jaegeuk Kim
2021-01-15 18:18 ` [PATCH 6/6] fs-verity: support reading signature " Eric Biggers
2021-01-28 1:11 ` Jaegeuk Kim
2021-01-22 23:26 ` [PATCH 0/6] fs-verity: add an ioctl to read verity metadata Victor Hsieh
2021-01-25 18:41 ` Eric Biggers
2021-02-01 17:41 ` 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=YBINj74g4Qhgwr9L@google.com \
--to=jaegeuk@kernel.org \
--cc=ebiggers@kernel.org \
--cc=linux-api@vger.kernel.org \
--cc=linux-ext4@vger.kernel.org \
--cc=linux-f2fs-devel@lists.sourceforge.net \
--cc=linux-fscrypt@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=tytso@mit.edu \
--cc=victorhsieh@google.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).