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 A7959375B for ; Mon, 11 Mar 2019 06:55:53 +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 x2B5tc0p027858; Sun, 10 Mar 2019 22:55:53 -0700 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=4nKW9g7HuhvQaRrs1mR/j6CECSE05VZiolWToE1F8Jo=; b=N33HnBZYkkgVkf4/0nYSZn2OOWoic4F3M40H0VizIC2Tx62P1jwkLyuz9+C8rWgk+DH8 FE24YCgxW5r/xrb1sgtN46USDi/XHLLuJg7Gus9pDQoaWF4z6DfhKd6rqOsBKIuWV99s BrinF3jwoAEpCttKl6MS5dvPZ4ZFdP4SieX6xlqytqiN/0xA0Dr6gdyale5q5E3P4z+1 CVqlO/IoBvOFPXbPYBZ+BAQ4PY78Nh4iaVgJmaG95ZeL3c1Z1k+z/pa6hpSaeIHNxzqc 4b1oDZ3cKZu38AhShQJ8ybkhG5+TK8XJlDsp0bCaLbqJEVDJZp/qyjVI5RNeZx2FSn1M sw== Received: from sc-exch01.marvell.com ([199.233.58.181]) by mx0b-0016f401.pphosted.com with ESMTP id 2r4dvrcq6t-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Sun, 10 Mar 2019 22:55:53 -0700 Received: from SC-EXCH04.marvell.com (10.93.176.84) by SC-EXCH01.marvell.com (10.93.176.81) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Sun, 10 Mar 2019 22:55:45 -0700 Received: from NAM01-BN3-obe.outbound.protection.outlook.com (104.47.33.57) by SC-EXCH04.marvell.com (10.93.176.84) with Microsoft SMTP Server (TLS) id 15.0.1367.3 via Frontend Transport; Sun, 10 Mar 2019 22:55:45 -0700 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=4nKW9g7HuhvQaRrs1mR/j6CECSE05VZiolWToE1F8Jo=; b=GuWs/YzLdksebj8HJ0FVzazVUv+ZdKuTkga0aMFepDKUN+cL95g/PCT774H+N4cEEE2yw7pupiXI20CX8D0jeUNmes3p3xJeWYrVz9uQRw8PMk5RlEgZ/mmQLzCYK1GO+r4Mdg8k5GQkO2RMyd0fWDBczGaw/Z6NkKWNW6QxR40= Received: from MN2PR18MB2877.namprd18.prod.outlook.com (20.179.20.218) by MN2PR18MB2672.namprd18.prod.outlook.com (20.179.84.74) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1686.18; Mon, 11 Mar 2019 05:55:44 +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.1686.021; Mon, 11 Mar 2019 05:55:44 +0000 From: Anoob Joseph To: Akhil Goyal , Declan Doherty , Pablo de Lara CC: Anoob Joseph , Ankur Dwivedi , Jerin Jacob Kollanukkaran , Narayana Prasad Raju Athreya , Suheil Chandran , "dev@dpdk.org" Thread-Topic: [PATCH v2] lib/cryptodev: fix driver name comparison Thread-Index: AQHU188QzNfa5uFkwUeHDLSJ/oWkIg== Date: Mon, 11 Mar 2019 05:55:44 +0000 Message-ID: <1552283715-18723-1-git-send-email-anoobj@marvell.com> 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-clientproxiedby: BMXPR01CA0014.INDPRD01.PROD.OUTLOOK.COM (2603:1096:b00:d::24) To MN2PR18MB2877.namprd18.prod.outlook.com (2603:10b6:208:3b::26) x-ms-exchange-messagesentrepresentingtype: 1 x-mailer: git-send-email 2.7.4 x-originating-ip: [115.113.156.2] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 348e956b-e921-404c-3a24-08d6a5e63312 x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(7168020)(4627221)(201703031133081)(201702281549075)(8990200)(5600127)(711020)(4605104)(2017052603328)(7153060)(7193020); SRVR:MN2PR18MB2672; x-ms-traffictypediagnostic: MN2PR18MB2672: x-microsoft-exchange-diagnostics: =?iso-8859-1?Q?1; MN2PR18MB2672; 23:WUol04d7kVfa0d6XVpFTUTnzfQ9EwNflpTIUoVY?= =?iso-8859-1?Q?WV0mnh2MV3725EQ4hZX4nF7RGSicmXfBV7Zqt7JBVv45hvLNrSeAPhajeD?= =?iso-8859-1?Q?bDKsS50jM5AEsi+EfD7SzZb6DkBC72HfcUcuidk1+EdCLu/u885rAd8sLk?= =?iso-8859-1?Q?lN9aPWnAffOyVNobOFB0ztYSujk0h7RjmLGBc9KJDgKxNRimEeN2QB3Mzv?= =?iso-8859-1?Q?D3bRbpGx7LekA+No0eMNmeAJzmcODRontXpisHtua36HH+uflhhQ9XZBxL?= =?iso-8859-1?Q?M6x0Z0n4c8y6p1wO8gRSq4sAGsEDbU7wAbl5D8eoX8UGBo12HsoDjmScZz?= =?iso-8859-1?Q?57Dqe6P14wce2zdCJbEm5H78Exu6S8T84uJrJVIfe1/DMbHhdKw2OBQIzS?= =?iso-8859-1?Q?EbWbtQEMThj6nt6ME++7bKQT8BMDsKZLtcvXmSBTaglOzhfhgSxj14uZxQ?= =?iso-8859-1?Q?d5z2Uh/Bx46Rpkj0sXiDlLtCBkQ436At9qJpDl9CYL+yGJ95eYUHiLFUmh?= =?iso-8859-1?Q?0YudwbCornkySau3EafCesdUKytGqkveyI/+p8ISALKGE4HERjlmNLtTvB?= =?iso-8859-1?Q?v1hEV2B4C1Hlb7wuUqiH8aV5gyOJwLUkTpcVBUcs0ToIS8naDjQA3tbf32?= =?iso-8859-1?Q?iSYlfm0uDXciKIQpXyOpNkzzMYvT3U+TkGnI/vIjRgoYZ+4XtqceqLP57x?= =?iso-8859-1?Q?Ucg3B5lxdtLqtC121rtKPm8NUOhED/t7Zf+ByMzkIwUGdVr6jw/eCbVlon?= =?iso-8859-1?Q?HiRz6kBZQZ4lbEvchuac+1f9kCsRn4dE4HdicwmOXDTSG3a7GVPYIJMsMl?= =?iso-8859-1?Q?nm6xSviy4pFEaXxOKcSmYgaD0PBlIiHiXPGopJSOhftdy57McCV5f3Idiw?= =?iso-8859-1?Q?0cWudEvlS7Tsm1N97g01S3uMoTBFOT3aF4wpK3vJR6WZM4sR39rkO6rv3I?= =?iso-8859-1?Q?2ucGpoFnJ4tYG+wEADCTxr3nPj0UZQUYCcLt9k26qGkZIYT/bePZj5pDW0?= =?iso-8859-1?Q?lFRFQTNyZrCVqOhLxjqZxBS4ubKgJxE1ehxu64IwMZEtMhQypBUlDO4C8T?= =?iso-8859-1?Q?jrer8cQMrRoyVLh+7Rr7ZIhBuRwmbN6Enu3O2ouCwbIeb1ZcMEHhxsMyWJ?= =?iso-8859-1?Q?s9i1fN3gJdn0+boHk7ks9Piw0sQ+QNOw2rXfZUW+hjNDGAbELF6eNAS1lH?= =?iso-8859-1?Q?LttPKhK0kNqyEUiUxWHeRClRi+BrBJboPXtCYRxydyqSURMpghfilR3kdv?= =?iso-8859-1?Q?3/KY7YKHq9HpeUup6I9U2p3EwrMStmSuG3MDKoA=3D=3D?= x-microsoft-antispam-prvs: x-forefront-prvs: 09730BD177 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(136003)(396003)(39850400004)(376002)(346002)(366004)(199004)(189003)(25786009)(7736002)(36756003)(316002)(55236004)(6506007)(386003)(305945005)(102836004)(68736007)(6512007)(8936002)(97736004)(50226002)(53936002)(6436002)(6486002)(52116002)(76176011)(8676002)(3846002)(2906002)(105586002)(99286004)(81156014)(81166006)(4326008)(6116002)(486006)(476003)(66066001)(2616005)(86362001)(106356001)(14454004)(186003)(478600001)(54906003)(26005)(110136005)(71190400001)(71200400001)(11346002)(446003)(5660300002)(256004)(14444005); DIR:OUT; SFP:1101; SCL:1; SRVR:MN2PR18MB2672; 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: TH3PS/uYyh2Omn7cQ7ZycB2/WMXLvU/JyWW3fl/AStMoPn6QqG6I8p//3iWU/OZUqi4YNp87GTK4OoYkXl4U3klesA0yT04ucmc8c6fYB2/7nubVGL+URrgAiIfRtiKjTn3QvcuO7eL+tgtCVayEFYQPzwmf1H4lI8VZr4xGSmnH6A0SmGtZ/z1ZABZFxBytpAsE7ff9Ol8rh9qtLe8qwPb05e0CESWydk2TZDBlx1DkAzBYPd6zPaFxOR+pri2AlgfkNosjqCOWMoxuPYJA7S5i6MXV7Y6smXCtJbRYYCVt0BmnISt1l8uLPLzBNF8niNeCVVfEpj2opfXxSu7AOzD+zIaUUbpmiaXEyxMFGARsP7FEYUV/DL1feGfK11AwCo+xa9d3/eJldG2PtSOrnhe9nVocSkLVzyS6dAnT/O0= Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-MS-Exchange-CrossTenant-Network-Message-Id: 348e956b-e921-404c-3a24-08d6a5e63312 X-MS-Exchange-CrossTenant-originalarrivaltime: 11 Mar 2019 05:55:44.0679 (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: MN2PR18MB2672 X-OriginatorOrg: marvell.com X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2019-03-11_05:, , signatures=0 Subject: [dpdk-dev] [PATCH v2] 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: Mon, 11 Mar 2019 05:55:54 -0000 The string compare to the length of driver name might give false positives 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 When strncmp with len =3D strlen("crypto_driver") is done, it could give a false positive when compared against "crypto_driver1". For such cases, 'strlen + 1' is done, so that the NULL termination also would be considered for the comparison. Fixes: d11b0f30df88 ("cryptodev: introduce API and framework for crypto dev= ices") Signed-off-by: Ankur Dwivedi Signed-off-by: Anoob Joseph --- v2: * Using strlen + 1, instead of RTE_CRYPTODEV_NAME_MAX_LEN for the compariso= n. * Strcmp would not cause this issue. Touching only the places which would result in the issue. lib/librte_cryptodev/rte_cryptodev.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/librte_cryptodev/rte_cryptodev.c b/lib/librte_cryptodev/rt= e_cryptodev.c index 7009735..871d7dd 100644 --- a/lib/librte_cryptodev/rte_cryptodev.c +++ b/lib/librte_cryptodev/rte_cryptodev.c @@ -586,7 +586,7 @@ rte_cryptodev_devices_get(const char *driver_name, uint= 8_t *devices, =20 cmp =3D strncmp(devs[i].device->driver->name, driver_name, - strlen(driver_name)); + strlen(driver_name) + 1); =20 if (cmp =3D=3D 0) devices[count++] =3D devs[i].data->dev_id; @@ -1691,7 +1691,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, strlen(driver_name) + 1) =3D=3D 0) return driver->id; } return -1; --=20 2.7.4