Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 25 Jun 2017 06:55:43 +0000 (UTC)
From:      Xin LI <delphij@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org
Subject:   svn commit: r320326 - stable/9/lib/libc/rpc
Message-ID:  <201706250655.v5P6thTV060059@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: delphij
Date: Sun Jun 25 06:55:42 2017
New Revision: 320326
URL: https://svnweb.freebsd.org/changeset/base/320326

Log:
  MFC r320216: Fix use-after-free introduced in r300388.
  
  In r300388, endnetconfig() was called on nc_handle which would release
  the associated netconfig structure, which means tmpnconf->nc_netid
  would be a use-after-free.
  
  Solve this by doing endnetconfig() in return paths instead.
  
  Reported by:	jemalloc via kevlo
  Reviewed by:	cem, ngie (earlier version)

Modified:
  stable/9/lib/libc/rpc/rpcb_clnt.c
Directory Properties:
  stable/9/lib/libc/   (props changed)

Modified: stable/9/lib/libc/rpc/rpcb_clnt.c
==============================================================================
--- stable/9/lib/libc/rpc/rpcb_clnt.c	Sun Jun 25 05:46:03 2017	(r320325)
+++ stable/9/lib/libc/rpc/rpcb_clnt.c	Sun Jun 25 06:55:42 2017	(r320326)
@@ -508,14 +508,15 @@ try_nconf:
 					hostname = IN6_LOCALHOST_STRING;
 			}
 		}
-		endnetconfig(nc_handle);
 		if (tmpnconf == NULL) {
+			endnetconfig(nc_handle);
 			rpc_createerr.cf_stat = RPC_UNKNOWNPROTO;
 			mutex_unlock(&loopnconf_lock);
 			return (NULL);
 		}
 		loopnconf = getnetconfigent(tmpnconf->nc_netid);
 		/* loopnconf is never freed */
+		endnetconfig(nc_handle);
 	}
 	mutex_unlock(&loopnconf_lock);
 	client = getclnthandle(hostname, loopnconf, NULL);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201706250655.v5P6thTV060059>