app/test: fix buffer overflow in table unit tests

Message ID 20220421173528.2152008-1-vladimir.medvedkin@intel.com (mailing list archive)
State Accepted, archived
Delegated to: David Marchand
Headers
Series app/test: fix buffer overflow in table unit tests |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK
ci/iol-mellanox-Performance success Performance Testing PASS
ci/intel-Testing success Testing PASS
ci/iol-aarch64-unit-testing success Testing PASS
ci/github-robot: build success github build: passed
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-aarch64-compile-testing success Testing PASS
ci/iol-x86_64-unit-testing success Testing PASS
ci/iol-x86_64-compile-testing success Testing PASS
ci/iol-abi-testing success Testing PASS

Commit Message

Vladimir Medvedkin April 21, 2022, 5:35 p.m. UTC
  This patch fixes stack buffer overflow reported by ASAN.

Bugzilla ID: 820
Fixes: 5205954791cb ("app/test: packet framework unit tests")
Cc: cristian.dumitrescu@intel.com
Cc: stable@dpdk.org

Signed-off-by: Vladimir Medvedkin <vladimir.medvedkin@intel.com>
---
 app/test/test_table_tables.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
  

Comments

Cristian Dumitrescu April 26, 2022, 2:03 p.m. UTC | #1
> -----Original Message-----
> From: Medvedkin, Vladimir <vladimir.medvedkin@intel.com>
> Sent: Thursday, April 21, 2022 6:35 PM
> To: dev@dpdk.org
> Cc: Dumitrescu, Cristian <cristian.dumitrescu@intel.com>; stable@dpdk.org
> Subject: [PATCH] app/test: fix buffer overflow in table unit tests
> 
> This patch fixes stack buffer overflow reported by ASAN.
> 
> Bugzilla ID: 820
> Fixes: 5205954791cb ("app/test: packet framework unit tests")
> Cc: cristian.dumitrescu@intel.com
> Cc: stable@dpdk.org
> 
> Signed-off-by: Vladimir Medvedkin <vladimir.medvedkin@intel.com>
> ---

Acked-by: Cristian Dumitrescu <cristian.dumitrescu@intel.com>
  
David Marchand April 28, 2022, 10:53 a.m. UTC | #2
On Tue, Apr 26, 2022 at 4:04 PM Dumitrescu, Cristian
<cristian.dumitrescu@intel.com> wrote:
> >
> > This patch fixes stack buffer overflow reported by ASAN.
> >
> > Bugzilla ID: 820
> > Fixes: 5205954791cb ("app/test: packet framework unit tests")
> > Cc: stable@dpdk.org
> >
> > Signed-off-by: Vladimir Medvedkin <vladimir.medvedkin@intel.com>
> Acked-by: Cristian Dumitrescu <cristian.dumitrescu@intel.com>

Applied, thanks Vladimir.
  

Patch

diff --git a/app/test/test_table_tables.c b/app/test/test_table_tables.c
index d5c5a426bc..010dd5a794 100644
--- a/app/test/test_table_tables.c
+++ b/app/test/test_table_tables.c
@@ -292,10 +292,10 @@  test_table_lpm(void)
 	struct rte_mbuf *mbufs[RTE_PORT_IN_BURST_SIZE_MAX];
 	void *table;
 	char *entries[RTE_PORT_IN_BURST_SIZE_MAX];
-	char entry;
+	uint64_t entry;
 	void *entry_ptr;
 	int key_found;
-	uint32_t entry_size = 1;
+	uint32_t entry_size = sizeof(entry);
 
 	/* Initialize params and create tables */
 	struct rte_table_lpm_params lpm_params = {
@@ -357,7 +357,7 @@  test_table_lpm(void)
 	struct rte_table_lpm_key lpm_key;
 	lpm_key.ip = 0xadadadad;
 
-	table = rte_table_lpm_ops.f_create(&lpm_params, 0, 1);
+	table = rte_table_lpm_ops.f_create(&lpm_params, 0, entry_size);
 	if (table == NULL)
 		return -9;
 
@@ -458,10 +458,10 @@  test_table_lpm_ipv6(void)
 	struct rte_mbuf *mbufs[RTE_PORT_IN_BURST_SIZE_MAX];
 	void *table;
 	char *entries[RTE_PORT_IN_BURST_SIZE_MAX];
-	char entry;
+	uint64_t entry;
 	void *entry_ptr;
 	int key_found;
-	uint32_t entry_size = 1;
+	uint32_t entry_size = sizeof(entry);
 
 	/* Initialize params and create tables */
 	struct rte_table_lpm_ipv6_params lpm_params = {