From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by dpdk.space (Postfix) with ESMTP id D3C95A0096 for ; Mon, 8 Apr 2019 11:25:27 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 811182BCE; Mon, 8 Apr 2019 11:25:27 +0200 (CEST) Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by dpdk.org (Postfix) with ESMTP id F348B2BC9; Mon, 8 Apr 2019 11:25:25 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 08 Apr 2019 02:25:25 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.60,324,1549958400"; d="scan'208";a="133899435" Received: from silpixa00399126.ir.intel.com (HELO silpixa00399126.ger.corp.intel.com) ([10.237.222.236]) by orsmga006.jf.intel.com with ESMTP; 08 Apr 2019 02:25:23 -0700 From: Bruce Richardson To: dev@dpdk.org Cc: Bruce Richardson , stable@dpdk.org, Declan Doherty , Fan Zhang Date: Mon, 8 Apr 2019 10:25:14 +0100 Message-Id: <20190408092514.36330-1-bruce.richardson@intel.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH] app/test-crypto-perf: fix missing bounds check on socket id X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Content-Type: text/plain; charset="UTF-8" Message-ID: <20190408092514.r4iWly6r7PUWAOQWSDwFIES7Uz3PHAfL0yZSpJS12J4@z> The socket_id is used as an array index so should be within the range of zero to max numa nodes. Add a range check to ensure we don't get excessive values. Coverity issue: 336812 Coverity issue: 336829 Fixes: 2c59bd32b70d ("cryptodev: do not create session mempool internally") CC: stable@dpdk.org CC: Declan Doherty CC: Fan Zhang Signed-off-by: Bruce Richardson --- app/test-crypto-perf/main.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/app/test-crypto-perf/main.c b/app/test-crypto-perf/main.c index 175c639fb..4247f6add 100644 --- a/app/test-crypto-perf/main.c +++ b/app/test-crypto-perf/main.c @@ -183,6 +183,11 @@ cperf_initialize_cryptodev(struct cperf_options *opts, uint8_t *enabled_cdevs) struct rte_cryptodev_info cdev_info; uint8_t socket_id = rte_cryptodev_socket_id(cdev_id); + /* range check the socket_id - negative values become big + * positive ones due to use of unsigned value + */ + if (socket_id >= RTE_MAX_NUMA_NODES) + socket_id = 0; rte_cryptodev_info_get(cdev_id, &cdev_info); if (opts->nb_qps > cdev_info.max_nb_queue_pairs) { -- 2.20.1