mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-06 10:57:46 +00:00
crypto: qat - fix memory leak in RSA
[ Upstream commit80a52e1ee7
] When an RSA key represented in form 2 (as defined in PKCS #1 V2.1) is used, some components of the private key persist even after the TFM is released. Replace the explicit calls to free the buffers in qat_rsa_exit_tfm() with a call to qat_rsa_clear_ctx() which frees all buffers referenced in the TFM context. Cc: stable@vger.kernel.org Fixes:879f77e907
("crypto: qat - Add RSA CRT mode") Signed-off-by: Giovanni Cabiddu <giovanni.cabiddu@intel.com> Reviewed-by: Adam Guerin <adam.guerin@intel.com> Reviewed-by: Wojciech Ziemba <wojciech.ziemba@intel.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
parent
2cb73f42c8
commit
0f967fdc09
1 changed files with 1 additions and 11 deletions
|
@ -1257,18 +1257,8 @@ static void qat_rsa_exit_tfm(struct crypto_akcipher *tfm)
|
||||||
struct qat_rsa_ctx *ctx = akcipher_tfm_ctx(tfm);
|
struct qat_rsa_ctx *ctx = akcipher_tfm_ctx(tfm);
|
||||||
struct device *dev = &GET_DEV(ctx->inst->accel_dev);
|
struct device *dev = &GET_DEV(ctx->inst->accel_dev);
|
||||||
|
|
||||||
if (ctx->n)
|
qat_rsa_clear_ctx(dev, ctx);
|
||||||
dma_free_coherent(dev, ctx->key_sz, ctx->n, ctx->dma_n);
|
|
||||||
if (ctx->e)
|
|
||||||
dma_free_coherent(dev, ctx->key_sz, ctx->e, ctx->dma_e);
|
|
||||||
if (ctx->d) {
|
|
||||||
memset(ctx->d, '\0', ctx->key_sz);
|
|
||||||
dma_free_coherent(dev, ctx->key_sz, ctx->d, ctx->dma_d);
|
|
||||||
}
|
|
||||||
qat_crypto_put_instance(ctx->inst);
|
qat_crypto_put_instance(ctx->inst);
|
||||||
ctx->n = NULL;
|
|
||||||
ctx->e = NULL;
|
|
||||||
ctx->d = NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct akcipher_alg rsa = {
|
static struct akcipher_alg rsa = {
|
||||||
|
|
Loading…
Reference in a new issue