From: Stefan Berger <stefanb@linux.ibm.com>
To: Eric Biggers <ebiggers@kernel.org>,
linux-integrity@vger.kernel.org, Mimi Zohar <zohar@linux.ibm.com>,
Dmitry Kasatkin <dmitry.kasatkin@gmail.com>
Cc: keyrings@vger.kernel.org, Vitaly Chikunov <vt@altlinux.org>,
Tianjia Zhang <tianjia.zhang@linux.alibaba.com>,
Herbert Xu <herbert@gondor.apana.org.au>,
stable@vger.kernel.org
Subject: Re: [PATCH] ima: fix reference leak in asymmetric_verify()
Date: Thu, 13 Jan 2022 15:39:23 -0500 [thread overview]
Message-ID: <ef9da2e6-908b-a35f-7873-05cbd353be62@linux.ibm.com> (raw)
In-Reply-To: <20220113194438.69202-1-ebiggers@kernel.org>
On 1/13/22 14:44, Eric Biggers wrote:
> From: Eric Biggers <ebiggers@google.com>
>
> Don't leak a reference to the key if its algorithm is unknown.
>
> Fixes: 947d70597236 ("ima: Support EC keys for signature verification")
> Cc: <stable@vger.kernel.org> # v5.13+
> Signed-off-by: Eric Biggers <ebiggers@google.com>
> ---
> security/integrity/digsig_asymmetric.c | 15 +++++++++------
> 1 file changed, 9 insertions(+), 6 deletions(-)
>
> diff --git a/security/integrity/digsig_asymmetric.c b/security/integrity/digsig_asymmetric.c
> index 23240d793b07..895f4b9ce8c6 100644
> --- a/security/integrity/digsig_asymmetric.c
> +++ b/security/integrity/digsig_asymmetric.c
> @@ -109,22 +109,25 @@ int asymmetric_verify(struct key *keyring, const char *sig,
>
> pk = asymmetric_key_public_key(key);
> pks.pkey_algo = pk->pkey_algo;
> - if (!strcmp(pk->pkey_algo, "rsa"))
> + if (!strcmp(pk->pkey_algo, "rsa")) {
> pks.encoding = "pkcs1";
> - else if (!strncmp(pk->pkey_algo, "ecdsa-", 6))
> + } else if (!strncmp(pk->pkey_algo, "ecdsa-", 6)) {
> /* edcsa-nist-p192 etc. */
> pks.encoding = "x962";
> - else if (!strcmp(pk->pkey_algo, "ecrdsa") ||
> - !strcmp(pk->pkey_algo, "sm2"))
> + } else if (!strcmp(pk->pkey_algo, "ecrdsa") ||
> + !strcmp(pk->pkey_algo, "sm2")) {
> pks.encoding = "raw";
> - else
> - return -ENOPKG;
> + } else {
> + ret = -ENOPKG;
> + goto out;
> + }
>
> pks.digest = (u8 *)data;
> pks.digest_size = datalen;
> pks.s = hdr->sig;
> pks.s_size = siglen;
> ret = verify_signature(key, &pks);
> +out:
> key_put(key);
> pr_debug("%s() = %d\n", __func__, ret);
> return ret;
>
> base-commit: feb7a43de5ef625ad74097d8fd3481d5dbc06a59
Reviewed-by: Stefan Berger <stefanb@linux.ibm.com>
next prev parent reply other threads:[~2022-01-13 20:39 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-13 19:44 [PATCH] ima: fix reference leak in asymmetric_verify() Eric Biggers
2022-01-13 20:39 ` Stefan Berger [this message]
2022-01-14 1:52 ` Mimi Zohar
2022-01-19 0:18 ` Eric Biggers
2022-01-19 0:28 ` Mimi Zohar
2022-01-14 2:47 ` Tianjia Zhang
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=ef9da2e6-908b-a35f-7873-05cbd353be62@linux.ibm.com \
--to=stefanb@linux.ibm.com \
--cc=dmitry.kasatkin@gmail.com \
--cc=ebiggers@kernel.org \
--cc=herbert@gondor.apana.org.au \
--cc=keyrings@vger.kernel.org \
--cc=linux-integrity@vger.kernel.org \
--cc=stable@vger.kernel.org \
--cc=tianjia.zhang@linux.alibaba.com \
--cc=vt@altlinux.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox