From: "xixin.liu" <liuxixin2020@outlook.com>
To: dev@dpdk.org
Cc: gakhil@marvell.com, liuxixin2020@outlook.com
Subject: [PATCH v2] cryptodev: avoid algorithm strings null pointers
Date: Thu, 8 Jun 2023 16:03:23 +0800 [thread overview]
Message-ID: <TY3PR01MB11575D0AC8023CEAAE444C877C250A@TY3PR01MB11575.jpnprd01.prod.outlook.com> (raw)
The crypto algorithm strings identifiers that are Continuous may be null,
so there is needed to add null judgment.
When testing with dpdk-test-crypto-perf and passing in the parameter
--auth-algo sm3-hmac, The program caused a segfault due to a null pointer
passed in by strcmp.
Adding this patch can solve the segfault problem.
Signed-off-by: xixin.liu <liuxixin2020@outlook.com>
---
lib/cryptodev/rte_cryptodev.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/lib/cryptodev/rte_cryptodev.c b/lib/cryptodev/rte_cryptodev.c
index a96114b2da..41c23fc596 100644
--- a/lib/cryptodev/rte_cryptodev.c
+++ b/lib/cryptodev/rte_cryptodev.c
@@ -346,6 +346,8 @@ rte_cryptodev_get_cipher_algo_enum(enum rte_crypto_cipher_algorithm *algo_enum,
int ret = -1; /* Invalid string */
for (i = 1; i < RTE_DIM(crypto_cipher_algorithm_strings); i++) {
+ if (crypto_cipher_algorithm_strings[i] == NULL)
+ continue;
if (strcmp(algo_string, crypto_cipher_algorithm_strings[i]) == 0) {
*algo_enum = (enum rte_crypto_cipher_algorithm) i;
ret = 0;
@@ -366,6 +368,8 @@ rte_cryptodev_get_auth_algo_enum(enum rte_crypto_auth_algorithm *algo_enum,
int ret = -1; /* Invalid string */
for (i = 1; i < RTE_DIM(crypto_auth_algorithm_strings); i++) {
+ if (crypto_auth_algorithm_strings[i] == NULL)
+ continue;
if (strcmp(algo_string, crypto_auth_algorithm_strings[i]) == 0) {
*algo_enum = (enum rte_crypto_auth_algorithm) i;
ret = 0;
@@ -386,6 +390,8 @@ rte_cryptodev_get_aead_algo_enum(enum rte_crypto_aead_algorithm *algo_enum,
int ret = -1; /* Invalid string */
for (i = 1; i < RTE_DIM(crypto_aead_algorithm_strings); i++) {
+ if (crypto_aead_algorithm_strings[i] == NULL)
+ continue;
if (strcmp(algo_string, crypto_aead_algorithm_strings[i]) == 0) {
*algo_enum = (enum rte_crypto_aead_algorithm) i;
ret = 0;
@@ -406,6 +412,8 @@ rte_cryptodev_asym_get_xform_enum(enum rte_crypto_asym_xform_type *xform_enum,
int ret = -1; /* Invalid string */
for (i = 1; i < RTE_DIM(crypto_asym_xform_strings); i++) {
+ if (crypto_asym_xform_strings[i] == NULL)
+ continue;
if (strcmp(xform_string,
crypto_asym_xform_strings[i]) == 0) {
*xform_enum = (enum rte_crypto_asym_xform_type) i;
--
2.34.1
next reply other threads:[~2023-06-08 8:29 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-08 8:03 xixin.liu [this message]
2023-06-09 6:46 ` [EXT] " Akhil Goyal
2023-06-09 7:00 ` 答复: " liu xixin
2023-06-09 8:06 ` Akhil Goyal
[not found] ` <TY3PR01MB1157507D3557958548014534EC251A@TY3PR01MB11575.jpnprd01.prod.outlook.com>
2023-06-09 8:30 ` Akhil Goyal
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=TY3PR01MB11575D0AC8023CEAAE444C877C250A@TY3PR01MB11575.jpnprd01.prod.outlook.com \
--to=liuxixin2020@outlook.com \
--cc=dev@dpdk.org \
--cc=gakhil@marvell.com \
/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;
as well as URLs for NNTP newsgroup(s).