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: Tue, 18 May 2010 15:29:37 +0300 [thread overview]
Message-ID: <201005181529.37420.opurdila@ixiacom.com> (raw)
In-Reply-To: <4BF26926.4070507@free.fr>
On Tuesday 18 May 2010 13:17:10 you wrote:
> the commit:
>
> commit d90310243fd750240755e217c5faa13e24f41536
> Author: Octavian Purdila <opurdila@ixiacom•com>
> Date: Wed Nov 18 02:36:59 2009 +0000
>
> net: device name allocation cleanups
>
> introduced a bug when there is a hash collision making impossible to
> rename a device with eth%d
<snip>
Hi Daniel,
Thanks for the detailed explanation !
>
> IMO, the bug is to pass the 'dev->name' parameter to __dev_alloc_name
> directly instead of a temporary name.
I agree.
>
> The patch in attachment fix the problem but I am not sure we shouldn't
> go further and do more cleanup around this bug, so you may consider it
> as a RFC more than a fix. If it is acceptable, I will send it as a patch
> against net-2.6.
>
The patch looks good to me, just one doubt here:
>--- net-2.6.orig/net/core/dev.c
>+++ net-2.6/net/core/dev.c
>@@ -936,18 +936,22 @@ int dev_alloc_name(struct net_device *de
> }
> EXPORT_SYMBOL(dev_alloc_name);
>
>-static int dev_get_valid_name(struct net *net, const char *name, char *buf,
>- bool fmt)
>+static int dev_get_valid_name(struct net_device *dev, const char *name, bool
fmt)
> {
>+ struct net *net;
>+
>+ BUG_ON(!dev_net(dev));
>+ net = dev_net(dev);
>+
> 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?
Thanks,
tavi
next prev parent reply other threads:[~2010-05-18 12:29 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 [this message]
2010-05-18 14:55 ` Daniel Lezcano
2010-05-19 17:05 ` Octavian Purdila
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=201005181529.37420.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