Commit 8a0d929b authored by Jia Jie Ho's avatar Jia Jie Ho Committed by Herbert Xu

crypto: starfive - Pad adata with zeroes

Aad requires padding with zeroes up to 15 bytes in some cases. This
patch increases the allocated buffer size for aad and prevents the
driver accessing uninitialized memory region.

v1->v2: Specify reason for alloc size change in descriptions.
Signed-off-by: default avatarJia Jie Ho <jiajie.ho@starfivetech.com>
Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
parent cc03a934
...@@ -500,7 +500,7 @@ static int starfive_aes_prepare_req(struct skcipher_request *req, ...@@ -500,7 +500,7 @@ static int starfive_aes_prepare_req(struct skcipher_request *req,
scatterwalk_start(&cryp->out_walk, rctx->out_sg); scatterwalk_start(&cryp->out_walk, rctx->out_sg);
if (cryp->assoclen) { if (cryp->assoclen) {
rctx->adata = kzalloc(ALIGN(cryp->assoclen, AES_BLOCK_SIZE), GFP_KERNEL); rctx->adata = kzalloc(cryp->assoclen + AES_BLOCK_SIZE, GFP_KERNEL);
if (!rctx->adata) if (!rctx->adata)
return dev_err_probe(cryp->dev, -ENOMEM, return dev_err_probe(cryp->dev, -ENOMEM,
"Failed to alloc memory for adata"); "Failed to alloc memory for adata");
...@@ -569,7 +569,7 @@ static int starfive_aes_aead_do_one_req(struct crypto_engine *engine, void *areq ...@@ -569,7 +569,7 @@ static int starfive_aes_aead_do_one_req(struct crypto_engine *engine, void *areq
struct starfive_cryp_ctx *ctx = struct starfive_cryp_ctx *ctx =
crypto_aead_ctx(crypto_aead_reqtfm(req)); crypto_aead_ctx(crypto_aead_reqtfm(req));
struct starfive_cryp_dev *cryp = ctx->cryp; struct starfive_cryp_dev *cryp = ctx->cryp;
struct starfive_cryp_request_ctx *rctx = ctx->rctx; struct starfive_cryp_request_ctx *rctx;
u32 block[AES_BLOCK_32]; u32 block[AES_BLOCK_32];
u32 stat; u32 stat;
int err; int err;
...@@ -579,6 +579,8 @@ static int starfive_aes_aead_do_one_req(struct crypto_engine *engine, void *areq ...@@ -579,6 +579,8 @@ static int starfive_aes_aead_do_one_req(struct crypto_engine *engine, void *areq
if (err) if (err)
return err; return err;
rctx = ctx->rctx;
if (!cryp->assoclen) if (!cryp->assoclen)
goto write_text; goto write_text;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment