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")
Cc: [email protected]
Signed-off-by: Alexey Simakov <[email protected]>
Signed-off-by: Mark Bulatov <[email protected]>
---
lib/table/rte_swx_table_selector.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/table/rte_swx_table_selector.c
b/lib/table/rte_swx_table_selector.c
index d42f67f157..d976904b7d 100644
--- a/lib/table/rte_swx_table_selector.c
+++ b/lib/table/rte_swx_table_selector.c
@@ -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)
--
2.39.5