public inbox for linux-rdma@vger.kernel.org
 help / color / mirror / Atom feed
From: Or Gerlitz <ogerlitz-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
To: David Miller <davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org>
Cc: roland-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org,
	Shlomo Pongratz <shlomop-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>,
	linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Re: Infiniband stack allows references to freed memory
Date: Tue, 17 Apr 2012 11:02:40 +0300	[thread overview]
Message-ID: <4F8D23A0.7000109@mellanox.com> (raw)
In-Reply-To: <20120201.202128.703330634975191244.davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org>

On 2/2/2012 3:21 AM, David Miller wrote:
> From: Roland Dreier<roland-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
>
>> I'm happy to do it but I'm still not quite sure I understand what the
>> end state is.  Is it just a matter of peeking into the skb contents
>> to get at the daddr, looking up the neigh based on that and then
>> continuing to handle neighs as we do now?
>
> Right, you also will now have a reference to the neigh so you must release it.
>
>> Does that also work for ARP packets?
>
> ARP packets have no dst_entry, so would need to be handled specially right now anyways.
>
>> Are there any examples in your tree I can crib off of?
>
> grep for dst_neigh_lookup() in the net-next tree.

Hi Dave, Roland,

As was indicated over the thread @ 
http://marc.info/?t=132812805900004&r=1&w=2 the current situation can 
surely lead to races, and I'd be happy to revive it, hopefully towards 
somehow addressing the issue.From my reading through the thread, I 
understand that more or less the following paths (...) were suggested:

#1 convert ipoib to use dst_neigh_lookup instead of dst_get_neighbour_noref
#2 do some RCU-ing where we don't actually free the ipoib_neigh 
immediately, etc

Dave commented that #1 conversion step will allow to merge a change 
where dst_entry objects will not have an attached neighbour any more. 
Alternatively, IPoIB could manage a data structure where ipoib_neighs 
are looked up the packet ipv4/ipv6 header and not from the neighbour.

Performance wise, it seems that the two suggestions should introduce the 
~same overhead, since in the ipv4 case for example, from 
dst_neigh_lookup we would land in __ipv4_neigh_lookup which does a hash 
lookup and we ipoib doesn't use the neighbours any more, some data 
structure lookup (e.g hash) will be used to resolve the ipoib_neigh from 
the destination address.

Dave, as for the conversion to dst_neigh_lookup, looking on net-next, I 
see about 30 hits for dst_get_neighbour_noref vs 13 hits for 
dst_neigh_lookup, so I wasn't sure about your comment re the ipoib 
conversion being what actually remains to make that change happen, can 
you elaborate here a little further?

Also, if ipoib moves to use that api, you made a comment that it will 
have a reference on the neighbour which will need to be released. I took 
a look on the net/atm use case which should to some extent be similar to 
ipoib, I see that neigh_release is called for neighbours retrieved by 
that API, okay.

Just for the sake of example, does the atm code free from the races you 
mention re ipoib? I see that it does stick its own object on the 
neighbour through the priv pointer but wasn't sure if it helps in that 
respect without further RCU-ing things.


Or.
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

  parent reply	other threads:[~2012-04-17  8:02 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-02-01 20:22 Infiniband stack allows references to freed memory David Miller
     [not found] ` <20120201.152213.433850213028883896.davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org>
2012-02-01 21:04   ` Roland Dreier
     [not found]     ` <CAG4TOxPrAhac1y-TzA=x47sm88JfQdkrpWW4Em_mBD=KbyRo+g-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2012-02-01 21:13       ` David Miller
     [not found]         ` <20120201.161333.2203265702893105548.davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org>
2012-02-01 21:42           ` Roland Dreier
     [not found]             ` <CAG4TOxMHG04_REzB9faBcjgUS43845qG5CgDYCUfLDYC6sEjmw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2012-02-01 21:50               ` David Miller
     [not found]                 ` <20120201.165041.1820098802489365638.davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org>
2012-02-01 22:02                   ` David Miller
     [not found]                     ` <20120201.170210.981802234698152048.davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org>
2012-02-01 22:06                       ` Roland Dreier
     [not found]                         ` <CAG4TOxNNTOc0hwjOuEa-p2SBf5GBnEjVQyOERiTq5gkprLioYQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2012-02-01 22:17                           ` David Miller
     [not found]                             ` <20120201.171703.1299449838314569881.davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org>
2012-02-01 23:28                               ` Roland Dreier
     [not found]                                 ` <CAG4TOxN75jXze4iy_nCBO1vwqvXnwKcqbAFAEFR=n-PdiG4moA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2012-02-02  1:21                                   ` David Miller
     [not found]                                     ` <20120201.202128.703330634975191244.davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org>
2012-02-02  2:19                                       ` Roland Dreier
2012-04-17  8:02                                       ` Or Gerlitz [this message]
     [not found]                                         ` <4F8D23A0.7000109-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
2012-04-18  3:04                                           ` David Miller
     [not found]                                             ` <20120417.230418.1898458010494189728.davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org>
2012-04-18  5:58                                               ` Or Gerlitz
     [not found]                                                 ` <4F8E57F8.9050703-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
2012-04-18  6:15                                                   ` David Miller
     [not found]                                                     ` <20120418.021558.255251358104374047.davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org>
2012-04-18  7:55                                                       ` Or Gerlitz
2012-02-01 22:26               ` Jason Gunthorpe
     [not found]                 ` <20120201222638.GA24483-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2012-02-01 23:32                   ` Roland Dreier
     [not found]                     ` <CAG4TOxMbDxYYyLRFJqvpDQk99f5cA7M=AA37W9R=yL5tBeshdQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2012-02-02  1:02                       ` Jason Gunthorpe
     [not found]                         ` <20120202010253.GB25606-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2012-02-02  1:42                           ` Roland Dreier

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=4F8D23A0.7000109@mellanox.com \
    --to=ogerlitz-vpraknaxozvwk0htik3j/w@public.gmane.org \
    --cc=davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org \
    --cc=linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=roland-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
    --cc=shlomop-VPRAkNaXOzVWk0Htik3J/w@public.gmane.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