Browse Source

[IPV6]: ipv6_add_addr should install dstentry earlier

ipv6_add_addr allocates a struct inet6_ifaddr and a dstentry, but it
doesn't install the dstentry in ifa->rt until after it releases the
addrconf_hash_lock. This means other CPUs will be able to see the new
address while it hasn't been initialized completely yet.

One possible fix would be to grab the ifp->lock spinlock when
creating the address struct; a simpler fix is to just move the
assignment.

Acked-by: jbeulich@novell.com
Acked-by: okir@suse.de
Acked-by: YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
Keir Fraser 19 years ago
parent
commit
57f5f544f5
1 changed files with 2 additions and 2 deletions
  1. 2 2
      net/ipv6/addrconf.c

+ 2 - 2
net/ipv6/addrconf.c

@@ -578,6 +578,8 @@ ipv6_add_addr(struct inet6_dev *idev, const struct in6_addr *addr, int pfxlen,
 	ifa->flags = flags | IFA_F_TENTATIVE;
 	ifa->flags = flags | IFA_F_TENTATIVE;
 	ifa->cstamp = ifa->tstamp = jiffies;
 	ifa->cstamp = ifa->tstamp = jiffies;
 
 
+	ifa->rt = rt;
+
 	ifa->idev = idev;
 	ifa->idev = idev;
 	in6_dev_hold(idev);
 	in6_dev_hold(idev);
 	/* For caller */
 	/* For caller */
@@ -603,8 +605,6 @@ ipv6_add_addr(struct inet6_dev *idev, const struct in6_addr *addr, int pfxlen,
 	}
 	}
 #endif
 #endif
 
 
-	ifa->rt = rt;
-
 	in6_ifa_hold(ifa);
 	in6_ifa_hold(ifa);
 	write_unlock(&idev->lock);
 	write_unlock(&idev->lock);
 out2:
 out2: