From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 9DBE8A2F67 for ; Fri, 4 Oct 2019 12:57:24 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 729FC1C20E; Fri, 4 Oct 2019 12:57:24 +0200 (CEST) Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by dpdk.org (Postfix) with ESMTP id 28B751C1F9; Fri, 4 Oct 2019 12:57:20 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 04 Oct 2019 03:57:19 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.67,256,1566889200"; d="scan'208";a="217113881" Received: from irsmsx152.ger.corp.intel.com ([163.33.192.66]) by fmsmga004.fm.intel.com with ESMTP; 04 Oct 2019 03:57:18 -0700 Received: from irsmsx102.ger.corp.intel.com ([169.254.2.160]) by IRSMSX152.ger.corp.intel.com ([169.254.6.150]) with mapi id 14.03.0439.000; Fri, 4 Oct 2019 11:57:17 +0100 From: "Ferriter, Cian" To: Kevin Traynor , "dev@dpdk.org" CC: "stable@dpdk.org" Thread-Topic: [PATCH 1/9] net/pcap: fix argument checks Thread-Index: AQHVeFdEOzydqTS3g0u86TPrygSSGqdKUtgA Date: Fri, 4 Oct 2019 10:57:17 +0000 Message-ID: <579B86492DFB364BBA627A48FB30C90E75DD9ADB@IRSMSX102.ger.corp.intel.com> References: <20191001125315.6191-1-ktraynor@redhat.com> <20191001125315.6191-2-ktraynor@redhat.com> In-Reply-To: <20191001125315.6191-2-ktraynor@redhat.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: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiMjczNWMyOGQtNWM4OS00NGU0LTllMTEtYWY5MjQwZWRmNDNmIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjEwLjE4MDQuNDkiLCJUcnVzdGVkTGFiZWxIYXNoIjoicDM0WllnK1pRNVRTTWR0MFwvZVpOTWdCWEhKY2lSNCt3SVcyak8weWF3S2VYeDZsXC9HelBycGxSZ0p3eXQ0djRsIn0= dlp-product: dlpe-windows dlp-version: 11.2.0.6 dlp-reaction: no-action x-originating-ip: [163.33.239.180] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dpdk-stable] [PATCH 1/9] net/pcap: fix argument checks X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.15 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 Sender: "stable" =20 > -----Original Message----- > From: Kevin Traynor [mailto:ktraynor@redhat.com] > Sent: Tuesday 1 October 2019 13:53 > To: dev@dpdk.org > Cc: Kevin Traynor ; Ferriter, Cian > ; stable@dpdk.org > Subject: [PATCH 1/9] net/pcap: fix argument checks >=20 > Previously rx/tx_queues were passed into eth_from_pcaps_common() as > ptrs and were checked for being NULL. >=20 > In commit da6ba28f0540 ("net/pcap: use a struct to pass user options") th= at > changed to pass in a ptr to a pmd_devargs_all which contains the > rx/tx_queues. >=20 > The parameter checking was not updated as part of that commit and coverit= y > caught that there was still a check if rx/tx_queues were NULL, apparently > after they had been dereferenced. >=20 > Fix that by checking the pmd_devargs_all ptr and removing the NULL checks > on rx/tx_queues. >=20 > 1231 struct pmd_devargs *rx_queues =3D &devargs_all->rx_queues; > 1232 struct pmd_devargs *tx_queues =3D &devargs_all->tx_queues; > 1233 const unsigned int nb_rx_queues =3D rx_queues->num_of_queue; > deref_ptr: Directly dereferencing pointer tx_queues. > 1234 const unsigned int nb_tx_queues =3D tx_queues->num_of_queue; > 1235 unsigned int i; > 1236 > 1237 /* do some parameter checking */ > CID 345004: Dereference before null check (REVERSE_INULL) > [select issue] > 1238 if (rx_queues =3D=3D NULL && nb_rx_queues > 0) > 1239 return -1; > CID 345029 (#1 of 1): Dereference before null check (REVERSE_INULL) > check_after_deref: Null-checking tx_queues suggests that it may be > null, but it has already been dereferenced on all paths leading to > the check. > 1240 if (tx_queues =3D=3D NULL && nb_tx_queues > 0) > 1241 return -1; >=20 > Coverity issue: 345029 > Coverity issue: 345044 > Fixes: da6ba28f0540 ("net/pcap: use a struct to pass user options") > Cc: cian.ferriter@intel.com > Cc: stable@dpdk.org >=20 > Signed-off-by: Kevin Traynor Acked-by: Cian Ferriter > --- > drivers/net/pcap/rte_eth_pcap.c | 19 +++++++++++-------- > 1 file changed, 11 insertions(+), 8 deletions(-) >=20 > diff --git a/drivers/net/pcap/rte_eth_pcap.c > b/drivers/net/pcap/rte_eth_pcap.c index 5489010b6..7cf00306e 100644 > --- a/drivers/net/pcap/rte_eth_pcap.c > +++ b/drivers/net/pcap/rte_eth_pcap.c > @@ -1229,16 +1229,19 @@ eth_from_pcaps_common(struct > rte_vdev_device *vdev, { > struct pmd_process_private *pp; > - struct pmd_devargs *rx_queues =3D &devargs_all->rx_queues; > - struct pmd_devargs *tx_queues =3D &devargs_all->tx_queues; > - const unsigned int nb_rx_queues =3D rx_queues->num_of_queue; > - const unsigned int nb_tx_queues =3D tx_queues->num_of_queue; > + struct pmd_devargs *rx_queues; > + struct pmd_devargs *tx_queues; > + unsigned int nb_rx_queues; > + unsigned int nb_tx_queues; > unsigned int i; >=20 > - /* do some parameter checking */ > - if (rx_queues =3D=3D NULL && nb_rx_queues > 0) > - return -1; > - if (tx_queues =3D=3D NULL && nb_tx_queues > 0) > + if (devargs_all =3D=3D NULL) > return -1; >=20 > + rx_queues =3D &devargs_all->rx_queues; > + tx_queues =3D &devargs_all->tx_queues; > + > + nb_rx_queues =3D rx_queues->num_of_queue; > + nb_tx_queues =3D tx_queues->num_of_queue; > + > if (pmd_init_internals(vdev, nb_rx_queues, nb_tx_queues, > internals, > eth_dev) < 0) > -- > 2.21.0