Skip to content

Commit

Permalink
app/pdump: abort on multi-core capture limit
Browse files Browse the repository at this point in the history
[ upstream commit 3ee04eb ]

Check lcore id value is not the maximum core supported.
Using lcore id without this check might cause
out of bound access inside the rte_eal_wait_lcore.

Coverity issue: 375841
Fixes: b2854d5 ("app/pdump: support multi-core capture")

Signed-off-by: Reshma Pattan <reshma.pattan@intel.com>
Acked-by: Stephen Hemminger <stephen@networkplumber.org>
  • Loading branch information
reshmapattan authored and bluca committed Mar 9, 2022
1 parent 4297b2d commit 30d6d02
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions app/pdump/main.c
Expand Up @@ -906,11 +906,21 @@ dump_packets_core(void *arg)
return 0;
}

static unsigned int
get_next_core(unsigned int lcore)
{
lcore = rte_get_next_lcore(lcore, 1, 0);
if (lcore == RTE_MAX_LCORE)
rte_exit(EXIT_FAILURE,
"Max core limit %u reached for packet capture", lcore);
return lcore;
}

static inline void
dump_packets(void)
{
int i;
uint32_t lcore_id = 0;
unsigned int lcore_id = 0;

if (!multiple_core_capture) {
printf(" core (%u), capture for (%d) tuples\n",
Expand All @@ -936,12 +946,12 @@ dump_packets(void)
return;
}

lcore_id = rte_get_next_lcore(lcore_id, 1, 0);
lcore_id = get_next_core(lcore_id);

for (i = 0; i < num_tuples; i++) {
rte_eal_remote_launch(dump_packets_core,
&pdump_t[i], lcore_id);
lcore_id = rte_get_next_lcore(lcore_id, 1, 0);
lcore_id = get_next_core(lcore_id);

if (rte_eal_wait_lcore(lcore_id) < 0)
rte_exit(EXIT_FAILURE, "failed to wait\n");
Expand Down

0 comments on commit 30d6d02

Please sign in to comment.