test/mempool: Fix illegal pointer access in mempool test

Message ID 20210331210557.4919-1-wenwux.ma@intel.com (mailing list archive)
State Superseded, archived
Delegated to: David Marchand
Headers
Series test/mempool: Fix illegal pointer access in mempool test |

Checks

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

Commit Message

Ma, WenwuX March 31, 2021, 9:05 p.m. UTC
  The value of parameter private_data_size of function
rte_mempool_create() called in test_mempool() should not be 0,
Otherwise, the function rte_pktmbuf_priv_size() called in
rte_pktmbuf_init() will cause heap-buffer-overflow.

Signed-off-by: Wenwu Ma <wenwux.ma@intel.com>
---
 app/test/test_mempool.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
  

Comments

Peng, ZhihongX April 15, 2021, 2:04 a.m. UTC | #1
-----Original Message-----
From: dev <dev-bounces@dpdk.org> On Behalf Of Wenwu Ma
Sent: Thursday, April 1, 2021 5:06 AM
To: olivier.matz@6wind.com; andrew.rybchenko@oktetlabs.ru; dev@dpdk.org
Subject: [dpdk-dev] [PATCH] test/mempool: Fix illegal pointer access in mempool test

The value of parameter private_data_size of function
rte_mempool_create() called in test_mempool() should not be 0, Otherwise, the function rte_pktmbuf_priv_size() called in
rte_pktmbuf_init() will cause heap-buffer-overflow.

Signed-off-by: Wenwu Ma <wenwux.ma@intel.com>
---
 app/test/test_mempool.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/app/test/test_mempool.c b/app/test/test_mempool.c index 084842fda..fc06a9c6f 100644
--- a/app/test/test_mempool.c
+++ b/app/test/test_mempool.c
@@ -543,7 +543,8 @@ test_mempool(void)
 	mp_stack_mempool_iter = rte_mempool_create("test_iter_obj",
 		MEMPOOL_SIZE,
 		MEMPOOL_ELT_SIZE,
-		RTE_MEMPOOL_CACHE_MAX_SIZE, 0,
+		RTE_MEMPOOL_CACHE_MAX_SIZE,
+		sizeof(struct rte_pktmbuf_pool_private),
 		NULL, NULL,
 		my_obj_init, NULL,
 		SOCKET_ID_ANY, 0);
--
2.25.1

Tested-by: Peng Zhihong <zhihongx.peng@intel.com>
  

Patch

diff --git a/app/test/test_mempool.c b/app/test/test_mempool.c
index 084842fda..fc06a9c6f 100644
--- a/app/test/test_mempool.c
+++ b/app/test/test_mempool.c
@@ -543,7 +543,8 @@  test_mempool(void)
 	mp_stack_mempool_iter = rte_mempool_create("test_iter_obj",
 		MEMPOOL_SIZE,
 		MEMPOOL_ELT_SIZE,
-		RTE_MEMPOOL_CACHE_MAX_SIZE, 0,
+		RTE_MEMPOOL_CACHE_MAX_SIZE,
+		sizeof(struct rte_pktmbuf_pool_private),
 		NULL, NULL,
 		my_obj_init, NULL,
 		SOCKET_ID_ANY, 0);