public inbox for netdev@vger.kernel.org 
 help / color / mirror / Atom feed
From: ebiederm@xmission•com (Eric W. Biederman)
To: David Miller <davem@davemloft•net>
Cc: eric.dumazet@gmail•com, xemul@parallels•com,
	sjur.brandeland@stericsson•com, levinsasha928@gmail•com,
	netdev@vger•kernel.org, linux-kernel@vger•kernel.org,
	davej@redhat•com, sjurbren@gmail•com
Subject: [PATCH 1/2] netns: Fail conspicously if someone uses net_generic at an inappropriate time.
Date: Thu, 26 Jan 2012 16:02:55 -0800	[thread overview]
Message-ID: <m1ehumc8r4.fsf_-_@fess.ebiederm.org> (raw)
In-Reply-To: <20120126.180754.679593869814492219.davem@davemloft.net> (David Miller's message of "Thu, 26 Jan 2012 18:07:54 -0500 (EST)")


By definition net_generic should never be called when it can return
NULL.  Fail conspicously with a BUG_ON to make it clear when people mess
up that a NULL return should never happen.

Recently there was a bug in the CAIF subsystem where it was registered
with register_pernet_device instead of register_pernet_subsys.  It was
erroneously concluded that net_generic could validly return NULL and
that net_assign_generic was buggy (when it was just inefficient).
Hopefully this BUG_ON will prevent people to coming to similar erroneous
conclusions in the futrue.

Signed-off-by: Eric W. Biederman <ebiederm@xmission•com>
---
 include/net/netns/generic.h |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/include/net/netns/generic.h b/include/net/netns/generic.h
index 3419bf5..d55f434 100644
--- a/include/net/netns/generic.h
+++ b/include/net/netns/generic.h
@@ -41,6 +41,7 @@ static inline void *net_generic(const struct net *net, int id)
 	ptr = ng->ptr[id - 1];
 	rcu_read_unlock();
 
+	BUG_ON(!ptr);
 	return ptr;
 }
 #endif
-- 
1.7.2.5

  parent reply	other threads:[~2012-01-27  0:02 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-01-24  7:30 [PATCH] net: caif: Don't act on notification for non-caif devices Sasha Levin
2012-01-24 10:52 ` Sjur Brændeland
2012-01-24 14:49   ` Sasha Levin
2012-01-24 15:06     ` Sjur Brændeland
2012-01-24 15:23       ` Sasha Levin
     [not found]         ` <1327444045-1033-1-git-send-email-sjur.brandeland@stericsson.com>
2012-01-25 16:13           ` [PATCH net] caif: Fix crash due to uninitialized net name-space Sasha Levin
2012-01-25 20:33             ` Sjur Brændeland
2012-01-26  6:14               ` Eric Dumazet
2012-01-26 10:41               ` [PATCH] netns: fix net_alloc_generic() Eric Dumazet
2012-01-26 10:44                 ` Pavel Emelyanov
2012-01-26 10:51                   ` Eric Dumazet
2012-01-26 22:57                     ` Eric W. Biederman
2012-01-26 23:07                       ` David Miller
2012-01-26 23:57                         ` Eric W. Biederman
2012-01-27  0:02                         ` Eric W. Biederman [this message]
2012-01-27  0:04                           ` [PATCH 2/2] net caif: Register properly as a pernet subsystem Eric W. Biederman
2012-01-27 13:24                             ` Sasha Levin
2012-01-27 14:48                               ` Sjur BRENDELAND
2012-01-28  2:07                             ` David Miller
2012-01-28  2:07                           ` [PATCH 1/2] netns: Fail conspicously if someone uses net_generic at an inappropriate time David Miller
2012-01-27  6:09                       ` [PATCH] netns: fix net_alloc_generic() Eric Dumazet
2012-01-27  6:54                         ` Eric W. Biederman
2012-01-27  7:07                           ` Eric Dumazet
2012-01-26 14:40                 ` Sasha Levin
2012-01-26 18:37                 ` 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=m1ehumc8r4.fsf_-_@fess.ebiederm.org \
    --to=ebiederm@xmission$(echo .)com \
    --cc=davej@redhat$(echo .)com \
    --cc=davem@davemloft$(echo .)net \
    --cc=eric.dumazet@gmail$(echo .)com \
    --cc=levinsasha928@gmail$(echo .)com \
    --cc=linux-kernel@vger$(echo .)kernel.org \
    --cc=netdev@vger$(echo .)kernel.org \
    --cc=sjur.brandeland@stericsson$(echo .)com \
    --cc=sjurbren@gmail$(echo .)com \
    --cc=xemul@parallels$(echo .)com \
    /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