提交 d270bb4c 编写于 作者: N Nicolas Toromanoff 提交者: Zheng Zengkai

crypto: stm32/cryp - fix xts and race condition in crypto_engine requests

stable inclusion
from stable-v5.10.94
commit 5deb24e50372357cf975e85067f09a57ad33dc99
bugzilla: https://gitee.com/openeuler/kernel/issues/I531X9

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=5deb24e50372357cf975e85067f09a57ad33dc99

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

[ Upstream commit d703c7a9 ]

Don't erase key:
If key is erased before the crypto_finalize_.*_request() call, some
pending process will run with a key={ 0 }.
Moreover if the key is reset at end of request, it breaks xts chaining
mode, as for last xts block (in case input len is not a multiple of
block) a new AES request is started without calling again set_key().

Fixes: 9e054ec2 ("crypto: stm32 - Support for STM32 CRYP crypto module")
Signed-off-by: NNicolas Toromanoff <nicolas.toromanoff@foss.st.com>
Signed-off-by: NHerbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: NSasha Levin <sashal@kernel.org>
Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
Acked-by: NXie XiuQi <xiexiuqi@huawei.com>
上级 a1064938
...@@ -674,8 +674,6 @@ static void stm32_cryp_finish_req(struct stm32_cryp *cryp, int err) ...@@ -674,8 +674,6 @@ static void stm32_cryp_finish_req(struct stm32_cryp *cryp, int err)
else else
crypto_finalize_skcipher_request(cryp->engine, cryp->req, crypto_finalize_skcipher_request(cryp->engine, cryp->req,
err); err);
memset(cryp->ctx->key, 0, cryp->ctx->keylen);
} }
static int stm32_cryp_cpu_start(struct stm32_cryp *cryp) static int stm32_cryp_cpu_start(struct stm32_cryp *cryp)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册