From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by dpdk.org (Postfix) with ESMTP id AF0B2A3 for ; Thu, 21 Feb 2019 18:03:10 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 21 Feb 2019 09:03:09 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.58,396,1544515200"; d="scan'208";a="145421913" Received: from irsmsx107.ger.corp.intel.com ([163.33.3.99]) by fmsmga002.fm.intel.com with ESMTP; 21 Feb 2019 09:03:08 -0800 Received: from irsmsx101.ger.corp.intel.com ([169.254.1.185]) by IRSMSX107.ger.corp.intel.com ([169.254.10.229]) with mapi id 14.03.0415.000; Thu, 21 Feb 2019 17:03:07 +0000 From: "Trahe, Fiona" To: Anoob Joseph , Akhil Goyal , "Doherty, Declan" , "De Lara Guarch, Pablo" CC: Jerin Jacob Kollanukkaran , "Narayana Prasad Raju Athreya" , "dev@dpdk.org" , Ankur Dwivedi , "Trahe, Fiona" Thread-Topic: [PATCH] lib/cryptodev: fix driver name comparison Thread-Index: AQHUvHxsntNewzBh2Ey4taeN+7Qt9aXo7DZAgAGkSYA= Date: Thu, 21 Feb 2019 17:03:06 +0000 Message-ID: <348A99DA5F5B7549AA880327E580B435896F431A@IRSMSX101.ger.corp.intel.com> References: <1549279528-10397-1-git-send-email-anoobj@marvell.com> In-Reply-To: Accept-Language: en-IE, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiYWRhZDc2OGQtMGM2Ni00MjYxLTg3MjktMjI4ZDVjY2RiOTY1IiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjEwLjE4MDQuNDkiLCJUcnVzdGVkTGFiZWxIYXNoIjoiWVVYeEpzbDFoR0NHVmhVSEFNRG8yN3IyRmxhTHFFeXV0SXFqWkNLNFZPd01Kdk1lS1Q1aHJ1eldWSG9EVmFMMiJ9 x-ctpclassification: CTP_NT dlp-product: dlpe-windows dlp-version: 11.0.400.15 dlp-reaction: no-action x-originating-ip: [163.33.239.182] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dpdk-dev] [PATCH] lib/cryptodev: fix driver name comparison 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: , X-List-Received-Date: Thu, 21 Feb 2019 17:03:11 -0000 > -----Original Message----- > From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Anoob Joseph > Sent: Wednesday, February 20, 2019 3:42 PM > To: Akhil Goyal ; Doherty, Declan ; De Lara Guarch, > Pablo > Cc: Jerin Jacob Kollanukkaran ; Narayana Prasad Raju = Athreya > ; dev@dpdk.org; Ankur Dwivedi > Subject: Re: [dpdk-dev] [PATCH] lib/cryptodev: fix driver name comparison >=20 > Hi Akhil, Declan, Pablo, >=20 > Can you review this patch and share your thoughts? >=20 > Thanks, > Anoob >=20 > > -----Original Message----- > > From: Anoob Joseph > > Sent: Monday, February 4, 2019 4:56 PM > > To: Akhil Goyal ; Declan Doherty > > ; Pablo de Lara > > Cc: Anoob Joseph ; Jerin Jacob Kollanukkaran > > ; Narayana Prasad Raju Athreya > > ; dev@dpdk.org; Ankur Dwivedi > > > > Subject: [PATCH] lib/cryptodev: fix driver name comparison > > > > The string compare to the length of driver name might give false positi= ves when > > there are drivers with similar names (one being the subset of another). > > > > Following is such a naming which could result in false positive. > > 1. crypto_driver > > 2. crypto_driver1 [Fiona] This patch changes compare for both driver and device names.=20 Update description to mention device names too. > > When strncmp with len =3D strlen("crypto_driver") is done, it could giv= e a false > > positive when compared against "crypto_driver1". > > > > Fixes: d11b0f30df88 ("cryptodev: introduce API and framework for crypto > > devices") > > > > Signed-off-by: Ankur Dwivedi > > Signed-off-by: Anoob Joseph > > --- > > lib/librte_cryptodev/rte_cryptodev.c | 11 ++++++----- > > 1 file changed, 6 insertions(+), 5 deletions(-) > > > > diff --git a/lib/librte_cryptodev/rte_cryptodev.c > > b/lib/librte_cryptodev/rte_cryptodev.c > > index 7009735..b743c60 100644 > > --- a/lib/librte_cryptodev/rte_cryptodev.c > > +++ b/lib/librte_cryptodev/rte_cryptodev.c > > @@ -510,7 +510,8 @@ rte_cryptodev_pmd_get_named_dev(const char *name) > > dev =3D &cryptodev_globals.devs[i]; > > > > if ((dev->attached =3D=3D RTE_CRYPTODEV_ATTACHED) && > > - (strcmp(dev->data->name, name) =3D=3D 0)) > > + (strncmp(dev->data->name, name, > > + RTE_CRYPTODEV_NAME_MAX_LEN) > > =3D=3D 0)) > > return dev; > > } > > > > @@ -542,8 +543,8 @@ rte_cryptodev_get_dev_id(const char *name) > > return -1; > > > > for (i =3D 0; i < cryptodev_globals.nb_devs; i++) > > - if ((strcmp(cryptodev_globals.devs[i].data->name, name) > > - =3D=3D 0) && > > + if ((strncmp(cryptodev_globals.devs[i].data->name, name, > > + RTE_CRYPTODEV_NAME_MAX_LEN) =3D=3D 0) && [Fiona] Is this safe? The const passed to this may not be the full length o= f RTE_CRYPTODEV_NAME_MAX_LEN. Does this prototype need to specify that a fu= ll length const filled with trailing zeros must be passed in? And if so is = this an ABI breakage? > > (cryptodev_globals.devs[i].attached =3D=3D > > RTE_CRYPTODEV_ATTACHED)) > > return i; > > @@ -586,7 +587,7 @@ rte_cryptodev_devices_get(const char *driver_name, > > uint8_t *devices, > > > > cmp =3D strncmp(devs[i].device->driver->name, > > driver_name, > > - strlen(driver_name)); > > + RTE_CRYPTODEV_NAME_MAX_LEN); [Fiona] Is this safe? Same comment as for device name. Also assumes RTE_CRYPTODEV_NAME_MAX_LEN is same as RTE_DEV_NAME_MAX_LEN. Th= ey're both 64 at the moment so not currently an issue. > > > > if (cmp =3D=3D 0) > > devices[count++] =3D devs[i].data->dev_id; @@ - > > 1691,7 +1692,7 @@ rte_cryptodev_driver_id_get(const char *name) > > > > TAILQ_FOREACH(driver, &cryptodev_driver_list, next) { > > driver_name =3D driver->driver->name; > > - if (strncmp(driver_name, name, strlen(driver_name)) =3D=3D 0) > > + if (strncmp(driver_name, name, > > RTE_CRYPTODEV_NAME_MAX_LEN) =3D=3D 0) > > return driver->id; > > } > > return -1; > > -- > > 2.7.4