aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv6/addrconf.c
diff options
context:
space:
mode:
authorstephen hemminger <shemminger@vyatta.com>2010-03-03 03:19:59 -0500
committerDavid S. Miller <davem@davemloft.net>2010-03-04 03:39:34 -0500
commit8f37ada5b5f6bfb4d251a7f510f249cb855b77b3 (patch)
tree8f39575febf0319570798117f8738f5127084634 /net/ipv6/addrconf.c
parent84e8b803f1e16f3a2b8b80f80a63fa2f2f8a9be6 (diff)
IPv6: fix race between cleanup and add/delete address
This solves a potential race problem during the cleanup process. The issue is that addrconf_ifdown() needs to traverse address list, but then drop lock to call the notifier. The version in -next could get confused if add/delete happened during this window. Original code (2.6.32 and earlier) was okay because all addresses were always deleted. Signed-off-by: Stephen Hemminger <shemminger@vyatta.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv6/addrconf.c')
-rw-r--r--net/ipv6/addrconf.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
index 7a4bf7671285..6cf3ee14ace3 100644
--- a/net/ipv6/addrconf.c
+++ b/net/ipv6/addrconf.c
@@ -2615,7 +2615,7 @@ static void addrconf_bonding_change(struct net_device *dev, unsigned long event)
2615static int addrconf_ifdown(struct net_device *dev, int how) 2615static int addrconf_ifdown(struct net_device *dev, int how)
2616{ 2616{
2617 struct inet6_dev *idev; 2617 struct inet6_dev *idev;
2618 struct inet6_ifaddr *ifa, **bifa; 2618 struct inet6_ifaddr *ifa, *keep_list, **bifa;
2619 struct net *net = dev_net(dev); 2619 struct net *net = dev_net(dev);
2620 int i; 2620 int i;
2621 2621
@@ -2689,8 +2689,12 @@ static int addrconf_ifdown(struct net_device *dev, int how)
2689 write_lock_bh(&idev->lock); 2689 write_lock_bh(&idev->lock);
2690 } 2690 }
2691#endif 2691#endif
2692 bifa = &idev->addr_list; 2692 keep_list = NULL;
2693 while ((ifa = *bifa) != NULL) { 2693 bifa = &keep_list;
2694 while ((ifa = idev->addr_list) != NULL) {
2695 idev->addr_list = ifa->if_next;
2696 ifa->if_next = NULL;
2697
2694 addrconf_del_timer(ifa); 2698 addrconf_del_timer(ifa);
2695 2699
2696 /* If just doing link down, and address is permanent 2700 /* If just doing link down, and address is permanent
@@ -2698,6 +2702,9 @@ static int addrconf_ifdown(struct net_device *dev, int how)
2698 if (how == 0 && 2702 if (how == 0 &&
2699 (ifa->flags&IFA_F_PERMANENT) && 2703 (ifa->flags&IFA_F_PERMANENT) &&
2700 !(ipv6_addr_type(&ifa->addr) & IPV6_ADDR_LINKLOCAL)) { 2704 !(ipv6_addr_type(&ifa->addr) & IPV6_ADDR_LINKLOCAL)) {
2705
2706 /* Move to holding list */
2707 *bifa = ifa;
2701 bifa = &ifa->if_next; 2708 bifa = &ifa->if_next;
2702 2709
2703 /* If not doing DAD on this address, just keep it. */ 2710 /* If not doing DAD on this address, just keep it. */
@@ -2714,8 +2721,6 @@ static int addrconf_ifdown(struct net_device *dev, int how)
2714 ifa->flags |= IFA_F_TENTATIVE; 2721 ifa->flags |= IFA_F_TENTATIVE;
2715 in6_ifa_hold(ifa); 2722 in6_ifa_hold(ifa);
2716 } else { 2723 } else {
2717 *bifa = ifa->if_next;
2718 ifa->if_next = NULL;
2719 ifa->dead = 1; 2724 ifa->dead = 1;
2720 } 2725 }
2721 write_unlock_bh(&idev->lock); 2726 write_unlock_bh(&idev->lock);
@@ -2726,6 +2731,9 @@ static int addrconf_ifdown(struct net_device *dev, int how)
2726 2731
2727 write_lock_bh(&idev->lock); 2732 write_lock_bh(&idev->lock);
2728 } 2733 }
2734
2735 idev->addr_list = keep_list;
2736
2729 write_unlock_bh(&idev->lock); 2737 write_unlock_bh(&idev->lock);
2730 2738
2731 /* Step 5: Discard multicast list */ 2739 /* Step 5: Discard multicast list */