From: Octavian Purdila <opurdila@ixiacom•com>
To: Daniel Lezcano <daniel.lezcano@free•fr>
Cc: Linux Netdev List <netdev@vger•kernel.org>
Subject: Re: dev_get_valid_name buggy with hash collision
Date: Wed, 19 May 2010 20:05:49 +0300 [thread overview]
Message-ID: <201005192005.49459.opurdila@ixiacom.com> (raw)
In-Reply-To: <4BF2AA68.5090008@free.fr>
On Tuesday 18 May 2010 17:55:36 you wrote:
> >> if (!dev_valid_name(name))
> >> return -EINVAL;
> >>
> >> if (fmt&& strchr(name, '%'))
> >> - return __dev_alloc_name(net, name, buf);
> >> + return dev_alloc_name(dev, name);
> >> else if (__dev_get_by_name(net, name))
> >> return -EEXIST;
> >> - else if (buf != name)
> >> - strlcpy(buf, name, IFNAMSIZ);
> >> + else if (strncmp(dev->name, name, IFNAMSIZ))
> >> + strlcpy(dev->name, name, IFNAMSIZ);
> >
> > Why do the strncmp, can't we preserve the (buf != name) condition
>
> The 'buf' parameter is no longer passed to the function. We have the
> 'dev' and the 'newname' parameters.
> The pointer test was just to check 'dev_get_valid_name' was called from
> the 'register_netdevice' function context with 'dev_get_valid_name(net,
> dev->name, dev->name, 0)'. Comparing the strings is valid in this case.
>
> Otherwise dev_get_valid_name is called from:
>
> * "dev_change_net_namespace" with "dev%d" or "ifname" specified
> within the netlink message. Both are different pointers, the first will
> fall in the "if (fmt && strchr(name, '%'))".
>
> * "dev_change_name", where the pointers are different and the strings
> are different.
>
True, but we why not use "if (dev->name !=name)" instead of strncmp? It should
yield the same results and it is lighter then full strncmp.
next prev parent reply other threads:[~2010-05-19 17:07 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-05-18 10:17 dev_get_valid_name buggy with hash collision Daniel Lezcano
2010-05-18 12:29 ` Octavian Purdila
2010-05-18 14:55 ` Daniel Lezcano
2010-05-19 17:05 ` Octavian Purdila [this message]
2010-05-19 19:39 ` Daniel Lezcano
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=201005192005.49459.opurdila@ixiacom.com \
--to=opurdila@ixiacom$(echo .)com \
--cc=daniel.lezcano@free$(echo .)fr \
--cc=netdev@vger$(echo .)kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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