patch 'crypto/openssl: fix use-after-free and cleanup' has been queued to stable release 25.11.3
Kevin Traynor
ktraynor at redhat.com
Tue Jul 28 17:56:11 CEST 2026
Hi,
FYI, your patch has been queued to stable release 25.11.3
Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet.
It will be pushed if I get no objections before 08/01/26. So please
shout if anyone has objections.
Also note that after the patch there's a diff of the upstream commit vs the
patch applied to the branch. This will indicate if there was any rebasing
needed to apply to the stable branch. If there were code changes for rebasing
(ie: not only metadata diffs), please double check that the rebase was
correctly done.
Queued patches are on a temporary branch at:
https://github.com/kevintraynor/dpdk-stable
This queued commit can be viewed at:
https://github.com/kevintraynor/dpdk-stable/commit/12ffbdf87cb73112bbdb9eae5ac26fcaecdc1a2f
Thanks.
Kevin
---
>From 12ffbdf87cb73112bbdb9eae5ac26fcaecdc1a2f Mon Sep 17 00:00:00 2001
From: Pratik Senapati <psenapati at marvell.com>
Date: Tue, 9 Jun 2026 11:23:02 +0530
Subject: [PATCH] crypto/openssl: fix use-after-free and cleanup
[ upstream commit 41095454593a1e617a052620a476f3768b36e81a ]
params is freed before it is used by
EVP_PKEY_decapsulate_init()
causing a use-after-free issue.
Pass NULL to EVP_PKEY_decapsulate_init()
instead of params to avoid it.
Add resource cleanup for all error paths in the
ML-KEM decapsulate and encapsulate handlers.
Consolidate cleanup into multiple goto labels;
err_decap, err_pkey, err_params for decap and
err_encap, err_pkey, err_params for encap.
Fixes: 5f761d7b605e ("crypto/openssl: support ML-KEM and ML-DSA")
Signed-off-by: Pratik Senapati <psenapati at marvell.com>
Acked-by: Akhil Goyal <gakhil at marvell.com>
---
.mailmap | 1 +
drivers/crypto/openssl/rte_openssl_pmd.c | 124 +++++++++--------------
2 files changed, 47 insertions(+), 78 deletions(-)
diff --git a/.mailmap b/.mailmap
index 0d5a1f3e41..487d7143b0 100644
--- a/.mailmap
+++ b/.mailmap
@@ -1306,4 +1306,5 @@ Prashant Upadhyaya <prashant.upadhyaya at aricent.com> <praupadhyaya at gmail.com>
Prateek Agarwal <prateekag at cse.iitb.ac.in>
Prathisna Padmasanan <prathisna.padmasanan at intel.com>
+Pratik Senapati <psenapati at marvell.com>
Praveen Kaligineedi <pkaligineedi at google.com>
Praveen Shetty <praveen.shetty at intel.com>
diff --git a/drivers/crypto/openssl/rte_openssl_pmd.c b/drivers/crypto/openssl/rte_openssl_pmd.c
index 4f171f48cc..7464884fb2 100644
--- a/drivers/crypto/openssl/rte_openssl_pmd.c
+++ b/drivers/crypto/openssl/rte_openssl_pmd.c
@@ -3538,33 +3538,22 @@ mlkem_encap_op_evp(struct rte_crypto_op *cop,
}
- if (EVP_PKEY_fromdata_init(pctx) != 1) {
- OSSL_PARAM_free(params);
- cop->status = RTE_CRYPTO_OP_STATUS_ERROR;
- return -1;
- }
+ cop->status = RTE_CRYPTO_OP_STATUS_ERROR;
- if (EVP_PKEY_fromdata(pctx, &pkey, EVP_PKEY_PUBLIC_KEY, params) != 1) {
- OSSL_PARAM_free(params);
- cop->status = RTE_CRYPTO_OP_STATUS_ERROR;
- return -1;
- }
- OSSL_PARAM_free(params);
+ if (EVP_PKEY_fromdata_init(pctx) != 1)
+ goto err_params;
- if (pkey == NULL) {
- cop->status = RTE_CRYPTO_OP_STATUS_ERROR;
- return -1;
- }
+ if (EVP_PKEY_fromdata(pctx, &pkey, EVP_PKEY_PUBLIC_KEY, params) != 1)
+ goto err_params;
+
+ if (pkey == NULL)
+ goto err_params;
cctx = EVP_PKEY_CTX_new_from_pkey(NULL, pkey, NULL);
- if (cctx == NULL) {
- EVP_PKEY_free(pkey);
- cop->status = RTE_CRYPTO_OP_STATUS_ERROR;
- return -1;
- }
+ if (cctx == NULL)
+ goto err_pkey;
- if (EVP_PKEY_encapsulate_init(cctx, NULL) != 1) {
- cop->status = RTE_CRYPTO_OP_STATUS_ERROR;
- return -1;
- }
+
+ if (EVP_PKEY_encapsulate_init(cctx, NULL) != 1)
+ goto err_encap;
if (op->encap.message.length) {
@@ -3575,30 +3564,21 @@ mlkem_encap_op_evp(struct rte_crypto_op *cop,
};
- if (EVP_PKEY_encapsulate_init(cctx, kem_params) != 1) {
- EVP_PKEY_free(pkey);
- cop->status = RTE_CRYPTO_OP_STATUS_ERROR;
- return -1;
- }
+ if (EVP_PKEY_encapsulate_init(cctx, kem_params) != 1)
+ goto err_encap;
}
if (EVP_PKEY_encapsulate(cctx, NULL, &outlen, NULL, &keylen) != 1) {
OPENSSL_LOG(ERR, "Failed to determine output length");
- EVP_PKEY_free(pkey);
- cop->status = RTE_CRYPTO_OP_STATUS_ERROR;
- return -1;
+ goto err_encap;
}
if (outlen > op->encap.cipher.length) {
OPENSSL_LOG(ERR, "Insufficient buffer for cipher text");
- EVP_PKEY_free(pkey);
- cop->status = RTE_CRYPTO_OP_STATUS_ERROR;
- return -1;
+ goto err_encap;
}
if (keylen > op->encap.sk.length) {
OPENSSL_LOG(ERR, "Insufficient buffer for shared key");
- EVP_PKEY_free(pkey);
- cop->status = RTE_CRYPTO_OP_STATUS_ERROR;
- return -1;
+ goto err_encap;
}
@@ -3606,16 +3586,18 @@ mlkem_encap_op_evp(struct rte_crypto_op *cop,
op->encap.sk.data, &keylen) != 1) {
OPENSSL_LOG(ERR, "Failed to encapculate");
- EVP_PKEY_free(pkey);
- cop->status = RTE_CRYPTO_OP_STATUS_ERROR;
- return -1;
+ goto err_encap;
}
op->encap.cipher.length = outlen;
op->encap.sk.length = keylen;
+ ret = 0;
+ cop->status = RTE_CRYPTO_OP_STATUS_SUCCESS;
+err_encap:
EVP_PKEY_CTX_free(cctx);
+err_pkey:
EVP_PKEY_free(pkey);
- ret = 0;
- cop->status = RTE_CRYPTO_OP_STATUS_SUCCESS;
+err_params:
+ OSSL_PARAM_free(params);
return ret;
}
@@ -3665,47 +3647,31 @@ mlkem_decap_op_evp(struct rte_crypto_op *cop,
}
- if (EVP_PKEY_fromdata_init(pctx) != 1) {
- OSSL_PARAM_free(params);
- cop->status = RTE_CRYPTO_OP_STATUS_ERROR;
- return -1;
- }
+ cop->status = RTE_CRYPTO_OP_STATUS_ERROR;
- if (EVP_PKEY_fromdata(pctx, &pkey, EVP_PKEY_PRIVATE_KEY, params) != 1) {
- OSSL_PARAM_free(params);
- cop->status = RTE_CRYPTO_OP_STATUS_ERROR;
- return -1;
- }
- OSSL_PARAM_free(params);
+ if (EVP_PKEY_fromdata_init(pctx) != 1)
+ goto err_params;
- if (pkey == NULL) {
- cop->status = RTE_CRYPTO_OP_STATUS_ERROR;
- return -1;
- }
+ if (EVP_PKEY_fromdata(pctx, &pkey, EVP_PKEY_PRIVATE_KEY, params) != 1)
+ goto err_params;
+
+ if (pkey == NULL)
+ goto err_params;
cctx = EVP_PKEY_CTX_new_from_pkey(NULL, pkey, NULL);
- if (cctx == NULL) {
- EVP_PKEY_free(pkey);
- cop->status = RTE_CRYPTO_OP_STATUS_ERROR;
- return -1;
- }
+ if (cctx == NULL)
+ goto err_pkey;
- if (EVP_PKEY_decapsulate_init(cctx, params) != 1) {
- cop->status = RTE_CRYPTO_OP_STATUS_ERROR;
- return -1;
- }
+ if (EVP_PKEY_decapsulate_init(cctx, NULL) != 1)
+ goto err_decap;
if (EVP_PKEY_decapsulate(cctx, NULL, &keylen,
op->decap.cipher.data, op->decap.cipher.length) != 1) {
OPENSSL_LOG(ERR, "Failed to determine output length");
- EVP_PKEY_free(pkey);
- cop->status = RTE_CRYPTO_OP_STATUS_ERROR;
- return -1;
+ goto err_decap;
}
if (keylen > op->decap.sk.length) {
OPENSSL_LOG(ERR, "Insufficient buffer for shared key");
- EVP_PKEY_free(pkey);
- cop->status = RTE_CRYPTO_OP_STATUS_ERROR;
- return -1;
+ goto err_decap;
}
@@ -3713,15 +3679,17 @@ mlkem_decap_op_evp(struct rte_crypto_op *cop,
op->decap.cipher.data, op->decap.cipher.length) != 1) {
OPENSSL_LOG(ERR, "Failed to decapsulate");
- EVP_PKEY_free(pkey);
- cop->status = RTE_CRYPTO_OP_STATUS_ERROR;
- return -1;
+ goto err_decap;
}
op->decap.sk.length = keylen;
+ ret = 0;
+ cop->status = RTE_CRYPTO_OP_STATUS_SUCCESS;
+err_decap:
EVP_PKEY_CTX_free(cctx);
+err_pkey:
EVP_PKEY_free(pkey);
- ret = 0;
- cop->status = RTE_CRYPTO_OP_STATUS_SUCCESS;
+err_params:
+ OSSL_PARAM_free(params);
return ret;
}
--
2.55.0
---
Diff of the applied patch vs upstream commit (please double-check if non-empty:
---
--- - 2026-07-28 16:54:52.002956590 +0100
+++ 0041-crypto-openssl-fix-use-after-free-and-cleanup.patch 2026-07-28 16:54:50.779728575 +0100
@@ -1 +1 @@
-From 41095454593a1e617a052620a476f3768b36e81a Mon Sep 17 00:00:00 2001
+From 12ffbdf87cb73112bbdb9eae5ac26fcaecdc1a2f Mon Sep 17 00:00:00 2001
@@ -5,0 +6,2 @@
+[ upstream commit 41095454593a1e617a052620a476f3768b36e81a ]
+
@@ -21 +22,0 @@
-Cc: stable at dpdk.org
@@ -31 +32 @@
-index 4001e5fb0e..8e1153ce58 100644
+index 0d5a1f3e41..487d7143b0 100644
@@ -34 +35 @@
-@@ -1315,4 +1315,5 @@ Prashant Upadhyaya <prashant.upadhyaya at aricent.com> <praupadhyaya at gmail.com>
+@@ -1306,4 +1306,5 @@ Prashant Upadhyaya <prashant.upadhyaya at aricent.com> <praupadhyaya at gmail.com>
@@ -41 +42 @@
-index 8748ef6195..2319c7cfa9 100644
+index 4f171f48cc..7464884fb2 100644
@@ -44 +45 @@
-@@ -3024,33 +3024,22 @@ mlkem_encap_op_evp(struct rte_crypto_op *cop,
+@@ -3538,33 +3538,22 @@ mlkem_encap_op_evp(struct rte_crypto_op *cop,
@@ -91 +92 @@
-@@ -3061,30 +3050,21 @@ mlkem_encap_op_evp(struct rte_crypto_op *cop,
+@@ -3575,30 +3564,21 @@ mlkem_encap_op_evp(struct rte_crypto_op *cop,
@@ -127 +128 @@
-@@ -3092,16 +3072,18 @@ mlkem_encap_op_evp(struct rte_crypto_op *cop,
+@@ -3606,16 +3586,18 @@ mlkem_encap_op_evp(struct rte_crypto_op *cop,
@@ -151 +152 @@
-@@ -3151,47 +3133,31 @@ mlkem_decap_op_evp(struct rte_crypto_op *cop,
+@@ -3665,47 +3647,31 @@ mlkem_decap_op_evp(struct rte_crypto_op *cop,
@@ -213 +214 @@
-@@ -3199,15 +3165,17 @@ mlkem_decap_op_evp(struct rte_crypto_op *cop,
+@@ -3713,15 +3679,17 @@ mlkem_decap_op_evp(struct rte_crypto_op *cop,
More information about the stable
mailing list