[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20100427155034.GA11157@midget.suse.cz>
Date: Tue, 27 Apr 2010 17:50:34 +0200
From: Jiri Bohac <jbohac@...e.cz>
To: David Miller <davem@...emloft.net>
Cc: jbohac@...e.cz, herbert@...dor.apana.org.au,
yoshfuji@...ux-ipv6.org, netdev@...r.kernel.org,
shemminger@...tta.com
Subject: Re: IPv6: race condition in __ipv6_ifa_notify() and dst_free() ?
On Thu, Apr 22, 2010 at 06:54:00PM -0700, David Miller wrote:
> From: Jiri Bohac <jbohac@...e.cz>
> Date: Thu, 22 Apr 2010 17:49:08 +0200
>
> > I still don't see why __ipv6_ifa_notify() needs to call
> > dst_free(). Shouldn't that be dst_release() instead, to drop the
> > reference obtained by dst_hold(&ifp->rt->u.dst)?
>
> It likely wants to do both.
>
> Just doing dst_release() doesn't mark the 'dst' object as obsolete,
> and therefore it won't get force garbage collected.
Sure. So If I understand it correctly, there are two problems:
- the reference taken by dst_hold() just above the ip6_del_rt()
is never dropped if ip6_del_rt() fails; so shouldn't the code
be like this?:
dst_hold(&ifp->rt->u.dst);
if (ip6_del_rt(ifp->rt)) {
dst_release(&ifp->rt->u.dst);
dst_free(&ifp->rt->u.dst);
}
- if ip6_del_rt() fails because it races with something else
deleting the address, dst_free() will be called twice. This is
what Herbert is fixing with additional locking. However -- even
when he fixes that -- how can ip6_del_rt() fail with the
ifp->rt still needing a dst_free()?
AFAICS, it can fail by:
- __ip6_del_rt() finding that (rt ==
net->ipv6.ip6_null_entry); we don't want to call
dst_free() on net->ipv6.ip6_null_entry, do we?
- fib6_del() returning -ENOENT for multiple reasons;
but doesn't that mean that something else has removed
the route already and called dst_free on it?
In either case, the dst_free() looks like not being needed. And it only
does no harm in most cases, because these events are rare and
it usually finds (obsolete > 2) and does nothing.
I think that what Herbert is doing is only going to enforce that
the ip6_del_rt() is never going to fail, so the dst_free()
won't ever be called anyway, right?
Thanks,
--
Jiri Bohac <jbohac@...e.cz>
SUSE Labs, SUSE CZ
--
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