netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Brian Haley <brian.haley@hp.com>
To: Alexey Dobriyan <adobriyan@gmail.com>
Cc: David Miller <davem@davemloft.net>,
	containers <containers@lists.osdl.org>,
	netdev@vger.kernel.org
Subject: Re: [Devel] [PATCH 1/2] netns: fix NULL-dereference in dev_net()
Date: Thu, 14 Aug 2008 16:01:34 -0400	[thread overview]
Message-ID: <48A48F1E.8050103@hp.com> (raw)
In-Reply-To: <20080814195537.GA8214@martell.zuzino.mipt.ru>

Alexey Dobriyan wrote:
> On Thu, Aug 14, 2008 at 03:27:25PM -0400, Brian Haley wrote:
>> Change dev_net() to handle a NULL argument - return &init_net instead.
> 
>> --- a/include/linux/netdevice.h
>> +++ b/include/linux/netdevice.h
>> @@ -781,10 +781,10 @@ static inline
>>  struct net *dev_net(const struct net_device *dev)
>>  {
>>  #ifdef CONFIG_NET_NS
>> -	return dev->nd_net;
>> -#else
>> -	return &init_net;
>> +	if (dev)
>> +		return dev->nd_net;
>>  #endif
>> +	return &init_net;
>>  }
> 
> This is ugly and wrong.
> 
> The only assymetry between init_net and dynamically created netns is
> that some data structures are created only when init_net is initialized
> like some kmem caches and so on.
> 
> And some sysctls that some people may ban in netns.
> 
> Modulo that, init_net is no different from the rest.

So would you rather have all the callers that aren't net-namespace aware 
pass &init_net?  That seemed like a worse solution to me.

-Brian


  reply	other threads:[~2008-08-14 20:01 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-08-14 19:27 [PATCH 1/2] netns: fix NULL-dereference in dev_net() Brian Haley
2008-08-14 19:55 ` [Devel] " Alexey Dobriyan
2008-08-14 20:01   ` Brian Haley [this message]
2008-08-14 20:20 ` Denis V. Lunev
2008-08-14 20:29   ` Brian Haley
2008-08-16 21:30 ` Daniel Lezcano
2008-08-17 22:34   ` 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=48A48F1E.8050103@hp.com \
    --to=brian.haley@hp.com \
    --cc=adobriyan@gmail.com \
    --cc=containers@lists.osdl.org \
    --cc=davem@davemloft.net \
    --cc=netdev@vger.kernel.org \
    /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).