mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Michael S. Tsirkin" <mst@dev.mellanox.co.il>
To: "Michael S. Tsirkin" <mst@dev.mellanox.co.il>
Cc: Alexey Kuznetsov <kuznet@ms2.inr.ac.ru>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	netdev@vger.kernel.org, general@lists.openfabrics.org,
	Roland Dreier <rolandd@cisco.com>
Subject: Re: dst_ifdown breaks infiniband?
Date: Sun, 18 Mar 2007 23:20:46 +0200	[thread overview]
Message-ID: <20070318212046.GI11078@mellanox.co.il> (raw)
In-Reply-To: <20070318210616.GG11078@mellanox.co.il>

> Quoting Michael S. Tsirkin <mst@dev.mellanox.co.il>:
> Subject: Re: dst_ifdown breaks infiniband?
> 
> > Quoting Michael S. Tsirkin <mst@dev.mellanox.co.il>:
> > Subject: Re: dst_ifdown breaks infiniband?
> > 
> > Quoting Alexey Kuznetsov <kuznet@ms2.inr.ac.ru>:
> > Subject: Re: dst_ifdown breaks infiniband?
> > > > Can dst->neighbour be changed to point to NULL instead, and the neighbour
> > > > released?
> > > 
> > > It should be cleared and we should be sure it will not be destroyed
> > > before quiescent state.
> > > 
> > > Seems, this is the only correct solution, but to do this we have
> > > to audit all the places where dst->neighbour is dereferenced for
> > > RCU safety.
> > > 
> > > Actually, it is very good you caught this eventually, the bug was
> > > so _disgusting_ that it was "forgotten" all the time, waiting for
> > > someone who will point out that the king is naked. :-)
> > 
> > Actually that might not be too bad:
> > $grep -rIi 'dst->neighbour' net/ | wc -l
> > 36
> > 
> > I'll try to do it.
> 
> Here's the list. Looks OK to me. What do you think?
> 

So Alexey, how does the following (lightly tested) patch look?
Is this what you had in mind?

-----------------------------

Fix dst_ifdown for infiniband.

Changing dst->neighbour->dev is unsafe because neigh->parms callbacks
are set up for specific device.
We should drop the dst->neighbour reference instead.

Signed-off-by: Michael S. Tsirkin <mst@dev.mellanox.co.il>

---

diff --git a/net/core/dst.c b/net/core/dst.c
index 764bccb..27091a5 100644
--- a/net/core/dst.c
+++ b/net/core/dst.c
@@ -15,6 +15,7 @@
 #include <linux/skbuff.h>
 #include <linux/string.h>
 #include <linux/types.h>
+#include <linux/if_arp.h>
 
 #include <net/dst.h>
 
@@ -235,6 +236,8 @@ again:
 static inline void dst_ifdown(struct dst_entry *dst, struct net_device *dev,
 			      int unregister)
 {
+	struct neighbour *neigh;
+
 	if (dst->ops->ifdown)
 		dst->ops->ifdown(dst, dev, unregister);
 
@@ -245,13 +248,13 @@ static inline void dst_ifdown(struct dst_entry *dst, struct net_device *dev,
 		dst->input = dst_discard_in;
 		dst->output = dst_discard_out;
 	} else {
+		neigh = dst->neighbour;
 		dst->dev = &loopback_dev;
 		dev_hold(&loopback_dev);
 		dev_put(dev);
-		if (dst->neighbour && dst->neighbour->dev == dev) {
-			dst->neighbour->dev = &loopback_dev;
-			dev_put(dev);
-			dev_hold(&loopback_dev);
+		if (neigh && neigh->dev == dev) {
+			dst->neighbour = NULL;
+			neigh_release(neigh);
 		}
 	}
 }


-- 
MST

  reply	other threads:[~2007-03-18 21:20 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-03-18 15:55 Michael S. Tsirkin
2007-03-18 19:12 ` Alexey Kuznetsov
2007-03-18 19:46   ` Michael S. Tsirkin
2007-03-18 19:55     ` Alexey Kuznetsov
2007-03-18 20:24       ` Michael S. Tsirkin
2007-03-18 19:53   ` Michael S. Tsirkin
2007-03-18 20:18     ` Alexey Kuznetsov
2007-03-18 20:29       ` Michael S. Tsirkin
2007-03-19  9:36       ` Michael S. Tsirkin
2007-03-19  9:55         ` Michael S. Tsirkin
2007-03-19 12:05         ` Alexey Kuznetsov
2007-03-19 12:12           ` Michael S. Tsirkin
2007-03-19 12:59             ` Alexey Kuznetsov
2007-03-19 15:13               ` Michael S. Tsirkin
2007-03-19 23:20                 ` Alexey Kuznetsov
2007-03-20 16:02                   ` Michael S. Tsirkin
2007-03-20 23:34                     ` David Miller
2007-03-19 12:13           ` Michael S. Tsirkin
2007-03-18 20:25   ` Michael S. Tsirkin
2007-03-18 22:24     ` [ofa-general] " Eric W. Biederman
2007-03-18 22:36       ` Michael S. Tsirkin
2007-03-18 22:42         ` Michael S. Tsirkin
2007-03-19  0:13           ` David Miller
2007-03-19  5:19             ` Michael S. Tsirkin
2007-03-19  5:30             ` Eric W. Biederman
2007-03-19  6:13               ` David Miller
2007-03-19  9:34                 ` Alexey Kuznetsov
2007-03-19 15:10                 ` Eric W. Biederman
2007-03-19  9:24           ` Alexey Kuznetsov
2007-03-19  9:33             ` Michael S. Tsirkin
2007-03-19  9:20       ` Alexey Kuznetsov
2007-03-18 20:33   ` Michael S. Tsirkin
2007-03-18 21:06     ` Michael S. Tsirkin
2007-03-18 21:20       ` Michael S. Tsirkin [this message]
2007-03-19  5:15         ` Michael S. Tsirkin

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=20070318212046.GI11078@mellanox.co.il \
    --to=mst@dev.mellanox.co.il \
    --cc=general@lists.openfabrics.org \
    --cc=kuznet@ms2.inr.ac.ru \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=rolandd@cisco.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

all inboxes | Powered by JetHome®