提交 a249067c 编写于 作者: K Kai Ye 提交者: Zheng Zengkai

crypto: hisilicon/sec - fix the aead software fallback for engine

mainline inclusion
from mainline-crypto-master
commit 0a2a464f
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I4W4WU
CVE: NA

--------------------------------

Due to the subreq pointer misuse the private context memory. The aead
soft crypto occasionally casues the OS panic as setting the 64K page.
Here is fix it.

Fixes: 6c46a329 ("crypto: hisilicon/sec - add fallback tfm...")
Signed-off-by: NKai Ye <yekai13@huawei.com>
Signed-off-by: NHerbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: NYang Shen <shenyang39@huawei.com>
Reviewed-by: NXiu Jianfeng <xiujianfeng@huawei.com>
Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
上级 ea71b362
...@@ -2295,9 +2295,10 @@ static int sec_aead_soft_crypto(struct sec_ctx *ctx, ...@@ -2295,9 +2295,10 @@ static int sec_aead_soft_crypto(struct sec_ctx *ctx,
struct aead_request *aead_req, struct aead_request *aead_req,
bool encrypt) bool encrypt)
{ {
struct aead_request *subreq = aead_request_ctx(aead_req);
struct sec_auth_ctx *a_ctx = &ctx->a_ctx; struct sec_auth_ctx *a_ctx = &ctx->a_ctx;
struct device *dev = ctx->dev; struct device *dev = ctx->dev;
struct aead_request *subreq;
int ret;
/* Kunpeng920 aead mode not support input 0 size */ /* Kunpeng920 aead mode not support input 0 size */
if (!a_ctx->fallback_aead_tfm) { if (!a_ctx->fallback_aead_tfm) {
...@@ -2305,6 +2306,10 @@ static int sec_aead_soft_crypto(struct sec_ctx *ctx, ...@@ -2305,6 +2306,10 @@ static int sec_aead_soft_crypto(struct sec_ctx *ctx,
return -EINVAL; return -EINVAL;
} }
subreq = aead_request_alloc(a_ctx->fallback_aead_tfm, GFP_KERNEL);
if (!subreq)
return -ENOMEM;
aead_request_set_tfm(subreq, a_ctx->fallback_aead_tfm); aead_request_set_tfm(subreq, a_ctx->fallback_aead_tfm);
aead_request_set_callback(subreq, aead_req->base.flags, aead_request_set_callback(subreq, aead_req->base.flags,
aead_req->base.complete, aead_req->base.data); aead_req->base.complete, aead_req->base.data);
...@@ -2312,8 +2317,13 @@ static int sec_aead_soft_crypto(struct sec_ctx *ctx, ...@@ -2312,8 +2317,13 @@ static int sec_aead_soft_crypto(struct sec_ctx *ctx,
aead_req->cryptlen, aead_req->iv); aead_req->cryptlen, aead_req->iv);
aead_request_set_ad(subreq, aead_req->assoclen); aead_request_set_ad(subreq, aead_req->assoclen);
return encrypt ? crypto_aead_encrypt(subreq) : if (encrypt)
crypto_aead_decrypt(subreq); ret = crypto_aead_encrypt(subreq);
else
ret = crypto_aead_decrypt(subreq);
aead_request_free(subreq);
return ret;
} }
static int sec_aead_crypto(struct aead_request *a_req, bool encrypt) static int sec_aead_crypto(struct aead_request *a_req, bool encrypt)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册