Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

crypto: cryptd - Use subreq for AEAD

AEAD reuses the existing request object for its child. This is
error-prone and unnecessary. This patch adds a subrequest object
just like we do for skcipher and hash.

This patch also restores the original completion function as we
do for skcipher/hash.

Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

+16 -4
+16 -4
crypto/cryptd.c
··· 93 93 94 94 struct cryptd_aead_request_ctx { 95 95 crypto_completion_t complete; 96 + struct aead_request req; 96 97 }; 97 98 98 99 static void cryptd_queue_worker(struct work_struct *work); ··· 716 715 int (*crypt)(struct aead_request *req)) 717 716 { 718 717 struct cryptd_aead_request_ctx *rctx; 718 + struct aead_request *subreq; 719 719 struct cryptd_aead_ctx *ctx; 720 720 crypto_completion_t compl; 721 721 struct crypto_aead *tfm; ··· 724 722 725 723 rctx = aead_request_ctx(req); 726 724 compl = rctx->complete; 725 + subreq = &rctx->req; 727 726 728 727 tfm = crypto_aead_reqtfm(req); 729 728 730 729 if (unlikely(err == -EINPROGRESS)) 731 730 goto out; 732 - aead_request_set_tfm(req, child); 733 - err = crypt( req ); 731 + 732 + aead_request_set_tfm(subreq, child); 733 + aead_request_set_callback(subreq, CRYPTO_TFM_REQ_MAY_SLEEP, 734 + NULL, NULL); 735 + aead_request_set_crypt(subreq, req->src, req->dst, req->cryptlen, 736 + req->iv); 737 + aead_request_set_ad(subreq, req->assoclen); 738 + 739 + err = crypt(subreq); 740 + 741 + req->base.complete = compl; 734 742 735 743 out: 736 744 ctx = crypto_aead_ctx(tfm); ··· 810 798 811 799 ctx->child = cipher; 812 800 crypto_aead_set_reqsize( 813 - tfm, max((unsigned)sizeof(struct cryptd_aead_request_ctx), 814 - crypto_aead_reqsize(cipher))); 801 + tfm, sizeof(struct cryptd_aead_request_ctx) + 802 + crypto_aead_reqsize(cipher)); 815 803 return 0; 816 804 } 817 805