Skip to content

Commit

Permalink
crypto: ccp - Prevent information leakage on export
Browse files Browse the repository at this point in the history
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.

Cc: <stable@vger.kernel.org> # 3.14.x-
Reported-by: Ben Hutchings <ben@decadent.org.uk>
Signed-off-by: Tom Lendacky <thomas.lendacky@amd.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
  • Loading branch information
Tom Lendacky authored and Herbert Xu committed Apr 15, 2016
1 parent 0851561 commit f709b45
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
3 changes: 3 additions & 0 deletions drivers/crypto/ccp/ccp-crypto-aes-cmac.c
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,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_exp_ctx state;

/* Don't let anything leak to 'out' */
memset(&state, 0, sizeof(state));

state.null_msg = rctx->null_msg;
memcpy(state.iv, rctx->iv, sizeof(state.iv));
state.buf_count = rctx->buf_count;
Expand Down
3 changes: 3 additions & 0 deletions drivers/crypto/ccp/ccp-crypto-sha.c
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,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_exp_ctx state;

/* Don't let anything leak to 'out' */
memset(&state, 0, sizeof(state));

state.type = rctx->type;
state.msg_bits = rctx->msg_bits;
state.first = rctx->first;
Expand Down

0 comments on commit f709b45

Please sign in to comment.