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 3E8F5A0096 for ; Fri, 15 Mar 2019 02:13:54 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 660C3324D; Fri, 15 Mar 2019 02:13:53 +0100 (CET) Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by dpdk.org (Postfix) with ESMTP id 471442C28 for ; Fri, 15 Mar 2019 02:13:51 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 14 Mar 2019 18:13:50 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.58,480,1544515200"; d="scan'208";a="151857383" Received: from fmsmsx106.amr.corp.intel.com ([10.18.124.204]) by fmsmga002.fm.intel.com with ESMTP; 14 Mar 2019 18:13:50 -0700 Received: from fmsmsx117.amr.corp.intel.com (10.18.116.17) by FMSMSX106.amr.corp.intel.com (10.18.124.204) with Microsoft SMTP Server (TLS) id 14.3.408.0; Thu, 14 Mar 2019 18:13:50 -0700 Received: from shsmsx105.ccr.corp.intel.com (10.239.4.158) by fmsmsx117.amr.corp.intel.com (10.18.116.17) with Microsoft SMTP Server (TLS) id 14.3.408.0; Thu, 14 Mar 2019 18:13:49 -0700 Received: from shsmsx103.ccr.corp.intel.com ([169.254.4.134]) by SHSMSX105.ccr.corp.intel.com ([169.254.11.113]) with mapi id 14.03.0415.000; Fri, 15 Mar 2019 09:13:47 +0800 From: "Zhang, Qi Z" 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: AQHU2oHzWEXorSJt/0Ke5lrJ1eMzOqYL42gg Date: Fri, 15 Mar 2019 01:13:47 +0000 Message-ID: <039ED4275CED7440929022BC67E706115334CD44@SHSMSX103.ccr.corp.intel.com> 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: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiMGQ2YTY4YTMtZjMyNS00NzE0LTk3OTQtNTM1Y2Q3NWExMzQwIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjEwLjE4MDQuNDkiLCJUcnVzdGVkTGFiZWxIYXNoIjoiQnljODRGZms5bWthcTIxdDRFQkxQdFltN01vNDYwXC9IdlNIODUxVlVPOFBKMFd6dThlSUpiakZPd1JsZlk1a0sifQ== x-ctpclassification: CTP_NT dlp-product: dlpe-windows dlp-version: 11.0.400.15 dlp-reaction: no-action x-originating-ip: [10.239.127.40] Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 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: <20190315011347.7NmOlhZnJLfXLooBy7DSysdbQLxGiqr2u6a6BuVePTQ@z> > -----Original Message----- > From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Stephen Hemminger > Sent: Friday, March 15, 2019 12:21 AM > 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 maxi= mum > (or zero length). This is safer than silently truncating which is what ha= ppens 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: Qi Zhang