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 62D06A034E; Tue, 22 Feb 2022 12:02:32 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 2BC8E40DF6; Tue, 22 Feb 2022 12:02:32 +0100 (CET) Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by mails.dpdk.org (Postfix) with ESMTP id A73F840DF4; Tue, 22 Feb 2022 12:02:30 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1645527751; x=1677063751; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=83dKtcrKD9jPT08rN9NJn0wCnUhFLwf/Jbssn62QF8E=; b=aKNDjh9BLwNDkwEx+p+R1ZuogIRHrQBZ5IdL4fhYlERAGSffHiTiXete i31WN/5grI1CKjNNBZnC+0RcPwlOc73ieQNktK1d+L6cR34Sux+1PR1jC PWokzMGGXlDOVe2fZC6z2FdYQYAREY/j1DQnLQTb5JJF8NCTYulvXMj4r z7D3EvBub6RPH/rLVCKa2sUdLeQnjJnLX6VYeZoz05xQVQ8XoK/hiuoeT HcQ02jCGi2KGEGqwchw7z3fM0rub+dCvIHkZfXQib9MKD5xF0kLKo1qkv nnu0bvdxrcGBQ5iEeEPnoGRIc+vFyO9cXZc7qTqVp3tpRLYPE6ZoK+LVn w==; X-IronPort-AV: E=McAfee;i="6200,9189,10265"; a="251612691" X-IronPort-AV: E=Sophos;i="5.88,387,1635231600"; d="scan'208";a="251612691" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Feb 2022 03:02:28 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.88,387,1635231600"; d="scan'208";a="532183493" Received: from silpixa00401214.ir.intel.com ([10.55.129.13]) by orsmga007.jf.intel.com with ESMTP; 22 Feb 2022 03:02:26 -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 v3] app/pdump: check lcore is not the maximum core Date: Tue, 22 Feb 2022 11:02:24 +0000 Message-Id: <20220222110224.56857-1-reshma.pattan@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220221101944.4216-1-reshma.pattan@intel.com> References: <20220221101944.4216-1-reshma.pattan@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-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 --- v3: add new function to get next core id and validate it. --- app/pdump/main.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/app/pdump/main.c b/app/pdump/main.c index 04a38e8911..e4e62811c9 100644 --- a/app/pdump/main.c +++ b/app/pdump/main.c @@ -900,6 +900,15 @@ dump_packets_core(void *arg) return 0; } +static inline void +get_next_core(uint32_t *lcore_id) +{ + *lcore_id = rte_get_next_lcore(*lcore_id, 1, 0); + if (*lcore_id == RTE_MAX_LCORE) + rte_exit(EXIT_FAILURE, + "Max core limit %u reached for packet capture", *lcore_id); +} + static inline void dump_packets(void) { @@ -930,12 +939,12 @@ dump_packets(void) return; } - lcore_id = rte_get_next_lcore(lcore_id, 1, 0); + 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); + get_next_core(&lcore_id); if (rte_eal_wait_lcore(lcore_id) < 0) rte_exit(EXIT_FAILURE, "failed to wait\n"); -- 2.25.1