examples/fips_validation: fix checking return value

Message ID 20201028153808.103328-1-ciara.power@intel.com (mailing list archive)
State Superseded, archived
Delegated to: David Marchand
Headers
Series examples/fips_validation: fix checking return value |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-testing success Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/Intel-compilation success Compilation OK
ci/travis-robot success Travis build: passed
ci/iol-mellanox-Performance success Performance Testing PASS

Commit Message

Power, Ciara Oct. 28, 2020, 3:38 p.m. UTC
  The return value was not being checked when calling the
get_writeback_data function in the AES test case. On failure, this led
to a NULL dereference when using memcpy later. The return value is now
checked to avoid this NULL dereference.

Coverity issue: 363463
Fixes: cd255ccf5764 ("examples/fips_validation: support AES parsing")
Cc: marko.kovacevic@intel.com
Cc: roy.fan.zhang@intel.com
Cc: stable@dpdk.org

Signed-off-by: Ciara Power <ciara.power@intel.com>
---
 examples/fips_validation/main.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
  

Comments

David Marchand Oct. 30, 2020, 1:01 p.m. UTC | #1
On Wed, Oct 28, 2020 at 4:38 PM Ciara Power <ciara.power@intel.com> wrote:
>
> The return value was not being checked when calling the
> get_writeback_data function in the AES test case. On failure, this led
> to a NULL dereference when using memcpy later. The return value is now
> checked to avoid this NULL dereference.
>
> Coverity issue: 363463
> Fixes: cd255ccf5764 ("examples/fips_validation: support AES parsing")

I'd rather flag:
Fixes: 952e10cdad5e ("examples/fips_validation: support scatter gather list")

Can you double check?


> Cc: marko.kovacevic@intel.com
> Cc: roy.fan.zhang@intel.com
> Cc: stable@dpdk.org
>
> Signed-off-by: Ciara Power <ciara.power@intel.com>
> ---
>  examples/fips_validation/main.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/examples/fips_validation/main.c b/examples/fips_validation/main.c
> index 07532c9562..bc7abd2b8f 100644
> --- a/examples/fips_validation/main.c
> +++ b/examples/fips_validation/main.c
> @@ -1520,7 +1520,9 @@ fips_mct_aes_test(void)
>                                 return ret;
>                         }
>
> -                       get_writeback_data(&val);
> +                       ret = get_writeback_data(&val);
> +                       if (ret < 0)
> +                               return ret;
>
>                         if (info.op == FIPS_TEST_DEC_AUTH_VERIF)
>                                 memcpy(prev_in, vec.ct.val, AES_BLOCK_SIZE);

And I think we have the same issue in fips_mct_sha_test().
  

Patch

diff --git a/examples/fips_validation/main.c b/examples/fips_validation/main.c
index 07532c9562..bc7abd2b8f 100644
--- a/examples/fips_validation/main.c
+++ b/examples/fips_validation/main.c
@@ -1520,7 +1520,9 @@  fips_mct_aes_test(void)
 				return ret;
 			}
 
-			get_writeback_data(&val);
+			ret = get_writeback_data(&val);
+			if (ret < 0)
+				return ret;
 
 			if (info.op == FIPS_TEST_DEC_AUTH_VERIF)
 				memcpy(prev_in, vec.ct.val, AES_BLOCK_SIZE);