app/crypto-perf: fix AAD template copy overrun
authorPrzemyslaw Zegan <przemyslawx.zegan@intel.com>
Tue, 12 Oct 2021 12:56:11 +0000 (12:56 +0000)
committerAkhil Goyal <gakhil@marvell.com>
Sat, 16 Oct 2021 13:45:02 +0000 (15:45 +0200)
This patch fixes a possible buffer overrun problem in crypto perf test.
Previously when user configured AAD size is over 12 bytes the copy
of template AAD will cause a buffer overrun.
The problem is fixed by only copy up to 12 bytes of AAD template.

Fixes: 8a5b494a7f99 ("app/test-crypto-perf: add AEAD parameters")
Cc: stable@dpdk.org
Signed-off-by: Przemyslaw Zegan <przemyslawx.zegan@intel.com>
Acked-by: Fan Zhang <roy.fan.zhang@intel.com>
app/test-crypto-perf/cperf_test_vectors.c

index 4bba405..7da1a8f 100644 (file)
@@ -590,6 +590,10 @@ cperf_test_vector_get_dummy(struct cperf_options *options)
                                rte_free(t_vec);
                                return NULL;
                        }
+
+                       if (options->aead_aad_sz > sizeof(aad))
+                               options->aead_aad_sz = sizeof(aad);
+
                        memcpy(t_vec->aad.data, aad, options->aead_aad_sz);
                        t_vec->aad.phys_addr = rte_malloc_virt2iova(t_vec->aad.data);
                        t_vec->aad.length = options->aead_aad_sz;