netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Stephen Hemminger <shemminger@vyatta.com>
To: Jiri Bohac <jbohac@suse.cz>
Cc: Herbert Xu <herbert@gondor.apana.org.au>,
	David Miller <davem@davemloft.net>,
	yoshfuji@linux-ipv6.org, netdev@vger.kernel.org
Subject: Re: IPv6: race condition in __ipv6_ifa_notify() and dst_free() ?
Date: Thu, 22 Apr 2010 09:17:03 -0700	[thread overview]
Message-ID: <20100422091703.463665c0@nehalam> (raw)
In-Reply-To: <20100422154908.GA31568@midget.suse.cz>

On Thu, 22 Apr 2010 17:49:08 +0200
Jiri Bohac <jbohac@suse.cz> wrote:

> On Thu, Apr 22, 2010 at 10:25:06PM +0800, Herbert Xu wrote:
> > This patch fixes this by using the DADFAILED bit to synchronise
> > the two paths while holding the ifp lock.  It relies on the fact
> > that the TENTATIVE bit is always set during DAD, and that the
> > DADFAILED bit is only set on failure.
> 
> But the addr_dad_failure()->...->ipv6_del_addr() path will
> still race with any other path calling ipv6_del_addr() (e.g. a
> manual address removal). Won't it?
> 
> 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)?

Yes, some more locking and race condition management is needed.

Something like the following (untested):

--- a/net/ipv6/addrconf.c	2010-04-22 09:11:54.594827858 -0700
+++ b/net/ipv6/addrconf.c	2010-04-22 09:15:59.224631752 -0700
@@ -720,13 +720,18 @@ static void ipv6_del_addr(struct inet6_i
 
 	hash = ipv6_addr_hash(&ifp->addr);
 
+	write_lock_bh(&idev->lock);
+	if (ifp->dead) {
+		write_unlock(&idev->lock); /* lost race with DAD */
+		return;
+	}
+
 	ifp->dead = 1;
 
-	spin_lock_bh(&addrconf_hash_lock);
+	spin_lock(&addrconf_hash_lock);
 	hlist_del_init_rcu(&ifp->addr_lst);
-	spin_unlock_bh(&addrconf_hash_lock);
+	spin_unlock(&addrconf_hash_lock);
 
-	write_lock_bh(&idev->lock);
 #ifdef CONFIG_IPV6_PRIVACY
 	if (ifp->flags&IFA_F_TEMPORARY) {
 		list_del(&ifp->tmp_list);




  reply	other threads:[~2010-04-22 16: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
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 [this message]
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=20100422091703.463665c0@nehalam \
    --to=shemminger@vyatta.com \
    --cc=davem@davemloft.net \
    --cc=herbert@gondor.apana.org.au \
    --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).