Commit dad41d54 authored by Tom Lendacky's avatar Tom Lendacky Committed by Sasha Levin

crypto: ccp - memset request context to zero during import

[ Upstream commit ce0ae266 ]

Since a crypto_ahash_import() can be called against a request context
that has not had a crypto_ahash_init() performed, the request context
needs to be cleared to insure there is no random data present. If not,
the random data can result in a kernel oops during crypto_ahash_update().

Cc: <stable@vger.kernel.org> # 3.14.x-
Signed-off-by: default avatarTom Lendacky <thomas.lendacky@amd.com>
Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: default avatarSasha Levin <sasha.levin@oracle.com>
parent 503f8305
...@@ -226,6 +226,7 @@ static int ccp_aes_cmac_import(struct ahash_request *req, const void *in) ...@@ -226,6 +226,7 @@ static int ccp_aes_cmac_import(struct ahash_request *req, const void *in)
/* 'in' may not be aligned so memcpy to local variable */ /* 'in' may not be aligned so memcpy to local variable */
memcpy(&state, in, sizeof(state)); memcpy(&state, in, sizeof(state));
memset(rctx, 0, sizeof(*rctx));
rctx->null_msg = state.null_msg; rctx->null_msg = state.null_msg;
memcpy(rctx->iv, state.iv, sizeof(rctx->iv)); memcpy(rctx->iv, state.iv, sizeof(rctx->iv));
rctx->buf_count = state.buf_count; rctx->buf_count = state.buf_count;
......
...@@ -220,6 +220,7 @@ static int ccp_sha_import(struct ahash_request *req, const void *in) ...@@ -220,6 +220,7 @@ static int ccp_sha_import(struct ahash_request *req, const void *in)
/* 'in' may not be aligned so memcpy to local variable */ /* 'in' may not be aligned so memcpy to local variable */
memcpy(&state, in, sizeof(state)); memcpy(&state, in, sizeof(state));
memset(rctx, 0, sizeof(*rctx));
rctx->type = state.type; rctx->type = state.type;
rctx->msg_bits = state.msg_bits; rctx->msg_bits = state.msg_bits;
rctx->first = state.first; rctx->first = state.first;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment