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 6644E20BD for ; Sat, 23 Feb 2019 07:11:36 +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 x1N65gJn016551; Fri, 22 Feb 2019 22:11:35 -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=Wc12cRapAEf2eM6ScZCmRW8fB3O2gX3wg6c1NhkrmSo=; b=Bu1co3QOVao8bN+ifOVFbaM8JfIixU+PLScAeBtK3xZ+ry2bN0ZBXylo0jwhHkm3mOs6 98rMcMhQjJNu9LSf+5HRs+mRtw2dzoAj2O1dedMT0Bdbq0NLkjx3RgmZcsvVlgwcK7y/ ayn4aHHCfBge6piyWc2C4L4cEamUjcLs7GSOY+1V1dmfIm/HRYy8f1EsCgVY/wpgNQXJ GMgs/yGaKRULMbgHlrVaVGFLmQfvFi/cQelsYu31QgHBBBdw6SGe3VFM0el59j4ForAJ STx6VqeJIDzHL5t3V8c4I6ClpU5CeQKjAQUPlvvdnPaK22E3NqF7M2eQLcfxFJgbF1Bj UQ== Received: from sc-exch04.marvell.com ([199.233.58.184]) by mx0b-0016f401.pphosted.com with ESMTP id 2qt126maqg-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Fri, 22 Feb 2019 22:11:34 -0800 Received: from SC-EXCH01.marvell.com (10.93.176.81) by SC-EXCH04.marvell.com (10.93.176.84) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Fri, 22 Feb 2019 22:11:33 -0800 Received: from NAM04-CO1-obe.outbound.protection.outlook.com (104.47.45.56) by SC-EXCH01.marvell.com (10.93.176.81) with Microsoft SMTP Server (TLS) id 15.0.1367.3 via Frontend Transport; Fri, 22 Feb 2019 22:11:33 -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=Wc12cRapAEf2eM6ScZCmRW8fB3O2gX3wg6c1NhkrmSo=; b=sOzlxNXt0pvr9V9m8Pdagcy6dlghKbLgS0SuHPdGMYzS4aUveOO0O2mlx/7Q9E2ARb81EOBEftWG9JQ90hN8Gk8Cl0nf20E39Qyfq2Mj2SX7jTRWBiUUMEyviFPFK9qtat+Pb6lzkjNz9Dwvt0xPF74BtT+RPfzywSaFKcbHsjw= Received: from MN2PR18MB2877.namprd18.prod.outlook.com (20.179.20.218) by MN2PR18MB2878.namprd18.prod.outlook.com (20.179.22.17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1643.15; Sat, 23 Feb 2019 06:11:31 +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.018; Sat, 23 Feb 2019 06:11:31 +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+7Qt9aXo7DZAgAGkSYCAAMGkYIAAvGkQgADywKA= Date: Sat, 23 Feb 2019 06:11:31 +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> In-Reply-To: <348A99DA5F5B7549AA880327E580B435896F4E65@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: [223.230.95.238] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 7c0dfaf2-9dab-4983-acb3-08d69955c189 x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(5600110)(711020)(4605104)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7153060)(7193020); SRVR:MN2PR18MB2878; x-ms-traffictypediagnostic: MN2PR18MB2878: x-microsoft-exchange-diagnostics: 1; MN2PR18MB2878; 20:h0ZLv2PpaJF+RnurRHe48q4BwqwUPtKaZOebxAG+61XxIDz7vHwCQ+9hHiZ6bWlmJgMuh2JjImmuRqRJjMiJzxnoGUBA3aqSaXe5Bwc6UOe/qgBTD5nxZziaaNuPohH/3aAivyLAUrSDfW82d3o6sjxpNhdXAJsfz+rxI+17Gsc= x-microsoft-antispam-prvs: x-forefront-prvs: 0957AD37A0 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(979002)(396003)(376002)(39860400002)(366004)(346002)(136003)(199004)(13464003)(189003)(81166006)(81156014)(14454004)(8936002)(25786009)(6436002)(6506007)(186003)(8676002)(7696005)(7736002)(93886005)(478600001)(53546011)(102836004)(76176011)(107886003)(4326008)(74316002)(305945005)(97736004)(5660300002)(256004)(86362001)(14444005)(53936002)(229853002)(68736007)(26005)(11346002)(99286004)(106356001)(105586002)(6246003)(446003)(33656002)(6116002)(2906002)(71190400001)(71200400001)(110136005)(476003)(66066001)(316002)(54906003)(486006)(55016002)(3846002)(9686003)(52536013)(921003)(1121003)(969003)(989001)(999001)(1009001)(1019001); DIR:OUT; SFP:1101; SCL:1; SRVR:MN2PR18MB2878; 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: ovK2yfwNlmmrQBhzegctf5HEpw298fSbGjIbIPvD7mcED2j2JeS40Vsztfja2VKNdMQJ649J+tkgDWO45VGzUzLsRliklkIVle4k6fHDaxWyUUOxzPfca+1weue0uT80Qvb7t28SWjZPnHxLvuDK0oSwTdWqNcYlwScwGlgXynZ0ecVI4JtJL7RwfsiMQlCj+nAn8jQTuiks8XWH9yVRKVDpI9lmfgSM+Qf0k8eQtxX8G/n82vJvOlQG8cDWjbk7whyRllbkBUrr4GzcNA6u7d02oMvRkt8vZIdp44w+XJuEajXsXLSEfgo7ukSqoTOZqckyZuPyTsb0g1tPr8L3+5ufzsHO7voSapWfiWm8LD0FACrRrhhIxk4MYKN4gkBzIlOAmsHw4GhJ1YeHqWmlBA8LsIfxcaZn/AX/tLGW5DY= Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-MS-Exchange-CrossTenant-Network-Message-Id: 7c0dfaf2-9dab-4983-acb3-08d69955c189 X-MS-Exchange-CrossTenant-originalarrivaltime: 23 Feb 2019 06:11:31.7008 (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: MN2PR18MB2878 X-OriginatorOrg: marvell.com X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2019-02-23_05:, , 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=1011 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-1902230043 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: Sat, 23 Feb 2019 06:11:36 -0000 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 >=20 > Hi Anoob, >=20 > > > > > @@ -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, n= one 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 su= ggest > adding a comment on the relevant APIs saying that the string must be pass= ed in > in a buffer of size with trailing zeros. [Anoob] Do you want this patch to address that? And wouldn't specifying som= ething like that explicitly, be an ABI breakage? Also, I think the same is applicable for other similar functions (rte_eth_d= ev_get_port_by_name() etc), wherever we expect a string. Please do share yo= ur thoughts on what all I should include in this patch. Thanks, Anoob