[v3] app: fix buffer overrun

Message ID 20211011080452.2710095-1-przemyslawx.zegan@intel.com (mailing list archive)
State Superseded, archived
Delegated to: akhil goyal
Headers
Series [v3] app: fix buffer overrun |

Checks

Context Check Description
ci/checkpatch warning coding style issues
ci/Intel-compilation warning apply issues
ci/iol-testing warning apply patch failure

Commit Message

Przemyslaw Zegan Oct. 11, 2021, 8:04 a.m. UTC
  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: pablo.de.lara.guarch@intel.com

Signed-off-by: Przemyslaw Zegan <przemyslawx.zegan@intel.com>
---
v3:
- replaced hardcoded values by sizeof(aad)

 app/test-crypto-perf/cperf_test_vectors.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
  

Comments

Fan Zhang Oct. 11, 2021, 10:45 a.m. UTC | #1
> -----Original Message-----
> From: Zegan, PrzemyslawX <przemyslawx.zegan@intel.com>
> Sent: Monday, October 11, 2021 9:05 AM
> To: dev@dpdk.org
> Cc: gakhil@marvell.com; Zhang, Roy Fan <roy.fan.zhang@intel.com>; Zegan,
> PrzemyslawX <przemyslawx.zegan@intel.com>; De Lara Guarch, Pablo
> <pablo.de.lara.guarch@intel.com>
> Subject: [dpdk-dev v3] app: fix buffer overrun
> 
> 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: pablo.de.lara.guarch@intel.com
> 
> Signed-off-by: Przemyslaw Zegan <przemyslawx.zegan@intel.com>
> ---
Acked-by: Fan Zhang <roy.fan.zhang@intel.com>
  

Patch

diff --git a/app/test-crypto-perf/cperf_test_vectors.c b/app/test-crypto-perf/cperf_test_vectors.c
index 2c7e314ec8..271e91c13c 100644
--- a/app/test-crypto-perf/cperf_test_vectors.c
+++ b/app/test-crypto-perf/cperf_test_vectors.c
@@ -555,8 +555,8 @@  cperf_test_vector_get_dummy(struct cperf_options *options)
 				return NULL;
 			}
 
-			if(options->aead_aad_sz > 12)
-				options->aead_aad_sz = 12;
+			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);