mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-11 12:28:41 +08:00
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>
This commit is contained in:
parent
4d666dbefc
commit
ec9f2006fc
@ -688,16 +688,18 @@ static void cryptd_aead_crypt(struct aead_request *req,
|
|||||||
int (*crypt)(struct aead_request *req))
|
int (*crypt)(struct aead_request *req))
|
||||||
{
|
{
|
||||||
struct cryptd_aead_request_ctx *rctx;
|
struct cryptd_aead_request_ctx *rctx;
|
||||||
|
crypto_completion_t compl;
|
||||||
|
|
||||||
rctx = aead_request_ctx(req);
|
rctx = aead_request_ctx(req);
|
||||||
|
compl = rctx->complete;
|
||||||
|
|
||||||
if (unlikely(err == -EINPROGRESS))
|
if (unlikely(err == -EINPROGRESS))
|
||||||
goto out;
|
goto out;
|
||||||
aead_request_set_tfm(req, child);
|
aead_request_set_tfm(req, child);
|
||||||
err = crypt( req );
|
err = crypt( req );
|
||||||
req->base.complete = rctx->complete;
|
|
||||||
out:
|
out:
|
||||||
local_bh_disable();
|
local_bh_disable();
|
||||||
rctx->complete(&req->base, err);
|
compl(&req->base, err);
|
||||||
local_bh_enable();
|
local_bh_enable();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -756,7 +758,9 @@ static int cryptd_aead_init_tfm(struct crypto_aead *tfm)
|
|||||||
return PTR_ERR(cipher);
|
return PTR_ERR(cipher);
|
||||||
|
|
||||||
ctx->child = cipher;
|
ctx->child = cipher;
|
||||||
crypto_aead_set_reqsize(tfm, sizeof(struct cryptd_aead_request_ctx));
|
crypto_aead_set_reqsize(
|
||||||
|
tfm, max((unsigned)sizeof(struct cryptd_aead_request_ctx),
|
||||||
|
crypto_aead_reqsize(cipher)));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -775,7 +779,7 @@ static int cryptd_create_aead(struct crypto_template *tmpl,
|
|||||||
struct aead_alg *alg;
|
struct aead_alg *alg;
|
||||||
const char *name;
|
const char *name;
|
||||||
u32 type = 0;
|
u32 type = 0;
|
||||||
u32 mask = 0;
|
u32 mask = CRYPTO_ALG_ASYNC;
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
cryptd_check_internal(tb, &type, &mask);
|
cryptd_check_internal(tb, &type, &mask);
|
||||||
|
Loading…
Reference in New Issue
Block a user