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 40E8127D for ; Thu, 28 Feb 2019 07:48:27 +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 x1S6j0B1002635; Wed, 27 Feb 2019 22:48:26 -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=U7NwjEVBsg49G9eGuuQMPaccd2xyHUAPxrPAZB1IBRM=; b=TjPns1eiLTAGCPITZAXLN7wjmBrPpFpHxmflk5GD9dVDE2n5oj+tnkqAL6QauFWOkwzm J/nogWnoACN2EOUasnz+q0UKmKQ8iDuzYYhFlIOhb6M8kiTOmYlhlZEoKpXPdVP7AD3U deKClto0Hrm9EqDe5XZ9SkVTMsc4NsODNx3As4XQL1wZxWw7+VXSFJ53OeofRXATC01A LrkUCq0kharwzsw4/thh4nzp7/229ZbGrQFCkdRFtL9C36j+m2/qf6UO01yshv96tRvO YPdGJcW7HgMSiOZeQpUGgHhukB14Faf+AjMZyPpNbixpaDo+F2yEmEq9GPuTfTNV4zZU jQ== Received: from sc-exch03.marvell.com ([199.233.58.183]) by mx0b-0016f401.pphosted.com with ESMTP id 2qwhfgvt2r-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Wed, 27 Feb 2019 22:48:26 -0800 Received: from SC-EXCH02.marvell.com (10.93.176.82) by SC-EXCH03.marvell.com (10.93.176.83) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Wed, 27 Feb 2019 22:48:24 -0800 Received: from NAM03-CO1-obe.outbound.protection.outlook.com (104.47.40.56) by SC-EXCH02.marvell.com (10.93.176.82) with Microsoft SMTP Server (TLS) id 15.0.1367.3 via Frontend Transport; Wed, 27 Feb 2019 22:48:24 -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=U7NwjEVBsg49G9eGuuQMPaccd2xyHUAPxrPAZB1IBRM=; b=FaZxloVGrK/IqK88xnYlTAWBMWsNCYuQIkgTF4lyGOiZQQfNosNez4ni/Lbu3bJxySsXUqI+2FmEpiZj+UkwLluHetbZBnDCBab8bqxZ69W4BaF3gTwVgSXwYWp8QLcQ/O6ay70eRthW6ji8T6E/Ov313yPrs12ZhFNAAYXy/AA= Received: from MN2PR18MB2877.namprd18.prod.outlook.com (20.179.20.218) by MN2PR18MB3086.namprd18.prod.outlook.com (20.179.21.74) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1665.15; Thu, 28 Feb 2019 06:48:19 +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.1665.015; Thu, 28 Feb 2019 06:48:19 +0000 From: Anoob Joseph To: "Trahe, Fiona" , Akhil Goyal , "Doherty, Declan" , "De Lara Guarch, Pablo" , "Yigit, Ferruh" , Thomas Monjalon 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+7Qt9aXo7DZAgAGkSYCAAMGkYIAAvGkQgADywKCAA4WCgIAEYxTg Date: Thu, 28 Feb 2019 06:48:19 +0000 Message-ID: References: <1549279528-10397-1-git-send-email-anoobj@marvell.com> <348A99DA5F5B7549AA880327E580B435896F431A@IRSMSX101.ger.corp.intel.com> <348A99DA5F5B7549AA880327E580B435896F4E65@IRSMSX101.ger.corp.intel.com> <348A99DA5F5B7549AA880327E580B435896F6EC3@IRSMSX101.ger.corp.intel.com> In-Reply-To: <348A99DA5F5B7549AA880327E580B435896F6EC3@IRSMSX101.ger.corp.intel.com> Accept-Language: en-IN, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [115.113.156.2] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: e643a3b1-1be9-4f2b-4350-08d69d48b990 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:MN2PR18MB3086; x-ms-traffictypediagnostic: MN2PR18MB3086: x-microsoft-exchange-diagnostics: =?us-ascii?Q?1; MN2PR18MB3086; 23:beW1ZR+37jULa0IJ7EyV9gU9ET/2N2kHAiwSpLzrd?= =?us-ascii?Q?vDoZo/5Mm+5iuPlj/q0e2iTUAqDklT2/AK9yeUq3ChwgKqnwmneiPi2R/MXW?= =?us-ascii?Q?4OKOnggueaqjETyhbh1+l+k4BbVVE2mA4AL7v4q9oediyFzpiZzPiQs1QJDq?= =?us-ascii?Q?C9kBvDXDRgVHh5f5/BarXPeTbej6yaKamTjapu26oApW8Fn4tm2MS8tQQLXO?= =?us-ascii?Q?aym/BUAoEyUri5ImyqbIELbP2K74CEOhlBOPl4jnXB/S8pKOnBGc4rz/34LV?= =?us-ascii?Q?OYqppXsdiPWZ3q7X5bbxfMs4y8Od0tXg0DhS+90Hn9JY4MppNqsWPjMT0KuI?= =?us-ascii?Q?ynAgQE8fdDj7GhvVJdWdyk13jtxoK41FlYIx2w6rmSUVNFWGZbtwonE5ORtY?= =?us-ascii?Q?nWxeH/KYB3bMdFCKWkWxkWjNCwmFrUlaVTe7Rb1iSyanKEAQ4GDKmWEn4SCO?= =?us-ascii?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X8lHNxSU8oeNyOo6v?= =?us-ascii?Q?zgFZEqwb7+bxHAFvfc35FugRj8=3D?= x-microsoft-antispam-prvs: x-forefront-prvs: 0962D394D2 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(39860400002)(366004)(136003)(346002)(376002)(396003)(199004)(189003)(13464003)(6116002)(14454004)(93886005)(3846002)(74316002)(229853002)(8936002)(53546011)(102836004)(7696005)(305945005)(81166006)(81156014)(6506007)(55236004)(7736002)(71190400001)(71200400001)(52536013)(5660300002)(8676002)(86362001)(97736004)(68736007)(11346002)(256004)(54906003)(25786009)(110136005)(4326008)(14444005)(486006)(316002)(6246003)(107886003)(476003)(446003)(99286004)(478600001)(9686003)(55016002)(26005)(76176011)(66066001)(186003)(105586002)(6436002)(106356001)(33656002)(53936002)(2906002)(921003)(1121003); DIR:OUT; SFP:1101; SCL:1; SRVR:MN2PR18MB3086; 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: zqCQvg153351+s3lq/TMwaBcyzOPX8KTMAKkKxKQKmt4C2M7aYLDBkg8qHIS0aGPOCI47CQ5OOnzNqvDsBoMl0cX0LkbUnXRcamVSTZ+xQJgi5eI56ktuESgsNDCHYe+zoFTBK0REQ6UTBpNm+TNFJIoINMnG6VEHY9BUX2E/sxIgSgdpNOS9gvUeI1No9mm88CjtXNW4NGBSDCcQp1x0HJNexKBPj0Jg93a6MpbLJngAev/8j2/PCwywBXTGvVOQgoPzkoS3jHaw20ev5QcYlCHVYfh01emAOAGrlzmM+QgthQEk536UrL1Zn/gBtZQt84WbzJ46npK69TzMiA32DY6bF6l9o1OFRh3FUK1Y09Q60MEaoD03Bj4RR619TGDEfsoAIUCrl41vGqJ4vBwLlUUqZdoC38VQo1Jro298aM= Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-MS-Exchange-CrossTenant-Network-Message-Id: e643a3b1-1be9-4f2b-4350-08d69d48b990 X-MS-Exchange-CrossTenant-originalarrivaltime: 28 Feb 2019 06:48:19.4628 (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: MN2PR18MB3086 X-OriginatorOrg: marvell.com X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2019-02-28_03:, , 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-1902280047 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, 28 Feb 2019 06:48:27 -0000 Hi Akhil, Declan, Pablo, Can you review this patch and share your thoughts? Thanks, Anoob > -----Original Message----- > From: Trahe, Fiona > Sent: Monday, February 25, 2019 5:22 PM > To: Anoob Joseph ; Akhil Goyal > ; Doherty, Declan ; De > Lara Guarch, Pablo ; Yigit, Ferruh > ; Thomas Monjalon > Cc: Jerin Jacob Kollanukkaran ; Narayana Prasad Raju > Athreya ; dev@dpdk.org; Ankur Dwivedi > > Subject: RE: [PATCH] lib/cryptodev: fix driver name comparison >=20 > Hi Anoob >=20 > > -----Original Message----- > > From: Anoob Joseph [mailto:anoobj@marvell.com] > > Sent: Saturday, February 23, 2019 6:12 AM > > To: Trahe, Fiona ; Akhil Goyal > > ; Doherty, Declan ; De > > Lara Guarch, Pablo ; Yigit, Ferruh > > ; Thomas Monjalon > > Cc: Jerin Jacob Kollanukkaran ; Narayana Prasad > > Raju Athreya ; dev@dpdk.org; Ankur Dwivedi > > > > Subject: RE: [PATCH] lib/cryptodev: fix driver name comparison > > > > Hi Fiona, > > > > > -----Original Message----- > > > From: Trahe, Fiona > > > Sent: Friday, February 22, 2019 9:09 PM > > > 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 > > > Subject: RE: [PATCH] lib/cryptodev: fix driver name comparison > > > > > > Hi Anoob, > > > > > > > > > > @@ -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 of RTE_CRYPTODEV_NAME_MAX_LEN. Does this > prototype > > > > > need to specify that a full length const filled with trailing > > > > > zeros must be passed in? And if so is this an ABI breakage? > > > > > > > > > > > > > [Anoob] strcmp itself is not safe when we have buffers which are > > > > not NULL terminated. Strncmp will make sure the check won't exceed > > > RTE_CRYPTODEV_NAME_MAX_LEN. > > > > > > > > From man page, "The strncmp() function is similar, except it only > > > > compares the first (at most) n bytes of > > > > s1 and s2." > > > > > > > > The main issue here is the usage of strncmp with > > > > strlen(driver_name), as in the below cases. Strlen will return > > > > string length, which doesn't include \0. strcmp is good enough to > > > > fix the issue. But usage of strcmp would assume that the const is > > > > filled with trailing zero. IMO, none of > > > these options are really safe. So please advise on what would be the > > > best solution here. I'll revise the patch accordingly. > > > [Fiona] I agree and think it is safest as you've coded it. However > > > I'd suggest adding a comment on the relevant APIs saying that the > > > string must be passed in in a buffer of size w= ith > trailing zeros. > > > > [Anoob] Do you want this patch to address that? And wouldn't > > specifying something like that explicitly, be an ABI breakage? > [Fiona] Yes, I think it should be in this patch as this patch is causing = it. > But it's up to the maintainers what's acceptable - it seems to me that it= 's an > ABI breakage, avoiding saying it explicitly doesn't make it less so. >=20 > > > > Also, I think the same is applicable for other similar functions > > (rte_eth_dev_get_port_by_name() etc), wherever we expect a string. > Please do share your thoughts on what all I should include in this patch. > > > > Thanks, > > Anoob