fanghuilin / rpms / kernel

Forked from rpms/kernel 3 years ago
Clone
a8a466
centosplus patch [bug#12711]
a8a466
a8a466
commit 751eb6b6042a596b0080967c1a529a9fe98dac1d
a8a466
Author: Wei Yongjun <weiyongjun1@huawei.com>
a8a466
Date:   Mon Sep 5 16:06:31 2016 +0800
a8a466
a8a466
    ipv6: addrconf: fix dev refcont leak when DAD failed
a8a466
                                                        
a8a466
    In general, when DAD detected IPv6 duplicate address, ifp->state
a8a466
    will be set to INET6_IFADDR_STATE_ERRDAD and DAD is stopped by a
a8a466
    delayed work, the call tree should be like this:
a8a466
                                                                    
a8a466
    ndisc_recv_ns                                                   
a8a466
      -> addrconf_dad_failure        <- missing ifp put             
a8a466
         -> addrconf_mod_dad_work                                   
a8a466
           -> schedule addrconf_dad_work()                          
a8a466
             -> addrconf_dad_stop()  <- missing ifp hold before call it
a8a466
                                                                       
a8a466
    addrconf_dad_failure() called with ifp refcont holding but not put.
a8a466
    addrconf_dad_work() call addrconf_dad_stop() without extra holding 
a8a466
    refcount. This will not cause any issue normally.                  
a8a466
                                                                       
a8a466
    But the race between addrconf_dad_failure() and addrconf_dad_work()
a8a466
    may cause ifp refcount leak and netdevice can not be unregister,   
a8a466
    dmesg show the following messages:                                 
a8a466
                                                                       
a8a466
    IPv6: eth0: IPv6 duplicate address fe80::XX:XXXX:XXXX:XX detected!
a8a466
    ...
a8a466
    unregister_netdevice: waiting for eth0 to become free. Usage count = 1
a8a466
a8a466
    Cc: stable@vger.kernel.org
a8a466
    Fixes: c15b1ccadb32 ("ipv6: move DAD and addrconf_verify processing
a8a466
    to workqueue")
a8a466
    Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
a8a466
    Signed-off-by: David S. Miller <davem@davemloft.net>
a8a466
a8a466
    Submitted-by: alfredo
a8a466
    Applied-by: Akemi Yagi <toracat@centos.org>
a8a466
a8a466
diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
a8a466
index b7d5ce6..dc65579 100644
a8a466
--- a/net/ipv6/addrconf.c
a8a466
+++ b/net/ipv6/addrconf.c
a8a466
@@ -1656,6 +1656,7 @@ void addrconf_dad_failure(struct inet6_ifaddr *ifp)
a8a466
 	spin_unlock_bh(&ifp->state_lock);
a8a466
 
a8a466
 	addrconf_mod_dad_work(ifp, 0);
a8a466
+    in6_ifa_put(ifp);
a8a466
 }
a8a466
 
a8a466
 /* Join to solicited addr multicast group.
a8a466
@@ -3300,6 +3301,7 @@ static void addrconf_dad_work(struct work_struct *w)
a8a466
 		addrconf_dad_begin(ifp);
a8a466
 		goto out;
a8a466
 	} else if (action == DAD_ABORT) {
a8a466
+        in6_ifa_hold(ifp);
a8a466
 		addrconf_dad_stop(ifp, 1);
a8a466
 		goto out;
a8a466
 	}