From owner-svn-src-stable@FreeBSD.ORG Wed Feb 25 11:18:18 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 77448106566B; Wed, 25 Feb 2009 11:18:18 +0000 (UTC) (envelope-from rwatson@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 4A72A8FC2F; Wed, 25 Feb 2009 11:18:18 +0000 (UTC) (envelope-from rwatson@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n1PBIIog094669; Wed, 25 Feb 2009 11:18:18 GMT (envelope-from rwatson@svn.freebsd.org) Received: (from rwatson@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n1PBIIcQ094668; Wed, 25 Feb 2009 11:18:18 GMT (envelope-from rwatson@svn.freebsd.org) Message-Id: <200902251118.n1PBIIcQ094668@svn.freebsd.org> From: Robert Watson Date: Wed, 25 Feb 2009 11:18:18 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r189029 - stable/7/sys/net X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 25 Feb 2009 11:18:19 -0000 Author: rwatson Date: Wed Feb 25 11:18:18 2009 New Revision: 189029 URL: http://svn.freebsd.org/changeset/base/189029 Log: Correct a deadlock and a rtentry leak in rt_check(): - In the event that a gateway route has to be looked up, drop the lock on 'rt' before reacquiring it 'rt0' in order to avoid deadlock. - In the event the original route has evaporated or is no longer up after the gateway route lookup, call RTFREE() on the gateway route before retrying. This is a potential errata candidate patch. PR: kern/130652 Submitted by: Dmitrij Tejblum Reviewed by: bz Tested by: Pete French Modified: stable/7/sys/net/route.c Modified: stable/7/sys/net/route.c ============================================================================== --- stable/7/sys/net/route.c Wed Feb 25 11:13:13 2009 (r189028) +++ stable/7/sys/net/route.c Wed Feb 25 11:18:18 2009 (r189029) @@ -1650,27 +1650,34 @@ retry: return (ENETUNREACH); } /* - * Relock it and lose the added reference. - * All sorts of things could have happenned while we - * had no lock on it, so check for them. + * Relock it and lose the added reference. All sorts + * of things could have happenned while we had no + * lock on it, so check for them. rt need to be + * unlocked to avoid possible deadlock. */ + RT_UNLOCK(rt); RT_RELOCK(rt0); - if (rt0 == NULL || ((rt0->rt_flags & RTF_UP) == 0)) + if (rt0 == NULL || ((rt0->rt_flags & RTF_UP) == 0)) { /* Ru-roh.. what we had is no longer any good */ + RTFREE(rt); goto retry; + } /* * While we were away, someone replaced the gateway. * Since a reference count is involved we can't just * overwrite it. */ if (rt0->rt_gwroute) { - if (rt0->rt_gwroute != rt) { - RTFREE_LOCKED(rt); - goto retry; - } + if (rt0->rt_gwroute != rt) + RTFREE(rt); } else { rt0->rt_gwroute = rt; } + /* + * Since rt was not locked, we need recheck that + * it still may be used (e.g. up) + */ + goto retry; } RT_LOCK_ASSERT(rt); RT_UNLOCK(rt0);