DPDK patches and discussions
 help / color / mirror / Atom feed
From: Stephen Hemminger <stephen@networkplumber.org>
To: Ferruh Yigit <ferruh.yigit@intel.com>
Cc: 20190311181544.15646-1-stephen@networkplumber.org, dev@dpdk.org,
	Andrew Rybchenko <arybchenko@solarflare.com>
Subject: Re: [dpdk-dev] [PATCH v3] ethdev: check for invalid device name
Date: Wed, 20 Mar 2019 10:52:26 -0700	[thread overview]
Message-ID: <20190320105226.58f3d5fc@shemminger-XPS-13-9360> (raw)
Message-ID: <20190320175226.Xa9O4hpc4i1vgP3bt98w1Ua07fe9fSZHiHcE3-ndhPs@z> (raw)
In-Reply-To: <7fffa0cb-1bfc-1ff1-5f1d-15fff4b3ff00@intel.com>

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.

  parent reply	other threads:[~2019-03-20 17:52 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-14 16:20 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-21 18:51     ` Ferruh Yigit
2019-03-18 12:32 ` Ali Alnubani
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 [this message]
2019-03-20 17:52     ` Stephen Hemminger

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190320105226.58f3d5fc@shemminger-XPS-13-9360 \
    --to=stephen@networkplumber.org \
    --cc=20190311181544.15646-1-stephen@networkplumber.org \
    --cc=arybchenko@solarflare.com \
    --cc=dev@dpdk.org \
    --cc=ferruh.yigit@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).