[PATCH 2/3] app/testpmd: fix flex item allocation overlap

Stephen Hemminger stephen at networkplumber.org
Mon Sep 7 20:22:03 CEST 2026


flex_item_init() allocates struct flex_item together with the arrays it
points at, and places the first of them at base_size from the start of
the allocation.  base_size is the size of the embedded flex_conf rather
than the size of the whole struct, so sample_data starts inside struct
flex_item itself.  On x86-64 flex_conf is 112 bytes and struct flex_item
is 128, so sample_data[0] aliases flex_handle and flex_id.

Nothing reads flex_id and flex_handle is assigned after the config has
been consumed, so this is currently harmless, but any new member added
to the struct would be silently overwritten during parsing.

Fixes: 59f3a8acbcdb ("app/testpmd: add flex item commands")
Cc: stable at dpdk.org

Signed-off-by: Stephen Hemminger <stephen at networkplumber.org>
---
 app/test-pmd/cmd_flex_item.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/app/test-pmd/cmd_flex_item.c b/app/test-pmd/cmd_flex_item.c
index e62afe3cb5..f4560d2cec 100644
--- a/app/test-pmd/cmd_flex_item.c
+++ b/app/test-pmd/cmd_flex_item.c
@@ -305,7 +305,7 @@ flex_item_init(void)
 	uint8_t (*pattern)[FLEX_MAX_FLOW_PATTERN_LENGTH];
 	int i;
 
-	base_size = RTE_ALIGN(sizeof(*conf), sizeof(uintptr_t));
+	base_size = RTE_ALIGN(sizeof(*fp), sizeof(uintptr_t));
 	samples_size = RTE_ALIGN(FLEX_ITEM_MAX_SAMPLES_NUM *
 				 sizeof(conf->sample_data[0]),
 				 sizeof(uintptr_t));
-- 
2.53.0



More information about the stable mailing list