From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 04C07C433E0 for ; Thu, 28 Jan 2021 01:15:57 +0000 (UTC) Received: from lists.sourceforge.net (lists.sourceforge.net [216.105.38.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 9438561492; Thu, 28 Jan 2021 01:15:56 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9438561492 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=linux-f2fs-devel-bounces@lists.sourceforge.net Received: from [127.0.0.1] (helo=sfs-ml-4.v29.lw.sourceforge.com) by sfs-ml-4.v29.lw.sourceforge.com with esmtp (Exim 4.90_1) (envelope-from ) id 1l4vud-0000Wn-8F; Thu, 28 Jan 2021 01:15:55 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-4.v29.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l4vub-0000Wc-5s for linux-f2fs-devel@lists.sourceforge.net; Thu, 28 Jan 2021 01:15:53 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=In-Reply-To:Content-Type:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=paYDAb7LmZ4xHcBEaGBrzzP51gJFQWT7wMl+7XgvZ2g=; b=acPh3/I2SOdZ35FpOEKaQNoQPI M+uq2bJNI2L4pPr4K1IT+pmaaTfUzAuORZTHU0QrcxqrroChzhU+ff3Z9pf0CzU/iVA83gPJwQmTc /o61ZwbUYiR4uH2TgkRRVoSE7FF6gYav7YrbFzoKMP1LvElRbpc4u310oeb3WVqh8KNo=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=In-Reply-To:Content-Type:MIME-Version:References:Message-ID:Subject:Cc:To :From:Date:Sender:Reply-To:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=paYDAb7LmZ4xHcBEaGBrzzP51gJFQWT7wMl+7XgvZ2g=; b=h6ZySXffTKVcugIryQrt6p1MEs icJU8g2eYQuJhoPbMDFRBWOKO8dC1iICT7j85xEFFTp54vxYJV4kf8sKcPJ4fCrkIvIJjo/1WLaBm n7vF56gWo1isciS6NVD6thHX/12OOTfn/DcK6+dduuG9J9oW35R1R1+1/EkMCHtZfJFw=; Received: from mail.kernel.org ([198.145.29.99]) by sfi-mx-1.v28.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.92.2) id 1l4vuR-00Cegd-Sn for linux-f2fs-devel@lists.sourceforge.net; Thu, 28 Jan 2021 01:15:53 +0000 Received: by mail.kernel.org (Postfix) with ESMTPSA id 1C69C64DD1; Thu, 28 Jan 2021 01:04:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1611795857; bh=9u+pX6tITQPni/ZTAGHNlkfJc+eKK2wzAvA+xh2TVPU=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=pCUSbfI7WRD+4txA2pHo3Xrw3oZG+pmpeTwBWaNcegbi36zxBW/ML2+IuDHKMbzHn AVTlavn5uNudzkPHCEf7hOhLjZyJxaX0VqC+vmh0Ax9J0E99UlNwAjDmZT8rxkmXhe W9tkHXGPTWxNhLRsIOiZ63gbCL00Xe4L0F4ttBQWkxnoSOup3VE3LxSDWVoxdaf48/ fISbEA7jX+sAUC3svQE6GrupalDXRGVf9ICYNTaONC8eARwMjBA04hUG0OmSmVNpkL mLuVd2lKIw2s/GnYIUz1aajlGgJohdw5ia9o9MmXIjfeSLBbSbO5d/RUmc6QsOUv8/ bhT8EDe+EENaw== Date: Wed, 27 Jan 2021 17:04:15 -0800 From: Jaegeuk Kim To: Eric Biggers Message-ID: References: <20210115181819.34732-1-ebiggers@kernel.org> <20210115181819.34732-3-ebiggers@kernel.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20210115181819.34732-3-ebiggers@kernel.org> X-Headers-End: 1l4vuR-00Cegd-Sn Subject: Re: [f2fs-dev] [PATCH 2/6] fs-verity: don't pass whole descriptor to fsverity_verify_signature() X-BeenThere: linux-f2fs-devel@lists.sourceforge.net X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Theodore Ts'o , linux-api@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, linux-fscrypt@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-ext4@vger.kernel.org, Victor Hsieh Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: linux-f2fs-devel-bounces@lists.sourceforge.net On 01/15, Eric Biggers wrote: > From: Eric Biggers > > 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 Reviewed-by: Jaegeuk Kim > --- > 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 _______________________________________________ Linux-f2fs-devel mailing list Linux-f2fs-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel