svn commit: r300743 - projects/vnet/sys/net

Bjoern A. Zeeb bz at FreeBSD.org
Thu May 26 14:13:11 UTC 2016


Author: bz
Date: Thu May 26 14:13:09 2016
New Revision: 300743
URL: https://svnweb.freebsd.org/changeset/base/300743

Log:
  Rather than just protecting the removal from the list, also protect
  the check even if it means we may lock and unlock without doing any
  work, plugging possible race condition in a rarely exercised path of
  if_detach_internal().
  
  Sponsored by:	The FreeBSD Foundation

Modified:
  projects/vnet/sys/net/if.c

Modified: projects/vnet/sys/net/if.c
==============================================================================
--- projects/vnet/sys/net/if.c	Thu May 26 14:02:41 2016	(r300742)
+++ projects/vnet/sys/net/if.c	Thu May 26 14:13:09 2016	(r300743)
@@ -1054,13 +1054,14 @@ if_detach_internal(struct ifnet *ifp, in
 		ifp->if_addr = NULL;
 
 		/* We can now free link ifaddr. */
+		IF_ADDR_WLOCK(ifp);
 		if (!TAILQ_EMPTY(&ifp->if_addrhead)) {
 			ifa = TAILQ_FIRST(&ifp->if_addrhead);
-			IF_ADDR_WLOCK(ifp);
 			TAILQ_REMOVE(&ifp->if_addrhead, ifa, ifa_link);
 			IF_ADDR_WUNLOCK(ifp);
 			ifa_free(ifa);
-		}
+		} else
+			IF_ADDR_WUNLOCK(ifp);
 	}
 
 	rt_flushifroutes(ifp);


More information about the svn-src-projects mailing list