From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR01-DB5-obe.outbound.protection.outlook.com (mail-eopbgr150059.outbound.protection.outlook.com [40.107.15.59]) by dpdk.org (Postfix) with ESMTP id 29EBE1DBD for ; Mon, 18 Mar 2019 13:32:17 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Mellanox.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=0bEyWakqWCRkrCG4w4HxlMGz2Du3ox1J1Lo4nfba3/4=; b=Esd9o0fIs6lbRb+nRw7Xs3XmF3kCCELLePcjzTDIeeLZXvm+wHwGqghZZFTm0ra6MlVdYwN1Yd8TZUwNvSVOfGteotmahkqNJH4zHNBOhyzk7cGWeZwEBr8bxpBHkjz0h5aUCoPab5gg7eHDrWLu2hYd9GXkl9FsXAvwfSAEBQM= Received: from VI1PR05MB4269.eurprd05.prod.outlook.com (52.133.12.22) by VI1PR05MB5983.eurprd05.prod.outlook.com (20.178.127.29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1709.13; Mon, 18 Mar 2019 12:32:16 +0000 Received: from VI1PR05MB4269.eurprd05.prod.outlook.com ([fe80::55ef:d19:7985:4c7f]) by VI1PR05MB4269.eurprd05.prod.outlook.com ([fe80::55ef:d19:7985:4c7f%4]) with mapi id 15.20.1709.015; Mon, 18 Mar 2019 12:32:16 +0000 From: Ali Alnubani To: "20190311181544.15646-1-stephen@networkplumber.org" <20190311181544.15646-1-stephen@networkplumber.org>, "dev@dpdk.org" Thread-Topic: [dpdk-dev] [PATCH v3] ethdev: check for invalid device name Thread-Index: AQHU2oHn90tIv0OODE+kbwKAjDzHiqYRVyNw Date: Mon, 18 Mar 2019 12:32:15 +0000 Message-ID: References: <20190314162047.20375-1-stephen@networkplumber.org> In-Reply-To: <20190314162047.20375-1-stephen@networkplumber.org> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=alialnu@mellanox.com; x-originating-ip: [82.213.2.186] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: a8aad348-be45-460f-2efe-08d6ab9dc148 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600127)(711020)(4605104)(4618075)(2017052603328)(7153060)(7193020); SRVR:VI1PR05MB5983; x-ms-traffictypediagnostic: VI1PR05MB5983: x-microsoft-antispam-prvs: x-forefront-prvs: 098076C36C x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(396003)(39860400002)(366004)(376002)(136003)(346002)(199004)(189003)(13464003)(68736007)(256004)(66066001)(26005)(6506007)(53546011)(446003)(102836004)(7736002)(229853002)(186003)(74316002)(71200400001)(33656002)(97736004)(71190400001)(478600001)(14454004)(25786009)(5660300002)(305945005)(316002)(2906002)(8936002)(81156014)(81166006)(110136005)(8676002)(11346002)(105586002)(2501003)(53936002)(9686003)(52536014)(486006)(99286004)(7696005)(86362001)(476003)(6436002)(6246003)(76176011)(3846002)(6116002)(106356001)(55016002); DIR:OUT; SFP:1101; SCL:1; SRVR:VI1PR05MB5983; H:VI1PR05MB4269.eurprd05.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; received-spf: None (protection.outlook.com: mellanox.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: EiyL6AjvHQgbajzBUC0oZfDtNe1UEPb5kcwRxkqrnej0ZhB2qC4U1KMJx1VoQzorRHir1KEPfmv94AvVpK08BaLVi4hwzjhbj/Lb1SxBG9LZP4mv5IjwowFN4KNJ7o1bVDggRD8dt/j5TWV3JiXBorId3icnnmYKc1cHqrMd+NyiokRcncu3kekGA3uUZS8YxgxQT4l0KJEgHmkrBbQK8N6G4xBs+7O2waY/FQEW9WP0c6+nThpKM8tCi9I8G1XQtoolz8FDmwKJ54RNG+6uk4ltztLMlRgaVE5mQ3GjTBOlBKfO+REY1cgyMDYp6pm0h+wJeBSEQlya3tfUVv9DrkVkXMbYI3A3VMUILpGvXbuauCtkqa2djOJnar8HghEzuzI96IUzB5OgCtlWYG1uxFfBEqAmOqvJOz8VmAXLCzI= Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-Network-Message-Id: a8aad348-be45-460f-2efe-08d6ab9dc148 X-MS-Exchange-CrossTenant-originalarrivaltime: 18 Mar 2019 12:32:16.0122 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR05MB5983 Subject: Re: [dpdk-dev] [PATCH v3] ethdev: check for invalid device name 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, 18 Mar 2019 12:32:17 -0000 > -----Original Message----- > From: dev On Behalf Of Stephen Hemminger > Sent: Thursday, March 14, 2019 6:21 PM > To: dev@dpdk.org > Cc: Stephen Hemminger > Subject: [dpdk-dev] [PATCH v3] ethdev: check for invalid device name >=20 > Do not allow creating a ethernet device with a name over the allowed > maximum (or zero length). This is safer than silently truncating which is= what > happens now. >=20 > Signed-off-by: Stephen Hemminger > Acked-by: Andrew Rybchenko > --- > v3 -- fix whitespace issue >=20 > lib/librte_ethdev/rte_ethdev.c | 12 ++++++++++++ > 1 file changed, 12 insertions(+) >=20 > diff --git a/lib/librte_ethdev/rte_ethdev.c b/lib/librte_ethdev/rte_ethde= v.c > index 85c1794968dd..cf69daaf3224 100644 > --- a/lib/librte_ethdev/rte_ethdev.c > +++ b/lib/librte_ethdev/rte_ethdev.c > @@ -438,6 +438,18 @@ rte_eth_dev_allocate(const char *name) { > uint16_t port_id; > struct rte_eth_dev *eth_dev =3D NULL; > + size_t name_len; > + > + name_len =3D strnlen(name, RTE_ETH_NAME_MAX_LEN); > + if (name_len =3D=3D 0) { > + RTE_ETHDEV_LOG(ERR, "Zero length Ethernet device > name\n"); > + return NULL; > + } > + > + if (name_len >=3D RTE_ETH_NAME_MAX_LEN) { > + RTE_ETHDEV_LOG(ERR, "Ethernet device name is too > long\n"); > + return NULL; > + } >=20 > rte_eth_dev_shared_data_prepare(); >=20 > -- > 2.17.1 Acked-by: Ali Alnubani From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by dpdk.space (Postfix) with ESMTP id 63231A05FE for ; Mon, 18 Mar 2019 13:32:19 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id B6E3F2C60; Mon, 18 Mar 2019 13:32:18 +0100 (CET) Received: from EUR01-DB5-obe.outbound.protection.outlook.com (mail-eopbgr150059.outbound.protection.outlook.com [40.107.15.59]) by dpdk.org (Postfix) with ESMTP id 29EBE1DBD for ; Mon, 18 Mar 2019 13:32:17 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Mellanox.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=0bEyWakqWCRkrCG4w4HxlMGz2Du3ox1J1Lo4nfba3/4=; b=Esd9o0fIs6lbRb+nRw7Xs3XmF3kCCELLePcjzTDIeeLZXvm+wHwGqghZZFTm0ra6MlVdYwN1Yd8TZUwNvSVOfGteotmahkqNJH4zHNBOhyzk7cGWeZwEBr8bxpBHkjz0h5aUCoPab5gg7eHDrWLu2hYd9GXkl9FsXAvwfSAEBQM= Received: from VI1PR05MB4269.eurprd05.prod.outlook.com (52.133.12.22) by VI1PR05MB5983.eurprd05.prod.outlook.com (20.178.127.29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1709.13; Mon, 18 Mar 2019 12:32:16 +0000 Received: from VI1PR05MB4269.eurprd05.prod.outlook.com ([fe80::55ef:d19:7985:4c7f]) by VI1PR05MB4269.eurprd05.prod.outlook.com ([fe80::55ef:d19:7985:4c7f%4]) with mapi id 15.20.1709.015; Mon, 18 Mar 2019 12:32:16 +0000 From: Ali Alnubani To: "20190311181544.15646-1-stephen@networkplumber.org" <20190311181544.15646-1-stephen@networkplumber.org>, "dev@dpdk.org" Thread-Topic: [dpdk-dev] [PATCH v3] ethdev: check for invalid device name Thread-Index: AQHU2oHn90tIv0OODE+kbwKAjDzHiqYRVyNw Date: Mon, 18 Mar 2019 12:32:15 +0000 Message-ID: References: <20190314162047.20375-1-stephen@networkplumber.org> In-Reply-To: <20190314162047.20375-1-stephen@networkplumber.org> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=alialnu@mellanox.com; x-originating-ip: [82.213.2.186] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: a8aad348-be45-460f-2efe-08d6ab9dc148 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600127)(711020)(4605104)(4618075)(2017052603328)(7153060)(7193020); SRVR:VI1PR05MB5983; x-ms-traffictypediagnostic: VI1PR05MB5983: x-microsoft-antispam-prvs: x-forefront-prvs: 098076C36C x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(396003)(39860400002)(366004)(376002)(136003)(346002)(199004)(189003)(13464003)(68736007)(256004)(66066001)(26005)(6506007)(53546011)(446003)(102836004)(7736002)(229853002)(186003)(74316002)(71200400001)(33656002)(97736004)(71190400001)(478600001)(14454004)(25786009)(5660300002)(305945005)(316002)(2906002)(8936002)(81156014)(81166006)(110136005)(8676002)(11346002)(105586002)(2501003)(53936002)(9686003)(52536014)(486006)(99286004)(7696005)(86362001)(476003)(6436002)(6246003)(76176011)(3846002)(6116002)(106356001)(55016002); DIR:OUT; SFP:1101; SCL:1; SRVR:VI1PR05MB5983; H:VI1PR05MB4269.eurprd05.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; received-spf: None (protection.outlook.com: mellanox.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: EiyL6AjvHQgbajzBUC0oZfDtNe1UEPb5kcwRxkqrnej0ZhB2qC4U1KMJx1VoQzorRHir1KEPfmv94AvVpK08BaLVi4hwzjhbj/Lb1SxBG9LZP4mv5IjwowFN4KNJ7o1bVDggRD8dt/j5TWV3JiXBorId3icnnmYKc1cHqrMd+NyiokRcncu3kekGA3uUZS8YxgxQT4l0KJEgHmkrBbQK8N6G4xBs+7O2waY/FQEW9WP0c6+nThpKM8tCi9I8G1XQtoolz8FDmwKJ54RNG+6uk4ltztLMlRgaVE5mQ3GjTBOlBKfO+REY1cgyMDYp6pm0h+wJeBSEQlya3tfUVv9DrkVkXMbYI3A3VMUILpGvXbuauCtkqa2djOJnar8HghEzuzI96IUzB5OgCtlWYG1uxFfBEqAmOqvJOz8VmAXLCzI= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-Network-Message-Id: a8aad348-be45-460f-2efe-08d6ab9dc148 X-MS-Exchange-CrossTenant-originalarrivaltime: 18 Mar 2019 12:32:16.0122 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR05MB5983 Subject: Re: [dpdk-dev] [PATCH v3] ethdev: check for invalid device name 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Message-ID: <20190318123215.m1cBdw8PNTZDtN__Jb1mxwyD6sGjm2jl3Zety_rDTzI@z> > -----Original Message----- > From: dev On Behalf Of Stephen Hemminger > Sent: Thursday, March 14, 2019 6:21 PM > To: dev@dpdk.org > Cc: Stephen Hemminger > Subject: [dpdk-dev] [PATCH v3] ethdev: check for invalid device name >=20 > Do not allow creating a ethernet device with a name over the allowed > maximum (or zero length). This is safer than silently truncating which is= what > happens now. >=20 > Signed-off-by: Stephen Hemminger > Acked-by: Andrew Rybchenko > --- > v3 -- fix whitespace issue >=20 > lib/librte_ethdev/rte_ethdev.c | 12 ++++++++++++ > 1 file changed, 12 insertions(+) >=20 > diff --git a/lib/librte_ethdev/rte_ethdev.c b/lib/librte_ethdev/rte_ethde= v.c > index 85c1794968dd..cf69daaf3224 100644 > --- a/lib/librte_ethdev/rte_ethdev.c > +++ b/lib/librte_ethdev/rte_ethdev.c > @@ -438,6 +438,18 @@ rte_eth_dev_allocate(const char *name) { > uint16_t port_id; > struct rte_eth_dev *eth_dev =3D NULL; > + size_t name_len; > + > + name_len =3D strnlen(name, RTE_ETH_NAME_MAX_LEN); > + if (name_len =3D=3D 0) { > + RTE_ETHDEV_LOG(ERR, "Zero length Ethernet device > name\n"); > + return NULL; > + } > + > + if (name_len >=3D RTE_ETH_NAME_MAX_LEN) { > + RTE_ETHDEV_LOG(ERR, "Ethernet device name is too > long\n"); > + return NULL; > + } >=20 > rte_eth_dev_shared_data_prepare(); >=20 > -- > 2.17.1 Acked-by: Ali Alnubani