[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Fri, 03 Apr 2015 18:20:06 -0700
From: Eric Dumazet <eric.dumazet@...il.com>
To: Alexei Potashnik <alexei@...estorage.com>
Cc: Joern Engel <joern@...estorage.com>,
"David S. Miller" <davem@...emloft.net>, netdev@...r.kernel.org
Subject: Re: neigh use-after-free
On Fri, 2015-04-03 at 18:10 -0700, Eric Dumazet wrote:
> On Fri, 2015-04-03 at 17:57 -0700, Alexei Potashnik wrote:
>
> >
> > My understanding of the state when issue occurs is:
> > - neigh_destroy() has finished executing
> > - no timer for this neigh entry is pending or running
> > (which makes neigh_timer_handler behavior irrelevant)
> > - but kfree_rcu callback for the neigh entry has not executed yet
> > - at this point IP code finds the entry with __ipv4_neigh_lookup_noref
> > and starts operating on it.
> >
>
> Right. So far no rule here seems to be violated.
>
> As long as IP code finds a neighbor, it is allowed to use it.
>
> Freeing of the neighbor should not happen before rcu grace period.
>
> Problem is __neigh_event_send() is ignoring n->dead
>
>
Please try following patch :
diff --git a/net/core/neighbour.c b/net/core/neighbour.c
index 3de6542560288b3896ab243879a7b4a9b098ca0d..3a2928332b31bfd421ca409ba9bc4e82f82b3552 100644
--- a/net/core/neighbour.c
+++ b/net/core/neighbour.c
@@ -957,7 +957,8 @@ int __neigh_event_send(struct neighbour *neigh, struct sk_buff *skb)
rc = 0;
if (neigh->nud_state & (NUD_CONNECTED | NUD_DELAY | NUD_PROBE))
goto out_unlock_bh;
-
+ if (neigh->dead)
+ goto out_unlock_bh;
if (!(neigh->nud_state & (NUD_STALE | NUD_INCOMPLETE))) {
if (NEIGH_VAR(neigh->parms, MCAST_PROBES) +
NEIGH_VAR(neigh->parms, APP_PROBES)) {
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Powered by blists - more mailing lists