- Added CoDA feature support in the context of CVM. When virtcca cvm is enabled, the iommu is tagged as secure. - hw/block: fix uint32 overflow - hw/ufs: add basic info of query response upiu - crypto: avoid leak of ctx when bad cipher mode is given Fixes: Coverity CID 1546884 Signed-off-by: Jiabo Feng <fengjiabo1@huawei.com>
49 lines
1.9 KiB
Diff
49 lines
1.9 KiB
Diff
From a0c5ce95e94a4621b12262423bfa021accb07625 Mon Sep 17 00:00:00 2001
|
|
From: dinglimin <dinglimin@cmss.chinamobile.com>
|
|
Date: Mon, 16 Sep 2024 17:22:02 +0800
|
|
Subject: [PATCH] =?UTF-8?q?crypto:=20avoid=20leak=20of=20ctx=20when=20bad?=
|
|
=?UTF-8?q?=20cipher=20mode=20is=20given=20Fixes:=20Coverity=20CID=2015468?=
|
|
=?UTF-8?q?84=20cherry=20picked=20from=20586ac2c67d707c2588766c5195d94fa55?=
|
|
=?UTF-8?q?3cc25af=20Reviewed-by:=20Peter=20Maydell=20<peter.maydell@linar?=
|
|
=?UTF-8?q?o.org>=20Reviewed-by:=20Philippe=20Mathieu-Daud=C3=A9=20<philmd?=
|
|
=?UTF-8?q?@linaro.org>=20Signed-off-by:=20Daniel=20P.=20Berrang=C3=A9=20<?=
|
|
=?UTF-8?q?berrange@redhat.com>=20Signed-off-by:=20dinglimin=20<dinglimin@?=
|
|
=?UTF-8?q?cmss.chinamobile.com>?=
|
|
MIME-Version: 1.0
|
|
Content-Type: text/plain; charset=UTF-8
|
|
Content-Transfer-Encoding: 8bit
|
|
|
|
---
|
|
crypto/cipher-nettle.c.inc | 7 +++++--
|
|
1 file changed, 5 insertions(+), 2 deletions(-)
|
|
|
|
diff --git a/crypto/cipher-nettle.c.inc b/crypto/cipher-nettle.c.inc
|
|
index 42b39e18a2..766de036ba 100644
|
|
--- a/crypto/cipher-nettle.c.inc
|
|
+++ b/crypto/cipher-nettle.c.inc
|
|
@@ -734,16 +734,19 @@ static QCryptoCipher *qcrypto_cipher_ctx_new(QCryptoCipherAlgorithm alg,
|
|
#ifdef CONFIG_CRYPTO_SM4
|
|
case QCRYPTO_CIPHER_ALG_SM4:
|
|
{
|
|
- QCryptoNettleSm4 *ctx = g_new0(QCryptoNettleSm4, 1);
|
|
+ QCryptoNettleSm4 *ctx;
|
|
+ const QCryptoCipherDriver *drv;
|
|
|
|
switch (mode) {
|
|
case QCRYPTO_CIPHER_MODE_ECB:
|
|
- ctx->base.driver = &qcrypto_nettle_sm4_driver_ecb;
|
|
+ drv = &qcrypto_nettle_sm4_driver_ecb;
|
|
break;
|
|
default:
|
|
goto bad_cipher_mode;
|
|
}
|
|
|
|
+ ctx = g_new0(QCryptoNettleSm4, 1);
|
|
+ ctx->base.driver = drv;
|
|
sm4_set_encrypt_key(&ctx->key[0], key);
|
|
sm4_set_decrypt_key(&ctx->key[1], key);
|
|
|
|
--
|
|
2.41.0.windows.1
|
|
|