From: Jarkko Sakkinen <jarkko@kernel.org>
To: David Howells <dhowells@redhat.com>
Cc: "Toke Høiland-Jørgensen" <toke@redhat.com>,
"Herbert Xu" <herbert@gondor.apana.org.au>,
"David S. Miller" <davem@davemloft.net>,
"Tianjia Zhang" <tianjia.zhang@linux.alibaba.com>,
"Gilad Ben-Yossef" <gilad@benyossef.com>,
keyrings@vger.kernel.org, linux-crypto@vger.kernel.org,
stable@vger.kernel.org
Subject: Re: [PATCH] crypto: public_key: check that pkey_algo is non-NULL before passing it to strcmp()
Date: Thu, 14 Jan 2021 04:55:34 +0200 [thread overview]
Message-ID: <X/+yphcab4AERQJS@kernel.org> (raw)
In-Reply-To: <2648795.1610536273@warthog.procyon.org.uk>
On Wed, Jan 13, 2021 at 11:11:13AM +0000, David Howells wrote:
> I'm intending to use Tianjia's patch. Would you like to add a Reviewed-by?
>
> David
I can give.
Reviewed-by: Jarkko Sakkinen <jarkko@kernel.org>
/Jarkko
> ---
> commit 11078a592e6dcea6b9f30e822d3d30e3defc99ca
> Author: Tianjia Zhang <tianjia.zhang@linux.alibaba.com>
> Date: Thu Jan 7 17:28:55 2021 +0800
>
> X.509: Fix crash caused by NULL pointer
>
> On the following call path, `sig->pkey_algo` is not assigned
> in asymmetric_key_verify_signature(), which causes runtime
> crash in public_key_verify_signature().
>
> keyctl_pkey_verify
> asymmetric_key_verify_signature
> verify_signature
> public_key_verify_signature
>
> This patch simply check this situation and fixes the crash
> caused by NULL pointer.
>
> Fixes: 215525639631 ("X.509: support OSCCA SM2-with-SM3 certificate verification")
> Cc: stable@vger.kernel.org # v5.10+
> Reported-by: Tobias Markus <tobias@markus-regensburg.de>
> Signed-off-by: Tianjia Zhang <tianjia.zhang@linux.alibaba.com>
> Signed-off-by: David Howells <dhowells@redhat.com>
>
> diff --git a/crypto/asymmetric_keys/public_key.c b/crypto/asymmetric_keys/public_key.c
> index 8892908ad58c..788a4ba1e2e7 100644
> --- a/crypto/asymmetric_keys/public_key.c
> +++ b/crypto/asymmetric_keys/public_key.c
> @@ -356,7 +356,8 @@ int public_key_verify_signature(const struct public_key *pkey,
> if (ret)
> goto error_free_key;
>
> - if (strcmp(sig->pkey_algo, "sm2") == 0 && sig->data_size) {
> + if (sig->pkey_algo && strcmp(sig->pkey_algo, "sm2") == 0 &&
> + sig->data_size) {
> ret = cert_sig_digest_update(sig, tfm);
> if (ret)
> goto error_free_key;
>
>
prev parent reply other threads:[~2021-01-14 2:56 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-12 16:10 [PATCH] crypto: public_key: check that pkey_algo is non-NULL before passing it to strcmp() Toke Høiland-Jørgensen
2021-01-13 2:39 ` Tianjia Zhang
2021-01-13 11:29 ` Toke Høiland-Jørgensen
2021-01-13 11:11 ` David Howells
2021-01-13 11:36 ` Toke Høiland-Jørgensen
2021-01-13 12:57 ` David Howells
2021-01-18 17:13 ` Toke Høiland-Jørgensen
2021-01-18 21:09 ` João Fonseca
2021-01-21 5:58 ` Tee Hao Wei
2021-03-10 12:02 ` Greg KH
2021-03-15 10:52 ` Toke Høiland-Jørgensen
2021-03-15 12:07 ` Greg KH
2021-01-14 2:55 ` Jarkko Sakkinen [this message]
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=X/+yphcab4AERQJS@kernel.org \
--to=jarkko@kernel.org \
--cc=davem@davemloft.net \
--cc=dhowells@redhat.com \
--cc=gilad@benyossef.com \
--cc=herbert@gondor.apana.org.au \
--cc=keyrings@vger.kernel.org \
--cc=linux-crypto@vger.kernel.org \
--cc=stable@vger.kernel.org \
--cc=tianjia.zhang@linux.alibaba.com \
--cc=toke@redhat.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.