svn commit: r320216 - head/lib/libc/rpc

Xin LI delphij at FreeBSD.org
Thu Jun 22 05:10:17 UTC 2017


Author: delphij
Date: Thu Jun 22 05:10:16 2017
New Revision: 320216
URL: https://svnweb.freebsd.org/changeset/base/320216

Log:
  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)
  MFC after:	3 days
  Differential Revision:    https://reviews.freebsd.org/D11288

Modified:
  head/lib/libc/rpc/rpcb_clnt.c

Modified: head/lib/libc/rpc/rpcb_clnt.c
==============================================================================
--- head/lib/libc/rpc/rpcb_clnt.c	Thu Jun 22 04:40:11 2017	(r320215)
+++ head/lib/libc/rpc/rpcb_clnt.c	Thu Jun 22 05:10:16 2017	(r320216)
@@ -499,14 +499,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);


More information about the svn-src-all mailing list