From: Brian Haley <brian.haley@hp.com>
To: David Miller <davem@davemloft.net>
Cc: Ben Hutchings <bhutchings@solarflare.com>,
Pavel Emelyanov <xemul@parallels.com>,
Eric Dumazet <eric.dumazet@gmail.com>,
"netdev@vger.kernel.org" <netdev@vger.kernel.org>
Subject: Re: [PATCH net-next] sockopt: Change getsockopt() of SO_BINDTODEVICE to return an interface name
Date: Thu, 08 Nov 2012 08:36:02 -0700 [thread overview]
Message-ID: <509BD162.1000205@hp.com> (raw)
In-Reply-To: <50988BAE.6020602@hp.com>
On 11/05/2012 09:01 PM, Brian Haley wrote:
>>>>> + rcu_read_lock();
>>>>> + dev = dev_get_by_index_rcu(net, sk->sk_bound_dev_if);
>>>>> + if (dev)
>>>>> + strcpy(devname, dev->name);
>>>>
>>>> This still races with the device name change, potentially providing
>>>> a name which never existed in the system, doesn't it?
>>>
>>> My only argument here is that SIOCGIFNAME has had this same code
>>> forever, and
>>> noone has ever complained about that returning a garbled name. Even
>>> dev_get_by_name() only holds an rcu lock when doing a strncmp().
>>>
>>> We'd need to audit the whole kernel to catch all the places where we
>>> potentially
>>> look at dev->name while it could change. Is it really worth it?
>>
>> A net device name can't be changed while the device is up, or while
>> another task holds the RTNL lock. I think that covers almost all uses.
>> I don't know whether it's worth going out to look for exceptions, but we
>> might as well fix the cases we know about.
>
> So do you think we can fix these corner cases later and get the API
> right first?
Hi Dave,
I noticed this isn't in patchwork anymore. Is it possible to get this
in and then work on the other issue in a separate patch since it's not
just this code that has this problem?
Of course I'm still not convinced that extra check is necessary (but
I'll do it to make others happy) because if you do a setsockopt("eth0"),
all you care is that a getsockopt() returns "eth0" - if it returns
anything else, eth0_renamed, eth0_foo, etc you'll notice it's not the
same and take action. And the fact that the name can't change when UP
means the odds are small it can happen anyways.
Thanks,
-Brian
next prev parent reply other threads:[~2012-11-08 15:36 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-10-31 20:06 [PATCH net-next] sockopt: Change getsockopt() of SO_BINDTODEVICE to return an interface name Brian Haley
2012-10-31 20:47 ` Andi Kleen
2012-11-01 14:02 ` Brian Haley
2012-11-01 14:52 ` David Miller
2012-11-02 9:36 ` Pavel Emelyanov
2012-11-02 10:23 ` Eric Dumazet
2012-11-02 15:02 ` Brian Haley
2012-11-02 23:34 ` Ben Hutchings
2012-11-06 4:01 ` Brian Haley
2012-11-08 0:23 ` Ben Hutchings
2012-11-08 15:36 ` Brian Haley [this message]
2012-11-08 20:02 ` David Miller
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=509BD162.1000205@hp.com \
--to=brian.haley@hp.com \
--cc=bhutchings@solarflare.com \
--cc=davem@davemloft.net \
--cc=eric.dumazet@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=xemul@parallels.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.