crypto/qat: fix EC session segfault on missing pkey/pub key
PATCH 1/1 crypto/qat: fix EC session segfault on missing pkey/pub key
session_set_ec() checked qat_session->xform.ec.pkey.length for the NULL-allocation guards, but that field is zero (from the preceding memset) at that point, so the guards never fired. When test_ecpm() created a session the xform had no pkey or public-key fields set (ECPM only needs curve_id), so the unchecked memcpy calls received a NULL destination and a garbage-length source, causing a segfault.
Fix session_set_ec() to check xform->ec.*.length, the caller- supplied value, before allocating and copying each optional field (pkey, q.x, q.y), skipping the allocation entirely when the length is zero.
Fix test_ecpm() to zero-initialise the xform with memset so that uninitialised pkey/q fields are never passed to the driver.
Also add a QAT_LOG(ERR) in pick_curve() default case so that unsupported curve IDs are surfaced immediately rather than producing the misleading 'Unsupported xform type' message from qat_asym_session_configure().
--- app/test/test_cryptodev_asym.c | 2 +- drivers/crypto/qat/qat_asym.c | 58 ++++++++++++++++++---------------- drivers/crypto/qat/qat_ec.h | 1 + 3 files changed, 32 insertions(+), 29 deletions(-)
app/test/test_cryptodev_asym.c +1 -1
@@ -1816,7 +1816,7 @@ test_ecpm(enum curve curve_id) asym_op = op->asym;/* Setup asym xform */ - xform.next =NULL ; +memset (&xform,0 ,sizeof (xform)); xform.xform_type =RTE_CRYPTO_ASYM_XFORM_ECPM ; xform.ec.curve_id = input_params.curve;
drivers/crypto/qat/qat_asym.c +30 -28
66 lines not on this page · raw message
drivers/crypto/qat/qat_ec.h +1 -0
@@ -274,6 +274,7 @@ pick_curve(const struct rte_crypto_asym_xform *xform)case RTE_CRYPTO_EC_GROUP_SECP521R1 :return SECP521R1 ;default : +QAT_LOG (ERR ,"Unsupported curve id %d" , xform->ec.curve_id);return -1 ; } }
Signature · 1 line
2.43.0
Best Regards
Yu Jiang
Quoted 32 lines
-----Original Message-----
From: Kai Ji <[email protected]>
Sent: Wednesday, March 25, 2026 11:51 PM
To: [email protected]
Cc: [email protected]; [email protected]; Ji, Kai <[email protected]>; [email protected]
Subject: [dpdk-dev v1]crypto/qat: fix EC session segfault on missing pkey/pub key
session_set_ec()checkedqat_session->xform.ec.pkey.lengthfor the NULL- allocation guards, but that field is zero (from the preceding memset) at that point, so the guards never fired.
Whentest_ecpm()created a session the xform had no pkey or public-key fields set (ECPM only needscurve_id), so the unchecked memcpy calls received a NULL destination and a garbage-length source, causing a segfault.Fix
session_set_ec()to check xform->ec.*.length, the caller- supplied value, before allocating and copying each optional field (pkey, q.x, q.y), skipping the allocation entirely when the length is zero.Fix
test_ecpm()to zero-initialise the xform with memset so that uninitialised pkey/q fields are never passed to the driver.Also add a
QAT_LOG(ERR)inpick_curve()default case so that unsupported curve IDs are surfaced immediately rather than producing the misleading 'Unsupported xform type' message fromqat_asym_session_configure().Fixes 064ef1b098d1 (\"test/crypto: remove PMD-specific asym test suites\")Signed-off-by Kai Ji <[email protected]>---