From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id BF0B1A0350 for ; Mon, 28 Feb 2022 10:59:05 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 93F2E4068C; Mon, 28 Feb 2022 10:59:05 +0100 (CET) Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by mails.dpdk.org (Postfix) with ESMTP id B14554068C; Mon, 28 Feb 2022 10:59:02 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1646042343; x=1677578343; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=FYxwaCT9SGCkrll1sorzreKuV8rO0hVTgADALebzuwg=; b=KsoHdWlnkI0DUbspMC4rgM55ua0ehd9kJKs4hieejIqrqgY0I4Fh98cu Ze62r51KN4h+5wSev+Hky+NGm0cA8gjSCGdh+MokRGf7zpJvlahAj+DM7 hzZ+qmSChAOwD8uxztnrfwP9iBV/OZSKm29MGF63WOUZl42J8W6kJCaZz gmTky8try4cps33q/nnAlJARaFf2gZBf7BnS8T3U5XgidAAUZryk3Xkbn YQC4VBX4odzB4rPrKobH2rwGeoGxZ5H6wTd/TorvWH3h4TIdIR4o5GDL9 vHqEwryKSp04VM6esstDJ8eE7LC4E3SDGdWBjOfIXHCRdS0RynvRnH/5d Q==; X-IronPort-AV: E=McAfee;i="6200,9189,10271"; a="233468584" X-IronPort-AV: E=Sophos;i="5.90,142,1643702400"; d="scan'208";a="233468584" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Feb 2022 01:59:01 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.90,142,1643702400"; d="scan'208";a="510031777" Received: from silpixa00401214.ir.intel.com ([10.55.129.100]) by orsmga006.jf.intel.com with ESMTP; 28 Feb 2022 01:58:58 -0800 From: Reshma Pattan To: dev@dpdk.org Cc: stephen@networkplumber.org, ferruh.yigit@intel.com, Reshma Pattan , vipin.varghese@intel.com, stable@dpdk.org Subject: [PATCH v4] app/pdump: check lcore is not the maximum core Date: Mon, 28 Feb 2022 09:58:56 +0000 Message-Id: <20220228095856.58563-1-reshma.pattan@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220222110224.56857-1-reshma.pattan@intel.com> References: <20220222110224.56857-1-reshma.pattan@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org 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: b2854d5317e8 ("app/pdump: support multi-core capture") Cc: vipin.varghese@intel.com Cc: stable@dpdk.org Signed-off-by: Reshma Pattan --- v4: Remove inline of new function Change lcore type as unsigned int return lcore from the function --- app/pdump/main.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/app/pdump/main.c b/app/pdump/main.c index 04a38e8911..96fa76f8da 100644 --- a/app/pdump/main.c +++ b/app/pdump/main.c @@ -900,11 +900,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", @@ -930,12 +940,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"); -- 2.25.1