Browse files

ipv6: addrconf: fix dev refcont leak when DAD failed

In general, when DAD detected IPv6 duplicate address, ifp->state
will be set to INET6_IFADDR_STATE_ERRDAD and DAD is stopped by a
delayed work, the call tree should be like this:

  -> addrconf_dad_failure        <- missing ifp put
     -> addrconf_mod_dad_work
       -> schedule addrconf_dad_work()
         -> addrconf_dad_stop()  <- missing ifp hold before call it

addrconf_dad_failure() called with ifp refcont holding but not put.
addrconf_dad_work() call addrconf_dad_stop() without extra holding
refcount. This will not cause any issue normally.

But the race between addrconf_dad_failure() and addrconf_dad_work()
may cause ifp refcount leak and netdevice can not be unregister,
dmesg show the following messages:

IPv6: eth0: IPv6 duplicate address fe80::XX:XXXX:XXXX:XX detected!
unregister_netdevice: waiting for eth0 to become free. Usage count = 1

Fixes: c15b1cc ("ipv6: move DAD and addrconf_verify processing
to workqueue")
Signed-off-by: Wei Yongjun <>
Signed-off-by: David S. Miller <>
  • Loading branch information...
Wei Yongjun authored and davem330 committed Sep 5, 2016
1 parent 9d13744 commit 751eb6b6042a596b0080967c1a529a9fe98dac1d
Showing with 2 additions and 0 deletions.
  1. +2 −0 net/ipv6/addrconf.c
@@ -1948,6 +1948,7 @@ void addrconf_dad_failure(struct inet6_ifaddr *ifp)

addrconf_mod_dad_work(ifp, 0);

/* Join to solicited addr multicast group.
@@ -3857,6 +3858,7 @@ static void addrconf_dad_work(struct work_struct *w)
goto out;
} else if (action == DAD_ABORT) {
addrconf_dad_stop(ifp, 1);
if (disable_ipv6)
addrconf_ifdown(idev->dev, 0);

0 comments on commit 751eb6b

Please sign in to comment.