summaryrefslogtreecommitdiffstats
path: root/crypto/cryptd.c
diff options
context:
space:
mode:
authorHerbert Xu <herbert@gondor.apana.org.au>2015-07-06 07:11:03 -0400
committerHerbert Xu <herbert@gondor.apana.org.au>2015-07-07 09:54:26 -0400
commitec9f2006fc020c58f32f01b9d68fdb5f7374ffce (patch)
tree4e331d6bde27e17aaa681caec70e412e0317ff53 /crypto/cryptd.c
parent4d666dbefcb094a2f35a0fc8a3c7b53dd8375e34 (diff)
crypto: cryptd - Fix AEAD request context corruption
The AEAD version of cryptd uses the same context for its own state as well as that of the child. In doing so it did not maintain the proper ordering, thus resulting in potential state corruption where the child will overwrite the state stored by cryptd. This patch fixes and also sets the request size properly. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'crypto/cryptd.c')
-rw-r--r--crypto/cryptd.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/crypto/cryptd.c b/crypto/cryptd.c
index 22ba81f76764..2f833dcc1711 100644
--- a/crypto/cryptd.c
+++ b/crypto/cryptd.c
@@ -688,16 +688,18 @@ static void cryptd_aead_crypt(struct aead_request *req,
688 int (*crypt)(struct aead_request *req)) 688 int (*crypt)(struct aead_request *req))
689{ 689{
690 struct cryptd_aead_request_ctx *rctx; 690 struct cryptd_aead_request_ctx *rctx;
691 crypto_completion_t compl;
692
691 rctx = aead_request_ctx(req); 693 rctx = aead_request_ctx(req);
694 compl = rctx->complete;
692 695
693 if (unlikely(err == -EINPROGRESS)) 696 if (unlikely(err == -EINPROGRESS))
694 goto out; 697 goto out;
695 aead_request_set_tfm(req, child); 698 aead_request_set_tfm(req, child);
696 err = crypt( req ); 699 err = crypt( req );
697 req->base.complete = rctx->complete;
698out: 700out:
699 local_bh_disable(); 701 local_bh_disable();
700 rctx->complete(&req->base, err); 702 compl(&req->base, err);
701 local_bh_enable(); 703 local_bh_enable();
702} 704}
703 705
@@ -756,7 +758,9 @@ static int cryptd_aead_init_tfm(struct crypto_aead *tfm)
756 return PTR_ERR(cipher); 758 return PTR_ERR(cipher);
757 759
758 ctx->child = cipher; 760 ctx->child = cipher;
759 crypto_aead_set_reqsize(tfm, sizeof(struct cryptd_aead_request_ctx)); 761 crypto_aead_set_reqsize(
762 tfm, max((unsigned)sizeof(struct cryptd_aead_request_ctx),
763 crypto_aead_reqsize(cipher)));
760 return 0; 764 return 0;
761} 765}
762 766
@@ -775,7 +779,7 @@ static int cryptd_create_aead(struct crypto_template *tmpl,
775 struct aead_alg *alg; 779 struct aead_alg *alg;
776 const char *name; 780 const char *name;
777 u32 type = 0; 781 u32 type = 0;
778 u32 mask = 0; 782 u32 mask = CRYPTO_ALG_ASYNC;
779 int err; 783 int err;
780 784
781 cryptd_check_internal(tb, &type, &mask); 785 cryptd_check_internal(tb, &type, &mask);