Date: Thu, 26 May 2016 14:13:10 +0000 (UTC) From: "Bjoern A. Zeeb" <bz@FreeBSD.org> To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r300743 - projects/vnet/sys/net Message-ID: <201605261413.u4QEDAXd069746@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
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);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201605261413.u4QEDAXd069746>