From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by dpdk.org (Postfix) with ESMTP id 569FF3572 for ; Wed, 13 Mar 2019 13:52:54 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 13 Mar 2019 05:52:53 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.58,474,1544515200"; d="scan'208";a="131288414" Received: from fmsmsx105.amr.corp.intel.com ([10.18.124.203]) by fmsmga008.fm.intel.com with ESMTP; 13 Mar 2019 05:52:52 -0700 Received: from FMSMSX109.amr.corp.intel.com (10.18.116.9) by FMSMSX105.amr.corp.intel.com (10.18.124.203) with Microsoft SMTP Server (TLS) id 14.3.408.0; Wed, 13 Mar 2019 05:52:52 -0700 Received: from shsmsx101.ccr.corp.intel.com (10.239.4.153) by fmsmsx109.amr.corp.intel.com (10.18.116.9) with Microsoft SMTP Server (TLS) id 14.3.408.0; Wed, 13 Mar 2019 05:52:52 -0700 Received: from shsmsx103.ccr.corp.intel.com ([169.254.4.134]) by SHSMSX101.ccr.corp.intel.com ([169.254.1.158]) with mapi id 14.03.0415.000; Wed, 13 Mar 2019 20:52:50 +0800 From: "Zhang, Qi Z" To: Stephen Hemminger , "dev@dpdk.org" Thread-Topic: [dpdk-dev] [PATCH] ethdev: check for invalid device name Thread-Index: AQHU2DaADbRsMlE2skqXgTAnwfRHKaYJhVhQ Date: Wed, 13 Mar 2019 12:52:50 +0000 Message-ID: <039ED4275CED7440929022BC67E706115334BE52@SHSMSX103.ccr.corp.intel.com> References: <20190311181544.15646-1-stephen@networkplumber.org> In-Reply-To: <20190311181544.15646-1-stephen@networkplumber.org> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiMzQwMzI1NzYtYTc4OS00ZTViLTlkYjAtZDA0NWVkNzAyYmExIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjEwLjE4MDQuNDkiLCJUcnVzdGVkTGFiZWxIYXNoIjoiTlhMNk56S3FHZG1jVnBvU3ZGS1IzWHdwTG9WVlpWMG5sV3V3R3I4bG9iaEdRSG1MTVJJckNLTFNhOCtaQXczdiJ9 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="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dpdk-dev] [PATCH] 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: Wed, 13 Mar 2019 12:52:54 -0000 HI > -----Original Message----- > From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Stephen Hemminger > Sent: Tuesday, March 12, 2019 2:16 AM > To: dev@dpdk.org > Cc: Stephen Hemminger > Subject: [dpdk-dev] [PATCH] 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 > --- > v1 - previously sent as RFC >=20 > lib/librte_ethdev/rte_ethdev.c | 10 ++++++++++ > 1 file changed, 10 insertions(+) >=20 > diff --git a/lib/librte_ethdev/rte_ethdev.c b/lib/librte_ethdev/rte_ethde= v.c > index 85c1794968dd..0b81980ff71c 100644 > --- a/lib/librte_ethdev/rte_ethdev.c > +++ b/lib/librte_ethdev/rte_ethdev.c > @@ -439,6 +439,16 @@ rte_eth_dev_allocate(const char *name) > uint16_t port_id; > struct rte_eth_dev *eth_dev =3D NULL; >=20 > + if (*name) { Is above check same as "strlen(name) =3D=3D 0"? > + RTE_ETHDEV_LOG(ERR, "Zero length Ethernet device name\n"); > + return NULL; > + } > + > + if (strnlen(name, RTE_ETH_NAME_MAX_LEN) >=3D > RTE_ETH_NAME_MAX_LEN) { > + RTE_ETHDEV_LOG(ERR, "Ethernet device name is too long\n"); > + return NULL; > + } > + > rte_eth_dev_shared_data_prepare(); >=20 > /* Synchronize port creation between primary and secondary threads. */ > -- > 2.17.1