From owner-svn-src-projects@freebsd.org Thu May 26 14:13:11 2016 Return-Path: Delivered-To: svn-src-projects@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 07968B4B910 for ; Thu, 26 May 2016 14:13:11 +0000 (UTC) (envelope-from bz@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id CE98D128A; Thu, 26 May 2016 14:13:10 +0000 (UTC) (envelope-from bz@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u4QEDAk6069747; Thu, 26 May 2016 14:13:10 GMT (envelope-from bz@FreeBSD.org) Received: (from bz@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u4QEDAXd069746; Thu, 26 May 2016 14:13:10 GMT (envelope-from bz@FreeBSD.org) Message-Id: <201605261413.u4QEDAXd069746@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: bz set sender to bz@FreeBSD.org using -f From: "Bjoern A. Zeeb" Date: Thu, 26 May 2016 14:13:10 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r300743 - projects/vnet/sys/net X-SVN-Group: projects MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 26 May 2016 14:13:11 -0000 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);