All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] X.509: Fix error code in x509_cert_parse()
@ 2017-05-23 14:27 ` Dan Carpenter
  0 siblings, 0 replies; 10+ messages in thread
From: Dan Carpenter @ 2017-05-23 14:27 UTC (permalink / raw)
  To: David Howells, Tadeusz Struk
  Cc: Herbert Xu, David S. Miller, keyrings, linux-crypto, kernel-janitors

We forgot to set the error code on this path so it could result in
returning NULL which leads to a NULL dereference.

Fixes: db6c43bd2132 ("crypto: KEYS: convert public key and digsig asym to the akcipher api")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

diff --git a/crypto/asymmetric_keys/x509_cert_parser.c b/crypto/asymmetric_keys/x509_cert_parser.c
index c80765b211cf..1f69e948fb34 100644
--- a/crypto/asymmetric_keys/x509_cert_parser.c
+++ b/crypto/asymmetric_keys/x509_cert_parser.c
@@ -103,8 +103,10 @@ struct x509_certificate *x509_cert_parse(const void *data, size_t datalen)
 	}
 
 	cert->pub->key = kmemdup(ctx->key, ctx->key_size, GFP_KERNEL);
-	if (!cert->pub->key)
+	if (!cert->pub->key) {
+		ret = -ENOMEM;
 		goto error_decode;
+	}
 
 	cert->pub->keylen = ctx->key_size;
 

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

* [PATCH] X.509: Fix error code in x509_cert_parse()
@ 2017-05-23 14:27 ` Dan Carpenter
  0 siblings, 0 replies; 10+ messages in thread
From: Dan Carpenter @ 2017-05-23 14:27 UTC (permalink / raw)
  To: David Howells, Tadeusz Struk
  Cc: Herbert Xu, David S. Miller, keyrings, linux-crypto, kernel-janitors

We forgot to set the error code on this path so it could result in
returning NULL which leads to a NULL dereference.

Fixes: db6c43bd2132 ("crypto: KEYS: convert public key and digsig asym to the akcipher api")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

diff --git a/crypto/asymmetric_keys/x509_cert_parser.c b/crypto/asymmetric_keys/x509_cert_parser.c
index c80765b211cf..1f69e948fb34 100644
--- a/crypto/asymmetric_keys/x509_cert_parser.c
+++ b/crypto/asymmetric_keys/x509_cert_parser.c
@@ -103,8 +103,10 @@ struct x509_certificate *x509_cert_parse(const void *data, size_t datalen)
 	}
 
 	cert->pub->key = kmemdup(ctx->key, ctx->key_size, GFP_KERNEL);
-	if (!cert->pub->key)
+	if (!cert->pub->key) {
+		ret = -ENOMEM;
 		goto error_decode;
+	}
 
 	cert->pub->keylen = ctx->key_size;
 

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

* Re: [PATCH] X.509: Fix error code in x509_cert_parse()
  2017-05-23 14:27 ` Dan Carpenter
@ 2017-05-23 16:49   ` David Howells
  -1 siblings, 0 replies; 10+ messages in thread
From: David Howells @ 2017-05-23 16:49 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: dhowells, Tadeusz Struk, Herbert Xu, David S. Miller, keyrings,
	linux-crypto, kernel-janitors

Dan Carpenter <dan.carpenter@oracle.com> wrote:

>  	cert->pub->key = kmemdup(ctx->key, ctx->key_size, GFP_KERNEL);
> -	if (!cert->pub->key)
> +	if (!cert->pub->key) {
> +		ret = -ENOMEM;
>  		goto error_decode;
> +	}

Put the "ret = -ENOMEM" line before the kmemdup line maybe?

David

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

* Re: [PATCH] X.509: Fix error code in x509_cert_parse()
@ 2017-05-23 16:49   ` David Howells
  0 siblings, 0 replies; 10+ messages in thread
From: David Howells @ 2017-05-23 16:49 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: dhowells, Tadeusz Struk, Herbert Xu, David S. Miller, keyrings,
	linux-crypto, kernel-janitors

Dan Carpenter <dan.carpenter@oracle.com> wrote:

>  	cert->pub->key = kmemdup(ctx->key, ctx->key_size, GFP_KERNEL);
> -	if (!cert->pub->key)
> +	if (!cert->pub->key) {
> +		ret = -ENOMEM;
>  		goto error_decode;
> +	}

Put the "ret = -ENOMEM" line before the kmemdup line maybe?

David

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

* [PATCH v2] X.509: Fix error code in x509_cert_parse()
  2017-05-23 16:49   ` David Howells
@ 2017-05-29 13:26     ` Dan Carpenter
  -1 siblings, 0 replies; 10+ messages in thread
From: Dan Carpenter @ 2017-05-29 13:26 UTC (permalink / raw)
  To: David Howells
  Cc: Herbert Xu, David S. Miller, keyrings, linux-crypto, kernel-janitors

We forgot to set the error code on this path so it could result in
returning NULL which leads to a NULL dereference.

Fixes: db6c43bd2132 ("crypto: KEYS: convert public key and digsig asym to the akcipher api")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
v2:  Style change

Sorry for the delay, I'm been out of office.

diff --git a/crypto/asymmetric_keys/x509_cert_parser.c b/crypto/asymmetric_keys/x509_cert_parser.c
index c80765b211cf..dd03fead1ca3 100644
--- a/crypto/asymmetric_keys/x509_cert_parser.c
+++ b/crypto/asymmetric_keys/x509_cert_parser.c
@@ -102,6 +102,7 @@ struct x509_certificate *x509_cert_parse(const void *data, size_t datalen)
 		}
 	}
 
+	ret = -ENOMEM;
 	cert->pub->key = kmemdup(ctx->key, ctx->key_size, GFP_KERNEL);
 	if (!cert->pub->key)
 		goto error_decode;

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

* [PATCH v2] X.509: Fix error code in x509_cert_parse()
@ 2017-05-29 13:26     ` Dan Carpenter
  0 siblings, 0 replies; 10+ messages in thread
From: Dan Carpenter @ 2017-05-29 13:26 UTC (permalink / raw)
  To: David Howells
  Cc: Herbert Xu, David S. Miller, keyrings, linux-crypto, kernel-janitors

We forgot to set the error code on this path so it could result in
returning NULL which leads to a NULL dereference.

Fixes: db6c43bd2132 ("crypto: KEYS: convert public key and digsig asym to the akcipher api")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
v2:  Style change

Sorry for the delay, I'm been out of office.

diff --git a/crypto/asymmetric_keys/x509_cert_parser.c b/crypto/asymmetric_keys/x509_cert_parser.c
index c80765b211cf..dd03fead1ca3 100644
--- a/crypto/asymmetric_keys/x509_cert_parser.c
+++ b/crypto/asymmetric_keys/x509_cert_parser.c
@@ -102,6 +102,7 @@ struct x509_certificate *x509_cert_parse(const void *data, size_t datalen)
 		}
 	}
 
+	ret = -ENOMEM;
 	cert->pub->key = kmemdup(ctx->key, ctx->key_size, GFP_KERNEL);
 	if (!cert->pub->key)
 		goto error_decode;

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

* Re: [PATCH v2] X.509: Fix error code in x509_cert_parse()
  2017-05-29 13:26     ` Dan Carpenter
@ 2017-06-10  4:18       ` Herbert Xu
  -1 siblings, 0 replies; 10+ messages in thread
From: Herbert Xu @ 2017-06-10  4:18 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: David Howells, David S. Miller, keyrings, linux-crypto, kernel-janitors

On Mon, May 29, 2017 at 04:26:22PM +0300, Dan Carpenter wrote:
> We forgot to set the error code on this path so it could result in
> returning NULL which leads to a NULL dereference.
> 
> Fixes: db6c43bd2132 ("crypto: KEYS: convert public key and digsig asym to the akcipher api")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> ---
> v2:  Style change

Patch applied.  Thanks.
-- 
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

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

* Re: [PATCH v2] X.509: Fix error code in x509_cert_parse()
@ 2017-06-10  4:18       ` Herbert Xu
  0 siblings, 0 replies; 10+ messages in thread
From: Herbert Xu @ 2017-06-10  4:18 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: David Howells, David S. Miller, keyrings, linux-crypto, kernel-janitors

On Mon, May 29, 2017 at 04:26:22PM +0300, Dan Carpenter wrote:
> We forgot to set the error code on this path so it could result in
> returning NULL which leads to a NULL dereference.
> 
> Fixes: db6c43bd2132 ("crypto: KEYS: convert public key and digsig asym to the akcipher api")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> ---
> v2:  Style change

Patch applied.  Thanks.
-- 
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

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

* Re: [PATCH v2] X.509: Fix error code in x509_cert_parse()
  2017-05-29 13:26     ` Dan Carpenter
@ 2017-06-10  6:14       ` David Howells
  -1 siblings, 0 replies; 10+ messages in thread
From: David Howells @ 2017-06-10  6:14 UTC (permalink / raw)
  To: Herbert Xu
  Cc: dhowells, Dan Carpenter, David S. Miller, keyrings, linux-crypto,
	kernel-janitors

Herbert Xu <herbert@gondor.apana.org.au> wrote:

> Patch applied.  Thanks.

Note that I've passed this on to James to pass on to Linus along with a bunch
of other patches.

David

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

* Re: [PATCH v2] X.509: Fix error code in x509_cert_parse()
@ 2017-06-10  6:14       ` David Howells
  0 siblings, 0 replies; 10+ messages in thread
From: David Howells @ 2017-06-10  6:14 UTC (permalink / raw)
  To: Herbert Xu
  Cc: dhowells, Dan Carpenter, David S. Miller, keyrings, linux-crypto,
	kernel-janitors

Herbert Xu <herbert@gondor.apana.org.au> wrote:

> Patch applied.  Thanks.

Note that I've passed this on to James to pass on to Linus along with a bunch
of other patches.

David

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

end of thread, other threads:[~2017-06-10  6:15 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-05-23 14:27 [PATCH] X.509: Fix error code in x509_cert_parse() Dan Carpenter
2017-05-23 14:27 ` Dan Carpenter
2017-05-23 16:49 ` David Howells
2017-05-23 16:49   ` David Howells
2017-05-29 13:26   ` [PATCH v2] " Dan Carpenter
2017-05-29 13:26     ` Dan Carpenter
2017-06-10  4:18     ` Herbert Xu
2017-06-10  4:18       ` Herbert Xu
2017-06-10  6:14     ` David Howells
2017-06-10  6:14       ` David Howells

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.