From: Kai Ji <kai.ji@intel.com>
To: dev@dpdk.org
Cc: gakhil@marvell.com, Kai Ji <kai.ji@intel.com>, stable@dpdk.org
Subject: [dpdk-dev v1] crypto/openssl: fix SM2 pubkey buffer overflow in session setup
Date: Wed, 25 Mar 2026 16:27:08 +0000 [thread overview]
Message-ID: <20260325162708.2931082-1-kai.ji@intel.com> (raw)
The SM2 session setup path in openssl_set_asym_session_parameters()
copies the caller-supplied public key coordinates into a fixed 65-byte
stack buffer (1 byte uncompressed-point prefix + 32 bytes X + 32 bytes
Y) without first validating that the coordinate lengths fit.
Since xform->ec.q.x.length and xform->ec.q.y.length are generic size_t
values from the caller and are not bounds-checked before this point in
the driver, an oversized coordinate pair would overflow the pubkey[]
stack buffer before any OpenSSL API is reached.
Add a guard that rejects the xform when
1 + x.length + y.length > sizeof(pubkey), failing the session create
with the existing err_sm2 error path.
Fixes: b2fc11b6f8f1 ("crypto/openssl: support SM2 algorithm")
Cc: stable@dpdk.org
Signed-off-by: Kai Ji <kai.ji@intel.com>
---
drivers/crypto/openssl/rte_openssl_pmd_ops.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/drivers/crypto/openssl/rte_openssl_pmd_ops.c b/drivers/crypto/openssl/rte_openssl_pmd_ops.c
index 6133622f1b..4e5fb07bb2 100644
--- a/drivers/crypto/openssl/rte_openssl_pmd_ops.c
+++ b/drivers/crypto/openssl/rte_openssl_pmd_ops.c
@@ -1773,6 +1773,12 @@ static int openssl_set_asym_session_parameters(
goto err_sm2;
}
+ if (xform->ec.q.x.length >= sizeof(pubkey) ||
+ xform->ec.q.y.length >=
+ sizeof(pubkey) - xform->ec.q.x.length) {
+ OPENSSL_LOG(ERR, "SM2 public key coordinates too large");
+ goto err_sm2;
+ }
memset(pubkey, 0, sizeof(pubkey));
pubkey[0] = 0x04;
len += 1;
--
2.43.0
reply other threads:[~2026-03-25 16:27 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260325162708.2931082-1-kai.ji@intel.com \
--to=kai.ji@intel.com \
--cc=dev@dpdk.org \
--cc=gakhil@marvell.com \
--cc=stable@dpdk.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox