diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2016-04-20 15:00:07 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2016-04-20 15:00:07 -0400 |
commit | 55f058e7574c3615dea4615573a19bdb258696c6 (patch) | |
tree | d61a76190d448f42a60e20a541b4808459f1b333 | |
parent | 9a0e3eea25d3ab267aff9d4eaed83fbe46d989d0 (diff) | |
parent | f709b45ec461b548c41a00044dba1f1b572783bf (diff) |
Merge branch 'linus' of git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6
Pull crypto fixes from Herbert Xu:
"This fixes the following issues:
- Incorrect output buffer size calculation in rsa-pkcs1pad
- Uninitialised padding bytes on exported state in ccp driver
- Potentially freed pointer used on completion callback in sha1-mb"
* 'linus' of git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6:
crypto: ccp - Prevent information leakage on export
crypto: sha1-mb - use corrcet pointer while completing jobs
crypto: rsa-pkcs1pad - fix dst len
-rw-r--r-- | arch/x86/crypto/sha-mb/sha1_mb.c | 4 | ||||
-rw-r--r-- | crypto/rsa-pkcs1pad.c | 12 | ||||
-rw-r--r-- | drivers/crypto/ccp/ccp-crypto-aes-cmac.c | 3 | ||||
-rw-r--r-- | drivers/crypto/ccp/ccp-crypto-sha.c | 3 |
4 files changed, 14 insertions, 8 deletions
diff --git a/arch/x86/crypto/sha-mb/sha1_mb.c b/arch/x86/crypto/sha-mb/sha1_mb.c index a8a0224fa0f8..081255cea1ee 100644 --- a/arch/x86/crypto/sha-mb/sha1_mb.c +++ b/arch/x86/crypto/sha-mb/sha1_mb.c | |||
@@ -453,10 +453,10 @@ static int sha_complete_job(struct mcryptd_hash_request_ctx *rctx, | |||
453 | 453 | ||
454 | req = cast_mcryptd_ctx_to_req(req_ctx); | 454 | req = cast_mcryptd_ctx_to_req(req_ctx); |
455 | if (irqs_disabled()) | 455 | if (irqs_disabled()) |
456 | rctx->complete(&req->base, ret); | 456 | req_ctx->complete(&req->base, ret); |
457 | else { | 457 | else { |
458 | local_bh_disable(); | 458 | local_bh_disable(); |
459 | rctx->complete(&req->base, ret); | 459 | req_ctx->complete(&req->base, ret); |
460 | local_bh_enable(); | 460 | local_bh_enable(); |
461 | } | 461 | } |
462 | } | 462 | } |
diff --git a/crypto/rsa-pkcs1pad.c b/crypto/rsa-pkcs1pad.c index 1cea67d43e1d..ead8dc0d084e 100644 --- a/crypto/rsa-pkcs1pad.c +++ b/crypto/rsa-pkcs1pad.c | |||
@@ -387,16 +387,16 @@ static int pkcs1pad_decrypt(struct akcipher_request *req) | |||
387 | req_ctx->child_req.src = req->src; | 387 | req_ctx->child_req.src = req->src; |
388 | req_ctx->child_req.src_len = req->src_len; | 388 | req_ctx->child_req.src_len = req->src_len; |
389 | req_ctx->child_req.dst = req_ctx->out_sg; | 389 | req_ctx->child_req.dst = req_ctx->out_sg; |
390 | req_ctx->child_req.dst_len = ctx->key_size - 1; | 390 | req_ctx->child_req.dst_len = ctx->key_size ; |
391 | 391 | ||
392 | req_ctx->out_buf = kmalloc(ctx->key_size - 1, | 392 | req_ctx->out_buf = kmalloc(ctx->key_size, |
393 | (req->base.flags & CRYPTO_TFM_REQ_MAY_SLEEP) ? | 393 | (req->base.flags & CRYPTO_TFM_REQ_MAY_SLEEP) ? |
394 | GFP_KERNEL : GFP_ATOMIC); | 394 | GFP_KERNEL : GFP_ATOMIC); |
395 | if (!req_ctx->out_buf) | 395 | if (!req_ctx->out_buf) |
396 | return -ENOMEM; | 396 | return -ENOMEM; |
397 | 397 | ||
398 | pkcs1pad_sg_set_buf(req_ctx->out_sg, req_ctx->out_buf, | 398 | pkcs1pad_sg_set_buf(req_ctx->out_sg, req_ctx->out_buf, |
399 | ctx->key_size - 1, NULL); | 399 | ctx->key_size, NULL); |
400 | 400 | ||
401 | akcipher_request_set_tfm(&req_ctx->child_req, ctx->child); | 401 | akcipher_request_set_tfm(&req_ctx->child_req, ctx->child); |
402 | akcipher_request_set_callback(&req_ctx->child_req, req->base.flags, | 402 | akcipher_request_set_callback(&req_ctx->child_req, req->base.flags, |
@@ -595,16 +595,16 @@ static int pkcs1pad_verify(struct akcipher_request *req) | |||
595 | req_ctx->child_req.src = req->src; | 595 | req_ctx->child_req.src = req->src; |
596 | req_ctx->child_req.src_len = req->src_len; | 596 | req_ctx->child_req.src_len = req->src_len; |
597 | req_ctx->child_req.dst = req_ctx->out_sg; | 597 | req_ctx->child_req.dst = req_ctx->out_sg; |
598 | req_ctx->child_req.dst_len = ctx->key_size - 1; | 598 | req_ctx->child_req.dst_len = ctx->key_size; |
599 | 599 | ||
600 | req_ctx->out_buf = kmalloc(ctx->key_size - 1, | 600 | req_ctx->out_buf = kmalloc(ctx->key_size, |
601 | (req->base.flags & CRYPTO_TFM_REQ_MAY_SLEEP) ? | 601 | (req->base.flags & CRYPTO_TFM_REQ_MAY_SLEEP) ? |
602 | GFP_KERNEL : GFP_ATOMIC); | 602 | GFP_KERNEL : GFP_ATOMIC); |
603 | if (!req_ctx->out_buf) | 603 | if (!req_ctx->out_buf) |
604 | return -ENOMEM; | 604 | return -ENOMEM; |
605 | 605 | ||
606 | pkcs1pad_sg_set_buf(req_ctx->out_sg, req_ctx->out_buf, | 606 | pkcs1pad_sg_set_buf(req_ctx->out_sg, req_ctx->out_buf, |
607 | ctx->key_size - 1, NULL); | 607 | ctx->key_size, NULL); |
608 | 608 | ||
609 | akcipher_request_set_tfm(&req_ctx->child_req, ctx->child); | 609 | akcipher_request_set_tfm(&req_ctx->child_req, ctx->child); |
610 | akcipher_request_set_callback(&req_ctx->child_req, req->base.flags, | 610 | akcipher_request_set_callback(&req_ctx->child_req, req->base.flags, |
diff --git a/drivers/crypto/ccp/ccp-crypto-aes-cmac.c b/drivers/crypto/ccp/ccp-crypto-aes-cmac.c index 3d9acc53d247..60fc0fa26fd3 100644 --- a/drivers/crypto/ccp/ccp-crypto-aes-cmac.c +++ b/drivers/crypto/ccp/ccp-crypto-aes-cmac.c | |||
@@ -225,6 +225,9 @@ static int ccp_aes_cmac_export(struct ahash_request *req, void *out) | |||
225 | struct ccp_aes_cmac_req_ctx *rctx = ahash_request_ctx(req); | 225 | struct ccp_aes_cmac_req_ctx *rctx = ahash_request_ctx(req); |
226 | struct ccp_aes_cmac_exp_ctx state; | 226 | struct ccp_aes_cmac_exp_ctx state; |
227 | 227 | ||
228 | /* Don't let anything leak to 'out' */ | ||
229 | memset(&state, 0, sizeof(state)); | ||
230 | |||
228 | state.null_msg = rctx->null_msg; | 231 | state.null_msg = rctx->null_msg; |
229 | memcpy(state.iv, rctx->iv, sizeof(state.iv)); | 232 | memcpy(state.iv, rctx->iv, sizeof(state.iv)); |
230 | state.buf_count = rctx->buf_count; | 233 | state.buf_count = rctx->buf_count; |
diff --git a/drivers/crypto/ccp/ccp-crypto-sha.c b/drivers/crypto/ccp/ccp-crypto-sha.c index b5ad72897dc2..8f36af62fe95 100644 --- a/drivers/crypto/ccp/ccp-crypto-sha.c +++ b/drivers/crypto/ccp/ccp-crypto-sha.c | |||
@@ -212,6 +212,9 @@ static int ccp_sha_export(struct ahash_request *req, void *out) | |||
212 | struct ccp_sha_req_ctx *rctx = ahash_request_ctx(req); | 212 | struct ccp_sha_req_ctx *rctx = ahash_request_ctx(req); |
213 | struct ccp_sha_exp_ctx state; | 213 | struct ccp_sha_exp_ctx state; |
214 | 214 | ||
215 | /* Don't let anything leak to 'out' */ | ||
216 | memset(&state, 0, sizeof(state)); | ||
217 | |||
215 | state.type = rctx->type; | 218 | state.type = rctx->type; |
216 | state.msg_bits = rctx->msg_bits; | 219 | state.msg_bits = rctx->msg_bits; |
217 | state.first = rctx->first; | 220 | state.first = rctx->first; |