From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <dev-bounces@dpdk.org>
Received: from dpdk.org (dpdk.org [92.243.14.124])
	by inbox.dpdk.org (Postfix) with ESMTP id 16713A0613
	for <public@inbox.dpdk.org>; Thu, 26 Sep 2019 11:47:51 +0200 (CEST)
Received: from [92.243.14.124] (localhost [127.0.0.1])
	by dpdk.org (Postfix) with ESMTP id CD1CF1BF3B;
	Thu, 26 Sep 2019 11:47:49 +0200 (CEST)
Received: from mga11.intel.com (mga11.intel.com [192.55.52.93])
 by dpdk.org (Postfix) with ESMTP id 2DEEC1BF34;
 Thu, 26 Sep 2019 11:47:47 +0200 (CEST)
X-Amp-Result: SKIPPED(no attachment in message)
X-Amp-File-Uploaded: False
Received: from fmsmga007.fm.intel.com ([10.253.24.52])
 by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384;
 26 Sep 2019 02:47:47 -0700
X-ExtLoop1: 1
X-IronPort-AV: E=Sophos;i="5.64,551,1559545200"; d="scan'208";a="189958563"
Received: from kmsmsx156.gar.corp.intel.com ([172.21.138.133])
 by fmsmga007.fm.intel.com with ESMTP; 26 Sep 2019 02:47:46 -0700
Received: from pgsmsx109.gar.corp.intel.com (10.221.44.109) by
 KMSMSX156.gar.corp.intel.com (172.21.138.133) with Microsoft SMTP Server
 (TLS) id 14.3.439.0; Thu, 26 Sep 2019 17:47:45 +0800
Received: from pgsmsx102.gar.corp.intel.com ([169.254.6.203]) by
 PGSMSX109.gar.corp.intel.com ([169.254.14.150]) with mapi id 14.03.0439.000;
 Thu, 26 Sep 2019 17:47:45 +0800
From: "Gujjar, Abhinandan S" <abhinandan.gujjar@intel.com>
To: "Chaitanya Babu, TalluriX" <tallurix.chaitanya.babu@intel.com>,
 "dev@dpdk.org" <dev@dpdk.org>
CC: "Pattan, Reshma" <reshma.pattan@intel.com>, "Parthasarathy, JananeeX M"
 <jananeex.m.parthasarathy@intel.com>, "stable@dpdk.org" <stable@dpdk.org>
Thread-Topic: [PATCH] lib/eventdev: fix null pointer dereferences coverity
 issue
Thread-Index: AQHVb4KNSDkKwGrXLUqy795SBdjFXac76CgAgAFNZACAAIce0A==
Date: Thu, 26 Sep 2019 09:47:44 +0000
Message-ID: <5612CB344B05EE4F95FC5B729939F78079549B20@PGSMSX102.gar.corp.intel.com>
References: <1568963369-6449-1-git-send-email-tallurix.chaitanya.babu@intel.com>
 <5612CB344B05EE4F95FC5B729939F78079549005@PGSMSX102.gar.corp.intel.com>
 <761FB0F2AB727F4FA9CE98D18810B01560F169CA@BGSMSX103.gar.corp.intel.com>
In-Reply-To: <761FB0F2AB727F4FA9CE98D18810B01560F169CA@BGSMSX103.gar.corp.intel.com>
Accept-Language: en-US
Content-Language: en-US
X-MS-Has-Attach: 
X-MS-TNEF-Correlator: 
x-ctpclassification: CTP_NT
x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiMmZhMzg5MTgtZDJhOC00OGEzLWFhOTYtNzNkYzUwYjRkNzMyIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjEwLjE4MDQuNDkiLCJUcnVzdGVkTGFiZWxIYXNoIjoiODc3YlNBekw2eVFPRUNEN3JoZkFnaG94YjFUTHBhVStKU0E1MTd4RWxTc2RpVWlEaE5TOWV3MFp0XC9HZVNZbHEifQ==
dlp-product: dlpe-windows
dlp-version: 11.2.0.6
dlp-reaction: no-action
x-originating-ip: [172.30.20.206]
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: quoted-printable
MIME-Version: 1.0
Subject: Re: [dpdk-dev] [PATCH] lib/eventdev: fix null pointer dereferences
 coverity issue
X-BeenThere: dev@dpdk.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: DPDK patches and discussions <dev.dpdk.org>
List-Unsubscribe: <https://mails.dpdk.org/options/dev>,
 <mailto:dev-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://mails.dpdk.org/archives/dev/>
List-Post: <mailto:dev@dpdk.org>
List-Help: <mailto:dev-request@dpdk.org?subject=help>
List-Subscribe: <https://mails.dpdk.org/listinfo/dev>,
 <mailto:dev-request@dpdk.org?subject=subscribe>
Errors-To: dev-bounces@dpdk.org
Sender: "dev" <dev-bounces@dpdk.org>

Hi Chaitanya,

This patch is not required.
This has to be marked to ignore in coverity.

Regards
Abhinandan

> -----Original Message-----
> From: Chaitanya Babu, TalluriX
> Sent: Thursday, September 26, 2019 3:03 PM
> To: Gujjar, Abhinandan S <abhinandan.gujjar@intel.com>; dev@dpdk.org
> Cc: Pattan, Reshma <reshma.pattan@intel.com>; Parthasarathy, JananeeX M
> <jananeex.m.parthasarathy@intel.com>; stable@dpdk.org
> Subject: RE: [PATCH] lib/eventdev: fix null pointer dereferences coverity=
 issue
>=20
> Hi Abhinandan,
>=20
> >-----Original Message-----
> >From: Gujjar, Abhinandan S
> >Sent: Wednesday, September 25, 2019 11:17 AM
> >To: Chaitanya Babu, TalluriX <tallurix.chaitanya.babu@intel.com>;
> >dev@dpdk.org
> >Cc: Pattan, Reshma <reshma.pattan@intel.com>; Parthasarathy, JananeeX M
> ><jananeex.m.parthasarathy@intel.com>; stable@dpdk.org
> >Subject: RE: [PATCH] lib/eventdev: fix null pointer dereferences
> >coverity issue
> >
> >Please find the comments inline
> >
> >> -----Original Message-----
> >> From: Chaitanya Babu, TalluriX
> >> Sent: Friday, September 20, 2019 12:39 PM
> >> To: dev@dpdk.org
> >> Cc: Pattan, Reshma <reshma.pattan@intel.com>; Parthasarathy, JananeeX
> >> M <jananeex.m.parthasarathy@intel.com>; Gujjar, Abhinandan S
> >> <abhinandan.gujjar@intel.com>; Chaitanya Babu, TalluriX
> >> <tallurix.chaitanya.babu@intel.com>; stable@dpdk.org
> >> Subject: [PATCH] lib/eventdev: fix null pointer dereferences coverity
> >> issue
> >>
> >> One issue caught by Coverity 340075
> >> *deref_ptr: Directly dereferencing pointer qp_info.
> >>
> >> In eca_enq_to_cryptodev() qp_info dereferenced without null check in
> >> both session and sessionless crypto ops.
> >>
> >> The fix is to access qp_info after null check.
> >>
> >> Coverity issue: 340075
> >> Fixes: 7901eac340 ("eventdev: add crypto adapter implementation")
> >> Cc: stable@dpdk.org
> >>
> >> Signed-off-by: Chaitanya Babu Talluri
> >> <tallurix.chaitanya.babu@intel.com>
> >> ---
> >>  lib/librte_eventdev/rte_event_crypto_adapter.c | 4 ++--
> >>  1 file changed, 2 insertions(+), 2 deletions(-)
> >>
> >> diff --git a/lib/librte_eventdev/rte_event_crypto_adapter.c
> >> b/lib/librte_eventdev/rte_event_crypto_adapter.c
> >> index 22d910816..4f3f57348 100644
> >> --- a/lib/librte_eventdev/rte_event_crypto_adapter.c
> >> +++ b/lib/librte_eventdev/rte_event_crypto_adapter.c
> >> @@ -356,7 +356,7 @@ eca_enq_to_cryptodev(struct
> >> rte_event_crypto_adapter *adapter,
> >>  			cdev_id =3D m_data->request_info.cdev_id;
> >>  			qp_id =3D m_data->request_info.queue_pair_id;
> >>  			qp_info =3D &adapter->cdevs[cdev_id].qpairs[qp_id];
> >> -			if (!qp_info->qp_enabled) {
> >> +			if ((qp_info =3D=3D NULL) || (!qp_info->qp_enabled)) {
> >qp_info cannot be null as the memory allocation is done in
> >rte_event_crypto_adapter_queue_pair_add() -> eca_add_queue_pair().
> >Please refer line #736 which is allocating memory for
> >"dev_info->dev->data-
> >>nb_queue_pairs"
> >
> >Without queue_pair_add(), service core cannot be started [Please look
> >at eca_init_service()].
> >This issue can be marked to ignore in klockworks.
> >
>=20
> Yes, we observed that queue pairs are allocated earlier based on device c=
onfig.
> But NULL check is done here just in case if queue pair id "qp_id" is inva=
lid since
> this is fed from request info during enqueue.
>=20
> Please let us know if still this change is not required, we will ignore t=
his patch.
>=20
> >>  				rte_pktmbuf_free(crypto_op->sym->m_src);
> >>  				rte_crypto_op_free(crypto_op);
> >>  				continue;
> >> @@ -372,7 +372,7 @@ eca_enq_to_cryptodev(struct
> >> rte_event_crypto_adapter *adapter,
> >>  			cdev_id =3D m_data->request_info.cdev_id;
> >>  			qp_id =3D m_data->request_info.queue_pair_id;
> >>  			qp_info =3D &adapter->cdevs[cdev_id].qpairs[qp_id];
> >> -			if (!qp_info->qp_enabled) {
> >> +			if ((qp_info =3D=3D NULL) || (!qp_info->qp_enabled)) {
> >>  				rte_pktmbuf_free(crypto_op->sym->m_src);
> >>  				rte_crypto_op_free(crypto_op);
> >>  				continue;
> >> --
> >> 2.17.2