Commit 85778f69 authored by Tom Lendacky's avatar Tom Lendacky Committed by Kamal Mostafa

crypto: ccp - Prevent information leakage on export

commit f709b45e upstream.

Prevent information from leaking to userspace by doing a memset to 0 of
the export state structure before setting the structure values and copying
it. This prevents un-initialized padding areas from being copied into the
export area.
Reported-by: default avatarBen Hutchings <ben@decadent.org.uk>
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 avatarKamal Mostafa <kamal@canonical.com>
parent f1e1baba
...@@ -207,6 +207,9 @@ static int ccp_aes_cmac_export(struct ahash_request *req, void *out) ...@@ -207,6 +207,9 @@ static int ccp_aes_cmac_export(struct ahash_request *req, void *out)
struct ccp_aes_cmac_req_ctx *rctx = ahash_request_ctx(req); struct ccp_aes_cmac_req_ctx *rctx = ahash_request_ctx(req);
struct ccp_aes_cmac_exp_ctx state; struct ccp_aes_cmac_exp_ctx state;
/* Don't let anything leak to 'out' */
memset(&state, 0, sizeof(state));
state.null_msg = rctx->null_msg; state.null_msg = rctx->null_msg;
memcpy(state.iv, rctx->iv, sizeof(state.iv)); memcpy(state.iv, rctx->iv, sizeof(state.iv));
state.buf_count = rctx->buf_count; state.buf_count = rctx->buf_count;
......
...@@ -199,6 +199,9 @@ static int ccp_sha_export(struct ahash_request *req, void *out) ...@@ -199,6 +199,9 @@ static int ccp_sha_export(struct ahash_request *req, void *out)
struct ccp_sha_req_ctx *rctx = ahash_request_ctx(req); struct ccp_sha_req_ctx *rctx = ahash_request_ctx(req);
struct ccp_sha_exp_ctx state; struct ccp_sha_exp_ctx state;
/* Don't let anything leak to 'out' */
memset(&state, 0, sizeof(state));
state.type = rctx->type; state.type = rctx->type;
state.msg_bits = rctx->msg_bits; state.msg_bits = rctx->msg_bits;
state.first = rctx->first; state.first = rctx->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