Skip to contentSkip to conversation

table: fix overflow in rte_swx_table_selector_create

PATCH New Bulatov Mark 1 participant 1 message Nov 13

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 table: fix overflow in rte_swx_table_selector_create

table_create_check() checks the bounds of params->n_groups_max and group_size individually. However, this does not guarantee that their product will not cause an overflow.

Fix this by using type casting.

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Fixes f7598a62d1 ("table: support selector table")
---
 lib/table/rte_swx_table_selector.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/table/rte_swx_table_selector.c +1 -1
index d42f67f157..d976904b7d 100644
@@ -289,7 +289,7 @@ rte_swx_table_selector_create(struct rte_swx_table_selector_params *params,
 
 	/* Group. */
 	group_size = params->n_members_per_group_max * sizeof(uint32_t);
-	t->group_table_size = params->n_groups_max * group_size;
+	t->group_table_size = (uint64_t)params->n_groups_max * group_size;
 
 	t->group_table = env_calloc(t->group_table_size, RTE_CACHE_LINE_SIZE, numa_node);
 	if (!t->group_table)
Signature · 1 line
2.39.5