linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] crypto: hash - initializing memory buffer for keys
@ 2019-10-18  5:04 Kangjie Lu
  2019-10-18  6:27 ` Herbert Xu
  0 siblings, 1 reply; 2+ messages in thread
From: Kangjie Lu @ 2019-10-18  5:04 UTC (permalink / raw)
  To: kjlu; +Cc: Herbert Xu, David S. Miller, linux-crypto, linux-kernel

"ctx" is uninitialized. To avoid undefined behaviors or memory
disclosures, we better initialize it.

Signed-off-by: Kangjie Lu <kjlu@umn.edu>
---
 crypto/algif_hash.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/crypto/algif_hash.c b/crypto/algif_hash.c
index 178f4cd75ef1..129a124e5056 100644
--- a/crypto/algif_hash.c
+++ b/crypto/algif_hash.c
@@ -433,6 +433,7 @@ static int hash_accept_parent_nokey(void *private, struct sock *sk)
 	ctx = sock_kmalloc(sk, len, GFP_KERNEL);
 	if (!ctx)
 		return -ENOMEM;
+	memset(ctx, 0, len);
 
 	ctx->result = NULL;
 	ctx->len = len;
-- 
2.17.1


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

* Re: [PATCH] crypto: hash - initializing memory buffer for keys
  2019-10-18  5:04 [PATCH] crypto: hash - initializing memory buffer for keys Kangjie Lu
@ 2019-10-18  6:27 ` Herbert Xu
  0 siblings, 0 replies; 2+ messages in thread
From: Herbert Xu @ 2019-10-18  6:27 UTC (permalink / raw)
  To: Kangjie Lu; +Cc: David S. Miller, linux-crypto, linux-kernel

On Fri, Oct 18, 2019 at 12:04:56AM -0500, Kangjie Lu wrote:
> "ctx" is uninitialized. To avoid undefined behaviors or memory
> disclosures, we better initialize it.
> 
> Signed-off-by: Kangjie Lu <kjlu@umn.edu>

Please be more specific about what undefined behaviours you're
referring to.

Cheers,
-- 
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] 2+ messages in thread

end of thread, other threads:[~2019-10-18  6:28 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-18  5:04 [PATCH] crypto: hash - initializing memory buffer for keys Kangjie Lu
2019-10-18  6:27 ` Herbert Xu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).