netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Woodhouse <dwmw2@infradead.org>
To: David Miller <davem@davemloft.net>
Cc: sjurbren@gmail.com, netdev@vger.kernel.org
Subject: [PATCH] Fix caif BUG() with network namespaces
Date: Tue, 25 Oct 2011 09:25:21 +0200	[thread overview]
Message-ID: <1319527522.24797.10.camel@shinybook.infradead.org> (raw)
In-Reply-To: <20111024.182831.489446218871753789.davem@davemloft.net>

The caif code will register its own pernet_operations, and then register
a netdevice_notifier. Each time the netdevice_notifier is triggered,
it'll do some stuff... including a lookup of its own pernet stuff with
net_generic().

If the net_generic() call ever returns NULL, the caif code will BUG().
That doesn't seem *so* unreasonable, I suppose — it does seem like it
should never happen.

However, it *does* happen. When we clone a network namespace,
setup_net() runs through all the pernet_operations one at a time. It
gets to loopback before it gets to caif. And loopback_net_init()
registers a netdevice... while caif hasn't been initialised. So the caif
netdevice notifier triggers, and immediately goes BUG().

We could imagine a complex and overengineered solution to this generic
class of problems, but this patch takes the simple approach. It just
makes caif_device_notify() *not* go looking for its pernet data
structures if the device it's being notified about isn't a caif device
in the first place.

Cc: stable@kernel.org
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
Acked-by: Sjur Brændeland <sjur.brandeland@stericsson.com>

---
On Mon, 2011-10-24 at 18:28 -0400, David Miller wrote:
> David W., the copy that ended up in patchwork was using DOS newlines:
> http://patchwork.ozlabs.org/patch/121250/
> Click on Download "mbox" to see what I mean.
> Can you get your email configuration straightened out before
> resubmitting this patch a third time?

Sorry about that. It's not a configuration thing; just me being stupid
and using the wrong account to send. I *know* Exchange is not an email
server, and that signing emails causes QP encoding. This one should be
fine.

Having said that... in fact, email is *supposed* to have DOS newlines.
The SMTP protocol requires it. When receiving on *nix boxes, we tend to
convert CRLF to LF.

I played a little with applying the emails I sent with 'git am', and it
actually copes fine with the original Quoted-Printable email, as it
should. It *almost* copes with the base64 email, but it forgets to do
the CRLF to LF conversion. I'll look at fixing it (in the spirit of 'be
liberal in what you accept)... but of course we should also be
conservative in what we *send*, so here is (hopefully) an unencoded
version. Apologies again for the inconvenience.

/me double-checks that the signature is turned off, and the sending
account is not the Exchange one... <send>



 net/caif/caif_dev.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/net/caif/caif_dev.c b/net/caif/caif_dev.c
index 7f9ac07..47fc8f3 100644
--- a/net/caif/caif_dev.c
+++ b/net/caif/caif_dev.c
@@ -212,8 +212,7 @@ static int caif_device_notify(struct notifier_block *me, unsigned long what,
 	enum cfcnfg_phy_preference pref;
 	enum cfcnfg_phy_type phy_type;
 	struct cfcnfg *cfg;
-	struct caif_device_entry_list *caifdevs =
-	    caif_device_list(dev_net(dev));
+	struct caif_device_entry_list *caifdevs;
 
 	if (dev->type != ARPHRD_CAIF)
 		return 0;
@@ -222,6 +221,8 @@ static int caif_device_notify(struct notifier_block *me, unsigned long what,
 	if (cfg == NULL)
 		return 0;
 
+	caifdevs = caif_device_list(dev_net(dev));
+
 	switch (what) {
 	case NETDEV_REGISTER:
 		caifd = caif_device_alloc(dev);
-- 
1.7.6.4



-- 
David Woodhouse                            Open Source Technology Centre
David.Woodhouse@intel.com                              Intel Corporation

  reply	other threads:[~2011-10-25  7:25 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-10-21 20:51 caif BUG() with network namespaces Woodhouse, David
2011-10-21 21:55 ` Sjur Brændeland
2011-10-23 21:21   ` [PATCH] Fix " Woodhouse, David
2011-10-23 21:24   ` [non-quoted-printable PATCH] " Woodhouse, David
2011-10-24 15:51     ` Sjur Brændeland
2011-10-24 22:28       ` David Miller
2011-10-25  7:25         ` David Woodhouse [this message]
2011-10-25 23:22           ` [PATCH] " 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=1319527522.24797.10.camel@shinybook.infradead.org \
    --to=dwmw2@infradead.org \
    --cc=davem@davemloft.net \
    --cc=netdev@vger.kernel.org \
    --cc=sjurbren@gmail.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 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).