All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] crypto: public_key: check that pkey_algo is non-NULL before passing it to strcmp()
@ 2021-01-12 16:10 Toke Høiland-Jørgensen
  2021-01-13  2:39 ` Tianjia Zhang
  2021-01-13 11:11 ` David Howells
  0 siblings, 2 replies; 13+ messages in thread
From: Toke Høiland-Jørgensen @ 2021-01-12 16:10 UTC (permalink / raw)
  To: David Howells, Herbert Xu, David S. Miller
  Cc: Toke Høiland-Jørgensen, Tianjia Zhang,
	Gilad Ben-Yossef, keyrings, linux-crypto, stable

When public_key_verify_signature() is called from
asymmetric_key_verify_signature(), the pkey_algo field of struct
public_key_signature will be NULL, which causes a NULL pointer dereference
in the strcmp() check. Fix this by adding a NULL check.

One visible manifestation of this is that userspace programs (such as the
'iwd' WiFi daemon) will be killed when trying to verify a TLS key using the
keyctl(2) interface.

Cc: stable@vger.kernel.org
Fixes: 215525639631 ("X.509: support OSCCA SM2-with-SM3 certificate verification")
Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
---
 crypto/asymmetric_keys/public_key.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/crypto/asymmetric_keys/public_key.c b/crypto/asymmetric_keys/public_key.c
index 8892908ad58c..35b09e95a870 100644
--- a/crypto/asymmetric_keys/public_key.c
+++ b/crypto/asymmetric_keys/public_key.c
@@ -356,7 +356,7 @@ 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;
-- 
2.30.0


^ permalink raw reply related	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2021-03-15 12:08 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 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.