Skip to content

Commit

Permalink
crypto: ccp - memset request context to zero during import
Browse files Browse the repository at this point in the history
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: 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 Feb 27, 2016
1 parent 9c6bd0c commit ce0ae26
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 0 deletions.
1 change: 1 addition & 0 deletions drivers/crypto/ccp/ccp-crypto-aes-cmac.c
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,7 @@ static int ccp_aes_cmac_import(struct ahash_request *req, const void *in)
/* 'in' may not be aligned so memcpy to local variable */
memcpy(&state, in, sizeof(state));

memset(rctx, 0, sizeof(*rctx));
rctx->null_msg = state.null_msg;
memcpy(rctx->iv, state.iv, sizeof(rctx->iv));
rctx->buf_count = state.buf_count;
Expand Down
1 change: 1 addition & 0 deletions drivers/crypto/ccp/ccp-crypto-sha.c
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,7 @@ static int ccp_sha_import(struct ahash_request *req, const void *in)
/* 'in' may not be aligned so memcpy to local variable */
memcpy(&state, in, sizeof(state));

memset(rctx, 0, sizeof(*rctx));
rctx->type = state.type;
rctx->msg_bits = state.msg_bits;
rctx->first = state.first;
Expand Down

0 comments on commit ce0ae26

Please sign in to comment.