[EXT] [PATCH v2] cryptodev: avoid algorithm strings null pointers

Akhil Goyal gakhil at marvell.com
Fri Jun 9 10:06:29 CEST 2023



> -----Original Message-----
> From: liu xixin <liuxixin2020 at outlook.com>
> Sent: Friday, June 9, 2023 12:31 PM
> To: Akhil Goyal <gakhil at marvell.com>; dev at dpdk.org
> Subject: 答复: [EXT] [PATCH v2] cryptodev: avoid algorithm strings null pointers
> 
> > Subject: [EXT] [PATCH v2] cryptodev: avoid algorithm strings null
> > pointers
> >
> > 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.
> 
> I believe this is a fix and you should add fixes tag for this and need to be
> backported.
> 
> >
> > Signed-off-by: xixin.liu <liuxixin2020 at outlook.com>
> 
> Signoff format is not correct.
> Please follow https://urldefense.proofpoint.com/v2/url?u=https-
> 3A__doc.dpdk.org_guides_contributing_patches.html&d=DwIGoQ&c=nKjWec2b
> 6R0mOyPaz7xtfQ&r=DnL7Si2wl_PRwpZ9TWey3eu68gBzn7DkPwuqhd6WNyo&m
> =6mzvm07Go5-
> S_2jVk9KRF1mOl0Juay2Sa2WI2XiNgTbg6ZhMcm75GNceSVhe0Doj&s=tvqhxvElc
> m_8h3e7YIBym6IAHk6BxUAFx2RKmjJ6Ibw&e=
> 
> 
> > ---
> >  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;
> 
> crypto_cipher_algorithm_strings is a fixed size array with all non-NULL known
> values and the for loop is iterating over it. So, this check does not make sense to
> me.
> ----> Not every element of the array is defined, eg. it is NULL that the first
> element [1],  if not check "strcmp(algo_string,
> crypto_cipher_algorithm_strings[i]" will fail

The loop starts from 1 so 0th element = NULL will not matter.
And for all other values it is not null. If something is missing,
then it can be added.
But this check is not needed.


More information about the dev mailing list