Skip to contentSkip to conversation

crypto: hash - initializing memory buffer for keys

PATCH In review Kangjie Lu 2 participants 2 messages Oct 18, 2019 Crypto API

lore
Share & tools
lore

Kangjie Lu

author
#0 lore raw

PATCH 1/1 crypto: hash - initializing memory buffer for keys

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

---
 crypto/algif_hash.c | 1 +
 1 file changed, 1 insertion(+)
crypto/algif_hash.c +1 -0
index 178f4cd75ef1..129a124e5056 100644
@@ -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;
Signature · 1 line
2.17.1
maintainer
#1 lore raw
Quoted 4 lines · Kangjie Lu

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

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

Cheers,

Signature · 3 lines
Email: Herbert Xu <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt