Author: delphij
Date: Sun Jun 25 17:42:27 2017
New Revision: 320330
URL: https://svnweb.freebsd.org/changeset/base/320330

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)
  Approved by:  re (kib)

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

Modified: stable/11/lib/libc/rpc/rpcb_clnt.c
==============================================================================
--- stable/11/lib/libc/rpc/rpcb_clnt.c  Sun Jun 25 15:21:51 2017        
(r320329)
+++ stable/11/lib/libc/rpc/rpcb_clnt.c  Sun Jun 25 17:42:27 2017        
(r320330)
@@ -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);
_______________________________________________
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to