bin/80798: mount_portal pipe leaves file descriptors open for child processes

Jukka A. Ukkonen jau at oxit.fi
Thu Jun 14 05:30:10 UTC 2012


The following reply was made to PR bin/80798; it has been noted by GNATS.

From: "Jukka A. Ukkonen" <jau at oxit.fi>
To: bug-followup at FreeBSD.org, hohmuth at sax.de
Cc:  
Subject: Re: bin/80798: mount_portal pipe leaves file descriptors open for
 child processes
Date: Thu, 14 Jun 2012 08:28:45 +0300

 This is a multi-part message in MIME format.
 --------------050707020708060501030604
 Content-Type: text/plain; charset=ISO-8859-1; format=flowed
 Content-Transfer-Encoding: 7bit
 
 
 To properly fix the anomaly (not just a workaround)
 only closing those couple of extra file descriptors at
 exec() apply the attached patch to stop leaking the
 socket to /tmp/portalXXXXXXXXX
 and the patch to the separate PR
 
 http://www.freebsd.org/cgi/query-pr.cgi?pr=bin/80798
 
 which plugs the leak of a descriptor to /etc/fstab.
 
 --jau
 
 
 --------------050707020708060501030604
 Content-Type: text/plain; charset=UTF-8;
  name="mount_portalfs.patch"
 Content-Transfer-Encoding: 7bit
 Content-Disposition: attachment;
  filename="mount_portalfs.patch"
 
 --- usr.sbin/mount_portalfs/mount_portalfs.c.orig	2012-06-14 07:52:20.000000000 +0300
 +++ usr.sbin/mount_portalfs/mount_portalfs.c	2012-06-14 08:07:54.000000000 +0300
 @@ -58,6 +58,7 @@
  #include <string.h>
  #include <sysexits.h>
  #include <unistd.h>
 +#include <fcntl.h>
  
  #include "mntopts.h"
  #include "pathnames.h"
 @@ -167,6 +168,8 @@
  
  	(void) listen(so, 5);
  
 +	(void) fcntl (so, F_SETFD, FD_CLOEXEC);
 +
  	args.pa_socket = so;
  	sprintf(tag, "portal:%d", getpid());
  	args.pa_config = tag;
 @@ -260,6 +263,9 @@
  			break;
  		case 0:
  			(void) close(so);
 +
 +			(void) fcntl (so2, F_SETFD, FD_CLOEXEC);
 +
  			activate(&q, so2);
  			exit(0);
  		default:
 
 --------------050707020708060501030604--


More information about the freebsd-bugs mailing list