From owner-svn-src-stable@freebsd.org Fri Jan 3 00:29:10 2020 Return-Path: Delivered-To: svn-src-stable@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 824891E0A05; Fri, 3 Jan 2020 00:29:10 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 47pm462yl2z4CSb; Fri, 3 Jan 2020 00:29:10 +0000 (UTC) (envelope-from markj@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 mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 607BF23CEA; Fri, 3 Jan 2020 00:29:10 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0030TAKH083810; Fri, 3 Jan 2020 00:29:10 GMT (envelope-from markj@FreeBSD.org) Received: (from markj@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0030TAPh083809; Fri, 3 Jan 2020 00:29:10 GMT (envelope-from markj@FreeBSD.org) Message-Id: <202001030029.0030TAPh083809@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: markj set sender to markj@FreeBSD.org using -f From: Mark Johnston Date: Fri, 3 Jan 2020 00:29:10 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r356312 - stable/12/sys/net X-SVN-Group: stable-12 X-SVN-Commit-Author: markj X-SVN-Commit-Paths: stable/12/sys/net X-SVN-Commit-Revision: 356312 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.29 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: Fri, 03 Jan 2020 00:29:10 -0000 Author: markj Date: Fri Jan 3 00:29:09 2020 New Revision: 356312 URL: https://svnweb.freebsd.org/changeset/base/356312 Log: MFC r356107: Plug some ifaddr refcount leaks. PR: 242746 Modified: stable/12/sys/net/route.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/net/route.c ============================================================================== --- stable/12/sys/net/route.c Fri Jan 3 00:28:34 2020 (r356311) +++ stable/12/sys/net/route.c Fri Jan 3 00:29:09 2020 (r356312) @@ -833,7 +833,7 @@ rtrequest_fib(int req, * to reflect size of the provided buffer. if no NHR_COPY is specified, * point dst,netmask and gw @info fields to appropriate @rt values. * - * if @flags contains NHR_REF, do refcouting on rt_ifp. + * if @flags contains NHR_REF, do refcouting on rt_ifp and rt_ifa. * * Returns 0 on success. */ @@ -903,10 +903,9 @@ rt_exportinfo(struct rtentry *rt, struct rt_addrinfo * info->rti_flags = rt->rt_flags; info->rti_ifp = rt->rt_ifp; info->rti_ifa = rt->rt_ifa; - ifa_ref(info->rti_ifa); if (flags & NHR_REF) { - /* Do 'traditional' refcouting */ if_ref(info->rti_ifp); + ifa_ref(info->rti_ifa); } return (0); @@ -916,8 +915,8 @@ rt_exportinfo(struct rtentry *rt, struct rt_addrinfo * * Lookups up route entry for @dst in RIB database for fib @fibnum. * Exports entry data to @info using rt_exportinfo(). * - * if @flags contains NHR_REF, refcouting is performed on rt_ifp. - * All references can be released later by calling rib_free_info() + * If @flags contains NHR_REF, refcouting is performed on rt_ifp and rt_ifa. + * All references can be released later by calling rib_free_info(). * * Returns 0 on success. * Returns ENOENT for lookup failure, ENOMEM for export failure. @@ -963,6 +962,7 @@ void rib_free_info(struct rt_addrinfo *info) { + ifa_free(info->rti_ifa); if_rele(info->rti_ifp); } @@ -1595,9 +1595,12 @@ rtrequest1_fib(int req, struct rt_addrinfo *info, stru error = rt_getifa_fib(info, fibnum); if (error) return (error); + } else { + ifa_ref(info->rti_ifa); } rt = uma_zalloc(V_rtzone, M_NOWAIT); if (rt == NULL) { + ifa_free(info->rti_ifa); return (ENOBUFS); } rt->rt_flags = RTF_UP | flags; @@ -1606,6 +1609,7 @@ rtrequest1_fib(int req, struct rt_addrinfo *info, stru * Add the gateway. Possibly re-malloc-ing the storage for it. */ if ((error = rt_setgate(rt, dst, gateway)) != 0) { + ifa_free(info->rti_ifa); uma_zfree(V_rtzone, rt); return (error); } @@ -1629,7 +1633,6 @@ rtrequest1_fib(int req, struct rt_addrinfo *info, stru * examine the ifa and ifa->ifa_ifp if it so desires. */ ifa = info->rti_ifa; - ifa_ref(ifa); rt->rt_ifa = ifa; rt->rt_ifp = ifa->ifa_ifp; rt->rt_weight = 1; @@ -2065,7 +2068,6 @@ rtinit1(struct ifaddr *ifa, int cmd, int flags, int fi * Do the actual request */ bzero((caddr_t)&info, sizeof(info)); - ifa_ref(ifa); info.rti_ifa = ifa; info.rti_flags = flags | (ifa->ifa_flags & ~IFA_RTSELF) | RTF_PINNED; @@ -2080,7 +2082,6 @@ rtinit1(struct ifaddr *ifa, int cmd, int flags, int fi info.rti_info[RTAX_GATEWAY] = ifa->ifa_addr; info.rti_info[RTAX_NETMASK] = netmask; error = rtrequest1_fib(cmd, &info, &rt, fibnum); - if (error == 0 && rt != NULL) { /* * notify any listening routing agents of the change