From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by dpdk.org (Postfix) with ESMTP id 8800C235 for ; Wed, 20 Feb 2019 16:41:42 +0100 (CET) Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x1KFYpkd014927; Wed, 20 Feb 2019 07:41:41 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : references : in-reply-to : content-type : content-transfer-encoding : mime-version; s=pfpt0818; bh=6djFk/PWZrd8GJnFKP17zEmvwr/KcZ9I8nd65TCR2HM=; b=vN5c/p5n9gHGnvQhF2nHHJ0UCGCsZJjmV3HEzqxyZKox445DqTO6kDeFmso5w0+PPIqK HmpueZQYbuWG0KWTTdkFyRmqXnNCtKVG0ut+dvgSKNXY77ipNTAQcZIMF0TeHttBhp++ UPQ7OnT3xHJsS2uLK7+SyQOm7LR0jeQJBYcgx/OKxP3AH/eeGxSK6h2MMPHr2UtZ+HSz eB9w+CnM0Bz70ijUVepc5+rl4/QsCMdaN25/eLJ33bl7djCa9BG47ZQNN0WJbf6sXWrF hWdapNb501BQwnxPrCBGYxp5M+fkvLNq+SMA7d+GRI5GsRDoHRF3RVX9gtBKHUChhJyC Dw== Received: from sc-exch02.marvell.com ([199.233.58.182]) by mx0b-0016f401.pphosted.com with ESMTP id 2qs7wqge9u-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Wed, 20 Feb 2019 07:41:41 -0800 Received: from SC-EXCH03.marvell.com (10.93.176.83) by SC-EXCH02.marvell.com (10.93.176.82) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Wed, 20 Feb 2019 07:41:39 -0800 Received: from NAM05-CO1-obe.outbound.protection.outlook.com (104.47.48.52) by SC-EXCH03.marvell.com (10.93.176.83) with Microsoft SMTP Server (TLS) id 15.0.1367.3 via Frontend Transport; Wed, 20 Feb 2019 07:41:39 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.onmicrosoft.com; s=selector1-marvell-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=6djFk/PWZrd8GJnFKP17zEmvwr/KcZ9I8nd65TCR2HM=; b=S5/RJVK0L/5qIjfjsRD21Rotw+REucRQyO5cgmRZYi0QxCU3b2XEyChIDaMCoaadQPhSc75bsGtNSn+wBqqMxXqbcTSuovV48pjn5gr/H14CzxCxVM1QMWpuhGDZ1+9+hRt6KUgm07BVwOLZt6qCAkKkVN0ZDB2QRLZEkhuNIXo= Received: from MN2PR18MB2877.namprd18.prod.outlook.com (20.179.20.218) by MN2PR18MB2655.namprd18.prod.outlook.com (20.179.84.146) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1622.19; Wed, 20 Feb 2019 15:41:37 +0000 Received: from MN2PR18MB2877.namprd18.prod.outlook.com ([fe80::1905:8cf6:f4a1:5d9a]) by MN2PR18MB2877.namprd18.prod.outlook.com ([fe80::1905:8cf6:f4a1:5d9a%4]) with mapi id 15.20.1643.014; Wed, 20 Feb 2019 15:41:37 +0000 From: Anoob Joseph To: Akhil Goyal , Declan Doherty , Pablo de Lara CC: Jerin Jacob Kollanukkaran , "Narayana Prasad Raju Athreya" , "dev@dpdk.org" , Ankur Dwivedi Thread-Topic: [PATCH] lib/cryptodev: fix driver name comparison Thread-Index: AQHUvHxsntNewzBh2Ey4taeN+7Qt9aXo7DZA Date: Wed, 20 Feb 2019 15:41:36 +0000 Message-ID: References: <1549279528-10397-1-git-send-email-anoobj@marvell.com> In-Reply-To: <1549279528-10397-1-git-send-email-anoobj@marvell.com> Accept-Language: en-IN, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [223.230.116.154] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 0b9059da-b591-4644-7e27-08d69749e633 x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(5600110)(711020)(4605104)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7153060)(7193020); SRVR:MN2PR18MB2655; x-ms-traffictypediagnostic: MN2PR18MB2655: x-microsoft-exchange-diagnostics: 1; MN2PR18MB2655; 20:qj5WJZ3DBUoFG3K/1yhZEtsnFbze0iogtVYG5wiwdk/wHMZ18aroRfVdauD93fxA1z1YEHc1YSidoofUN9JsJaXIPF8R4BpGBDxVYEwbkZEnQlII756Wd1XXccelYYAV/CeqnuventHMtzDc4dvEvtwPVA1OGWaQ2nES/JtpVGs= x-microsoft-antispam-prvs: x-forefront-prvs: 0954EE4910 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(346002)(136003)(376002)(39860400002)(366004)(396003)(199004)(13464003)(189003)(26005)(66066001)(55016002)(6116002)(97736004)(3846002)(446003)(54906003)(478600001)(33656002)(68736007)(316002)(6436002)(110136005)(9686003)(71190400001)(71200400001)(11346002)(476003)(8936002)(105586002)(99286004)(76176011)(7696005)(14454004)(305945005)(53936002)(5024004)(6506007)(81166006)(8676002)(486006)(5660300002)(2906002)(107886003)(81156014)(6246003)(25786009)(53546011)(74316002)(102836004)(256004)(106356001)(186003)(229853002)(86362001)(7736002)(4326008); DIR:OUT; SFP:1101; SCL:1; SRVR:MN2PR18MB2655; H:MN2PR18MB2877.namprd18.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; received-spf: None (protection.outlook.com: marvell.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: rKc9pz/m+SRvAEPDlf1RpK/S1IoqTPAZ2D3lXIJnQJwdqxEJFveEE2yLoVAOu8Oi91XrYLGdF9i2vAX2p2C+nMnUw4rjZgdJnghG9tsK/yJu2ualCmBqCLxJYmHhJ8+iKNtukiVkvUlG3S3pbGBMRMx/lf+pLHFytoSwTbPhJC1GUoYlZBw/4Yo7JRMxJJCHoylPIG5DuXvaiK9HoN9rdrNxWgFnHv+DcJRcvofDzPZGO6yVJO8I5qJRZJa5e9zIsVO5A3ef5f9YtIesRRZPdSeLcS77xwI0953eHRhNPQddeXzsVdsBRFg2/0ar5CmT1ag3wWxoSeVFP0cR2dyn1a5BQF4EG9BbLNjYCIIIBug/gxJxpOvWZT4dVw+IVn2jAsA8KXoJhHcAt7rewAo/ufFg02MC2tP+Hp137ARTfWc= Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-MS-Exchange-CrossTenant-Network-Message-Id: 0b9059da-b591-4644-7e27-08d69749e633 X-MS-Exchange-CrossTenant-originalarrivaltime: 20 Feb 2019 15:41:36.8713 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 70e1fb47-1155-421d-87fc-2e58f638b6e0 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR18MB2655 X-OriginatorOrg: marvell.com X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2019-02-20_13:, , signatures=0 X-Proofpoint-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1902200112 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: Wed, 20 Feb 2019 15:41:42 -0000 Hi Akhil, Declan, Pablo, Can you review this patch and share your thoughts? Thanks, Anoob > -----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 >=20 > The string compare to the length of driver name might give false positive= s when > there are drivers with similar names (one being the subset of another). >=20 > Following is such a naming which could result in false positive. > 1. crypto_driver > 2. crypto_driver1 >=20 > When strncmp with len =3D strlen("crypto_driver") is done, it could give = a false > positive when compared against "crypto_driver1". >=20 > Fixes: d11b0f30df88 ("cryptodev: introduce API and framework for crypto > devices") >=20 > Signed-off-by: Ankur Dwivedi > Signed-off-by: Anoob Joseph > --- > lib/librte_cryptodev/rte_cryptodev.c | 11 ++++++----- > 1 file changed, 6 insertions(+), 5 deletions(-) >=20 > 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]; >=20 > 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; > } >=20 > @@ -542,8 +543,8 @@ rte_cryptodev_get_dev_id(const char *name) > return -1; >=20 > 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) && > (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, >=20 > cmp =3D strncmp(devs[i].device->driver->name, > driver_name, > - strlen(driver_name)); > + RTE_CRYPTODEV_NAME_MAX_LEN); >=20 > 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) >=20 > 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