* [dpdk-dev] [PATCH v3] ethdev: check for invalid device name
2019-03-14 16:20 [dpdk-dev] [PATCH v3] ethdev: check for invalid device name Stephen Hemminger
@ 2019-03-14 16:20 ` Stephen Hemminger
2019-03-15 1:13 ` Zhang, Qi Z
` (2 subsequent siblings)
3 siblings, 0 replies; 12+ messages in thread
From: Stephen Hemminger @ 2019-03-14 16:20 UTC (permalink / raw)
To: dev; +Cc: Stephen Hemminger
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.
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Acked-by: Andrew Rybchenko <arybchenko@solarflare.com>
---
v3 -- fix whitespace issue
lib/librte_ethdev/rte_ethdev.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/lib/librte_ethdev/rte_ethdev.c b/lib/librte_ethdev/rte_ethdev.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 = NULL;
+ size_t name_len;
+
+ name_len = strnlen(name, RTE_ETH_NAME_MAX_LEN);
+ if (name_len == 0) {
+ RTE_ETHDEV_LOG(ERR, "Zero length Ethernet device name\n");
+ return NULL;
+ }
+
+ if (name_len >= RTE_ETH_NAME_MAX_LEN) {
+ RTE_ETHDEV_LOG(ERR, "Ethernet device name is too long\n");
+ return NULL;
+ }
rte_eth_dev_shared_data_prepare();
--
2.17.1
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [dpdk-dev] [PATCH v3] ethdev: check for invalid device name
2019-03-14 16:20 [dpdk-dev] [PATCH v3] ethdev: check for invalid device name Stephen Hemminger
2019-03-14 16:20 ` Stephen Hemminger
@ 2019-03-15 1:13 ` Zhang, Qi Z
2019-03-15 1:13 ` Zhang, Qi Z
2019-03-21 18:51 ` Ferruh Yigit
2019-03-18 12:32 ` Ali Alnubani
2019-03-20 14:28 ` Ferruh Yigit
3 siblings, 2 replies; 12+ messages in thread
From: Zhang, Qi Z @ 2019-03-15 1:13 UTC (permalink / raw)
To: 20190311181544.15646-1-stephen, dev
> -----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 <stephen@networkplumber.org>
> Subject: [dpdk-dev] [PATCH v3] ethdev: check for invalid device name
>
> 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.
>
> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
> Acked-by: Andrew Rybchenko <arybchenko@solarflare.com>
> ---
> v3 -- fix whitespace issue
>
> lib/librte_ethdev/rte_ethdev.c | 12 ++++++++++++
> 1 file changed, 12 insertions(+)
>
> diff --git a/lib/librte_ethdev/rte_ethdev.c b/lib/librte_ethdev/rte_ethdev.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 = NULL;
> + size_t name_len;
> +
> + name_len = strnlen(name, RTE_ETH_NAME_MAX_LEN);
> + if (name_len == 0) {
> + RTE_ETHDEV_LOG(ERR, "Zero length Ethernet device name\n");
> + return NULL;
> + }
> +
> + if (name_len >= RTE_ETH_NAME_MAX_LEN) {
> + RTE_ETHDEV_LOG(ERR, "Ethernet device name is too long\n");
> + return NULL;
> + }
>
> rte_eth_dev_shared_data_prepare();
>
> --
> 2.17.1
Acked-by: Qi Zhang <qi.z.zhang@intel.com>
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [dpdk-dev] [PATCH v3] ethdev: check for invalid device name
2019-03-15 1:13 ` Zhang, Qi Z
@ 2019-03-15 1:13 ` Zhang, Qi Z
2019-03-21 18:51 ` Ferruh Yigit
1 sibling, 0 replies; 12+ messages in thread
From: Zhang, Qi Z @ 2019-03-15 1:13 UTC (permalink / raw)
To: 20190311181544.15646-1-stephen, dev
> -----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 <stephen@networkplumber.org>
> Subject: [dpdk-dev] [PATCH v3] ethdev: check for invalid device name
>
> 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.
>
> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
> Acked-by: Andrew Rybchenko <arybchenko@solarflare.com>
> ---
> v3 -- fix whitespace issue
>
> lib/librte_ethdev/rte_ethdev.c | 12 ++++++++++++
> 1 file changed, 12 insertions(+)
>
> diff --git a/lib/librte_ethdev/rte_ethdev.c b/lib/librte_ethdev/rte_ethdev.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 = NULL;
> + size_t name_len;
> +
> + name_len = strnlen(name, RTE_ETH_NAME_MAX_LEN);
> + if (name_len == 0) {
> + RTE_ETHDEV_LOG(ERR, "Zero length Ethernet device name\n");
> + return NULL;
> + }
> +
> + if (name_len >= RTE_ETH_NAME_MAX_LEN) {
> + RTE_ETHDEV_LOG(ERR, "Ethernet device name is too long\n");
> + return NULL;
> + }
>
> rte_eth_dev_shared_data_prepare();
>
> --
> 2.17.1
Acked-by: Qi Zhang <qi.z.zhang@intel.com>
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [dpdk-dev] [PATCH v3] ethdev: check for invalid device name
2019-03-15 1:13 ` Zhang, Qi Z
2019-03-15 1:13 ` Zhang, Qi Z
@ 2019-03-21 18:51 ` Ferruh Yigit
2019-03-21 18:51 ` Ferruh Yigit
1 sibling, 1 reply; 12+ messages in thread
From: Ferruh Yigit @ 2019-03-21 18:51 UTC (permalink / raw)
To: Zhang, Qi Z, 20190311181544.15646-1-stephen, dev
On 3/15/2019 1:13 AM, Zhang, Qi Z wrote:
>
>
>> -----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 <stephen@networkplumber.org>
>> Subject: [dpdk-dev] [PATCH v3] ethdev: check for invalid device name
>>
>> 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.
>>
>> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
>> Acked-by: Andrew Rybchenko <arybchenko@solarflare.com>
>
> Acked-by: Qi Zhang <qi.z.zhang@intel.com>
>
Applied to dpdk-next-net/master, thanks.
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [dpdk-dev] [PATCH v3] ethdev: check for invalid device name
2019-03-21 18:51 ` Ferruh Yigit
@ 2019-03-21 18:51 ` Ferruh Yigit
0 siblings, 0 replies; 12+ messages in thread
From: Ferruh Yigit @ 2019-03-21 18:51 UTC (permalink / raw)
To: Zhang, Qi Z, 20190311181544.15646-1-stephen, dev
On 3/15/2019 1:13 AM, Zhang, Qi Z wrote:
>
>
>> -----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 <stephen@networkplumber.org>
>> Subject: [dpdk-dev] [PATCH v3] ethdev: check for invalid device name
>>
>> 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.
>>
>> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
>> Acked-by: Andrew Rybchenko <arybchenko@solarflare.com>
>
> Acked-by: Qi Zhang <qi.z.zhang@intel.com>
>
Applied to dpdk-next-net/master, thanks.
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [dpdk-dev] [PATCH v3] ethdev: check for invalid device name
2019-03-14 16:20 [dpdk-dev] [PATCH v3] ethdev: check for invalid device name Stephen Hemminger
2019-03-14 16:20 ` Stephen Hemminger
2019-03-15 1:13 ` Zhang, Qi Z
@ 2019-03-18 12:32 ` Ali Alnubani
2019-03-18 12:32 ` Ali Alnubani
2019-03-20 14:28 ` Ferruh Yigit
3 siblings, 1 reply; 12+ messages in thread
From: Ali Alnubani @ 2019-03-18 12:32 UTC (permalink / raw)
To: 20190311181544.15646-1-stephen, dev
> -----Original Message-----
> From: dev <dev-bounces@dpdk.org> On Behalf Of Stephen Hemminger
> Sent: Thursday, March 14, 2019 6:21 PM
> To: dev@dpdk.org
> Cc: Stephen Hemminger <stephen@networkplumber.org>
> Subject: [dpdk-dev] [PATCH v3] ethdev: check for invalid device name
>
> 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.
>
> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
> Acked-by: Andrew Rybchenko <arybchenko@solarflare.com>
> ---
> v3 -- fix whitespace issue
>
> lib/librte_ethdev/rte_ethdev.c | 12 ++++++++++++
> 1 file changed, 12 insertions(+)
>
> diff --git a/lib/librte_ethdev/rte_ethdev.c b/lib/librte_ethdev/rte_ethdev.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 = NULL;
> + size_t name_len;
> +
> + name_len = strnlen(name, RTE_ETH_NAME_MAX_LEN);
> + if (name_len == 0) {
> + RTE_ETHDEV_LOG(ERR, "Zero length Ethernet device
> name\n");
> + return NULL;
> + }
> +
> + if (name_len >= RTE_ETH_NAME_MAX_LEN) {
> + RTE_ETHDEV_LOG(ERR, "Ethernet device name is too
> long\n");
> + return NULL;
> + }
>
> rte_eth_dev_shared_data_prepare();
>
> --
> 2.17.1
Acked-by: Ali Alnubani <alialnu@mellanox.com>
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [dpdk-dev] [PATCH v3] ethdev: check for invalid device name
2019-03-18 12:32 ` Ali Alnubani
@ 2019-03-18 12:32 ` Ali Alnubani
0 siblings, 0 replies; 12+ messages in thread
From: Ali Alnubani @ 2019-03-18 12:32 UTC (permalink / raw)
To: 20190311181544.15646-1-stephen, dev
> -----Original Message-----
> From: dev <dev-bounces@dpdk.org> On Behalf Of Stephen Hemminger
> Sent: Thursday, March 14, 2019 6:21 PM
> To: dev@dpdk.org
> Cc: Stephen Hemminger <stephen@networkplumber.org>
> Subject: [dpdk-dev] [PATCH v3] ethdev: check for invalid device name
>
> 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.
>
> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
> Acked-by: Andrew Rybchenko <arybchenko@solarflare.com>
> ---
> v3 -- fix whitespace issue
>
> lib/librte_ethdev/rte_ethdev.c | 12 ++++++++++++
> 1 file changed, 12 insertions(+)
>
> diff --git a/lib/librte_ethdev/rte_ethdev.c b/lib/librte_ethdev/rte_ethdev.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 = NULL;
> + size_t name_len;
> +
> + name_len = strnlen(name, RTE_ETH_NAME_MAX_LEN);
> + if (name_len == 0) {
> + RTE_ETHDEV_LOG(ERR, "Zero length Ethernet device
> name\n");
> + return NULL;
> + }
> +
> + if (name_len >= RTE_ETH_NAME_MAX_LEN) {
> + RTE_ETHDEV_LOG(ERR, "Ethernet device name is too
> long\n");
> + return NULL;
> + }
>
> rte_eth_dev_shared_data_prepare();
>
> --
> 2.17.1
Acked-by: Ali Alnubani <alialnu@mellanox.com>
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [dpdk-dev] [PATCH v3] ethdev: check for invalid device name
2019-03-14 16:20 [dpdk-dev] [PATCH v3] ethdev: check for invalid device name Stephen Hemminger
` (2 preceding siblings ...)
2019-03-18 12:32 ` Ali Alnubani
@ 2019-03-20 14:28 ` Ferruh Yigit
2019-03-20 14:28 ` Ferruh Yigit
2019-03-20 17:52 ` Stephen Hemminger
3 siblings, 2 replies; 12+ messages in thread
From: Ferruh Yigit @ 2019-03-20 14:28 UTC (permalink / raw)
To: 20190311181544.15646-1-stephen, dev; +Cc: Stephen Hemminger, Andrew Rybchenko
On 3/14/2019 4:20 PM, Stephen Hemminger wrote:
> 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.
>
> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
> Acked-by: Andrew Rybchenko <arybchenko@solarflare.com>
> ---
> v3 -- fix whitespace issue
>
> lib/librte_ethdev/rte_ethdev.c | 12 ++++++++++++
> 1 file changed, 12 insertions(+)
>
> diff --git a/lib/librte_ethdev/rte_ethdev.c b/lib/librte_ethdev/rte_ethdev.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 = NULL;
> + size_t name_len;
> +
> + name_len = strnlen(name, RTE_ETH_NAME_MAX_LEN);
'strlen' does not check against NULL pointer and it will crash if NULL provided.
This is internal API, so the input is not completely out of our control but
still as an API if we need to check zero length, shouldn't we check for NULL
pointer as well?
> + if (name_len == 0) {
> + RTE_ETHDEV_LOG(ERR, "Zero length Ethernet device name\n");
> + return NULL;
> + }
> +
> + if (name_len >= RTE_ETH_NAME_MAX_LEN) {
> + RTE_ETHDEV_LOG(ERR, "Ethernet device name is too long\n");
> + return NULL;
> + }
>
> rte_eth_dev_shared_data_prepare();
>
>
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [dpdk-dev] [PATCH v3] ethdev: check for invalid device name
2019-03-20 14:28 ` Ferruh Yigit
@ 2019-03-20 14:28 ` Ferruh Yigit
2019-03-20 17:52 ` Stephen Hemminger
1 sibling, 0 replies; 12+ messages in thread
From: Ferruh Yigit @ 2019-03-20 14:28 UTC (permalink / raw)
To: 20190311181544.15646-1-stephen, dev; +Cc: Stephen Hemminger, Andrew Rybchenko
On 3/14/2019 4:20 PM, Stephen Hemminger wrote:
> 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.
>
> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
> Acked-by: Andrew Rybchenko <arybchenko@solarflare.com>
> ---
> v3 -- fix whitespace issue
>
> lib/librte_ethdev/rte_ethdev.c | 12 ++++++++++++
> 1 file changed, 12 insertions(+)
>
> diff --git a/lib/librte_ethdev/rte_ethdev.c b/lib/librte_ethdev/rte_ethdev.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 = NULL;
> + size_t name_len;
> +
> + name_len = strnlen(name, RTE_ETH_NAME_MAX_LEN);
'strlen' does not check against NULL pointer and it will crash if NULL provided.
This is internal API, so the input is not completely out of our control but
still as an API if we need to check zero length, shouldn't we check for NULL
pointer as well?
> + if (name_len == 0) {
> + RTE_ETHDEV_LOG(ERR, "Zero length Ethernet device name\n");
> + return NULL;
> + }
> +
> + if (name_len >= RTE_ETH_NAME_MAX_LEN) {
> + RTE_ETHDEV_LOG(ERR, "Ethernet device name is too long\n");
> + return NULL;
> + }
>
> rte_eth_dev_shared_data_prepare();
>
>
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [dpdk-dev] [PATCH v3] ethdev: check for invalid device name
2019-03-20 14:28 ` Ferruh Yigit
2019-03-20 14:28 ` Ferruh Yigit
@ 2019-03-20 17:52 ` Stephen Hemminger
2019-03-20 17:52 ` Stephen Hemminger
1 sibling, 1 reply; 12+ messages in thread
From: Stephen Hemminger @ 2019-03-20 17:52 UTC (permalink / raw)
To: Ferruh Yigit; +Cc: 20190311181544.15646-1-stephen, dev, Andrew Rybchenko
On Wed, 20 Mar 2019 14:28:22 +0000
Ferruh Yigit <ferruh.yigit@intel.com> wrote:
> On 3/14/2019 4:20 PM, Stephen Hemminger wrote:
> > 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.
> >
> > Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
> > Acked-by: Andrew Rybchenko <arybchenko@solarflare.com>
> > ---
> > v3 -- fix whitespace issue
> >
> > lib/librte_ethdev/rte_ethdev.c | 12 ++++++++++++
> > 1 file changed, 12 insertions(+)
> >
> > diff --git a/lib/librte_ethdev/rte_ethdev.c b/lib/librte_ethdev/rte_ethdev.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 = NULL;
> > + size_t name_len;
> > +
> > + name_len = strnlen(name, RTE_ETH_NAME_MAX_LEN);
>
> 'strlen' does not check against NULL pointer and it will crash if NULL provided.
>
> This is internal API, so the input is not completely out of our control but
> still as an API if we need to check zero length, shouldn't we check for NULL
> pointer as well?
Maybe, but none of the other DPDK API's check for NULL in name fields.
Probably best to just crash.
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [dpdk-dev] [PATCH v3] ethdev: check for invalid device name
2019-03-20 17:52 ` Stephen Hemminger
@ 2019-03-20 17:52 ` Stephen Hemminger
0 siblings, 0 replies; 12+ messages in thread
From: Stephen Hemminger @ 2019-03-20 17:52 UTC (permalink / raw)
To: Ferruh Yigit; +Cc: 20190311181544.15646-1-stephen, dev, Andrew Rybchenko
On Wed, 20 Mar 2019 14:28:22 +0000
Ferruh Yigit <ferruh.yigit@intel.com> wrote:
> On 3/14/2019 4:20 PM, Stephen Hemminger wrote:
> > 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.
> >
> > Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
> > Acked-by: Andrew Rybchenko <arybchenko@solarflare.com>
> > ---
> > v3 -- fix whitespace issue
> >
> > lib/librte_ethdev/rte_ethdev.c | 12 ++++++++++++
> > 1 file changed, 12 insertions(+)
> >
> > diff --git a/lib/librte_ethdev/rte_ethdev.c b/lib/librte_ethdev/rte_ethdev.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 = NULL;
> > + size_t name_len;
> > +
> > + name_len = strnlen(name, RTE_ETH_NAME_MAX_LEN);
>
> 'strlen' does not check against NULL pointer and it will crash if NULL provided.
>
> This is internal API, so the input is not completely out of our control but
> still as an API if we need to check zero length, shouldn't we check for NULL
> pointer as well?
Maybe, but none of the other DPDK API's check for NULL in name fields.
Probably best to just crash.
^ permalink raw reply [flat|nested] 12+ messages in thread