From: Stephen Hemminger <shemminger@vyatta.com>
To: Eric Dumazet <eric.dumazet@gmail.com>
Cc: Jiri Bohac <jbohac@suse.cz>,
netdev@vger.kernel.org,
Hideaki YOSHIFUJI <yoshfuji@linux-ipv6.org>,
David Miller <davem@davemloft.net>
Subject: Re: IPv6: race condition in __ipv6_ifa_notify() and dst_free() ?
Date: Tue, 20 Apr 2010 14:16:55 -0700 [thread overview]
Message-ID: <20100420141655.3a66b8e8@nehalam> (raw)
In-Reply-To: <1271797043.7895.320.camel@edumazet-laptop>
On Tue, 20 Apr 2010 22:57:23 +0200
Eric Dumazet <eric.dumazet@gmail.com> wrote:
> Le mardi 20 avril 2010 à 22:49 +0200, Jiri Bohac a écrit :
> > On Tue, Apr 20, 2010 at 07:57:27PM +0200, Eric Dumazet wrote:
> > > Le mardi 20 avril 2010 à 19:44 +0200, Jiri Bohac a écrit :
> > > > --- a/net/ipv6/addrconf.c 2010-04-17 00:12:32.000000000 +0200
> > > > +++ b/net/ipv6/addrconf.c 2010-04-20 19:07:35.000000000 +0200
> > > > @@ -3974,8 +3974,7 @@ static void __ipv6_ifa_notify(int event,
> > > > addrconf_leave_anycast(ifp);
> > > > addrconf_leave_solict(ifp->idev, &ifp->addr);
> > > > dst_hold(&ifp->rt->u.dst);
> > > > - if (ip6_del_rt(ifp->rt))
> > > > - dst_free(&ifp->rt->u.dst);
> > > > + ip6_del_rt(ifp->rt);
> > > > break;
> > > > }
> > > > }
> > > >
> > >
> > >
> > > I dont understand the problem Jiri.
> > >
> > > We just did dst_hold(&ifp->rt->u.dst), so if ip6_del_rt() fails we must
> > > dst_free(), or we leak a refcount.
> >
> > Well, no ... dst_free() does not decrement the refcount.
> > The "opposite" of dst_hold() is dst_release(). And it does not
> > automatically call dst_free() when the refcount drops to 0.
> > dst_free() needs to be called explicitly and it apparently
> > expects the caller to ensure that two dst_free()s won't be called
> > simultaneously. But my bonding example shows this is not the
> > case.
> >
> >
>
> Ah yes you're right
>
> Maybe ask Stephen ?
>
> commit 93fa159abe50d3c55c7f83622d3f5c09b6e06f4b
> Author: stephen hemminger <shemminger@vyatta.com>
> Date: Mon Apr 12 05:41:31 2010 +0000
>
> IPv6: keep route for tentative address
>
> Recent changes preserve IPv6 address when link goes down (good).
> But would cause address to point to dead dst entry (bad).
> The simplest fix is to just not delete route if address is
> being held for later use.
>
> Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>
> Signed-off-by: David S. Miller <davem@davemloft.net>
>
> diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
> index 1b00bfe..a9913d2 100644
> --- a/net/ipv6/addrconf.c
> +++ b/net/ipv6/addrconf.c
> @@ -4047,7 +4047,8 @@ static void __ipv6_ifa_notify(int event, struct
> inet6_ifaddr *ifp)
> addrconf_leave_anycast(ifp);
> addrconf_leave_solict(ifp->idev, &ifp->addr);
> dst_hold(&ifp->rt->u.dst);
> - if (ip6_del_rt(ifp->rt))
> +
> + if (ifp->dead && ip6_del_rt(ifp->rt))
> dst_free(&ifp->rt->u.dst);
> break;
Is this problem new to net-next where we hold onto addresses, or was
the issue there before?
next prev parent reply other threads:[~2010-04-20 21:17 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-04-20 17:44 IPv6: race condition in __ipv6_ifa_notify() and dst_free() ? Jiri Bohac
2010-04-20 17:57 ` Eric Dumazet
2010-04-20 20:49 ` Jiri Bohac
2010-04-20 20:57 ` Eric Dumazet
2010-04-20 21:16 ` Stephen Hemminger [this message]
2010-04-20 21:35 ` Jiri Bohac
2010-04-21 21:34 ` Jiri Bohac
2010-04-22 2:32 ` Herbert Xu
2010-04-22 7:43 ` David Miller
2010-04-22 14:25 ` Herbert Xu
2010-04-22 15:49 ` Jiri Bohac
2010-04-22 16:17 ` Stephen Hemminger
2010-04-23 1:54 ` David Miller
2010-04-23 2:10 ` Herbert Xu
2010-04-23 15:05 ` Herbert Xu
2010-05-18 11:02 ` [0/4] Fix addrconf race conditions Herbert Xu
2010-05-18 11:04 ` [PATCH 1/4] ipv6: Replace inet6_ifaddr->dead with state Herbert Xu
2010-05-18 17:23 ` Stephen Hemminger
2010-05-18 22:27 ` David Miller
2010-05-18 11:04 ` [PATCH 2/4] ipv6: Use state_lock to protect ifa state Herbert Xu
2010-05-18 11:04 ` [PATCH 3/4] ipv6: Use POSTDAD state Herbert Xu
2010-05-18 11:04 ` [PATCH 4/4] ipv6: Never schedule DAD timer on dead address Herbert Xu
2010-05-18 17:25 ` [0/4] Fix addrconf race conditions Stephen Hemminger
2010-05-18 22:27 ` David Miller
2010-05-18 22:35 ` Herbert Xu
2010-04-27 15:50 ` IPv6: race condition in __ipv6_ifa_notify() and dst_free() ? Jiri Bohac
2010-04-27 15:55 ` Herbert Xu
2010-05-09 6:48 ` Herbert Xu
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=20100420141655.3a66b8e8@nehalam \
--to=shemminger@vyatta.com \
--cc=davem@davemloft.net \
--cc=eric.dumazet@gmail.com \
--cc=jbohac@suse.cz \
--cc=netdev@vger.kernel.org \
--cc=yoshfuji@linux-ipv6.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;
as well as URLs for NNTP newsgroup(s).