Re: file descriptor leak in 5.2-RC

From: Bjoern A. Zeeb <bzeeb-lists_at_lists.zabbadoz.net>
Date: Sun, 28 Dec 2003 18:49:29 +0000 (UTC)
On Sun, 28 Dec 2003, David Malone wrote:

> > I'd call it a surprise if someone after all had a fix within the next 10
> > hours or so.
>
> I'm fairly certain I've found the problem (and, indeed, it looks
> like I introduced it too while changing how falloc works). You loose
> a reference to /dev/null every time you exec a suid program with
> at least one of std{in,out,err} closed. I'm guessing that some part
> of postfix does this.
>
> I believe the patch below will fix the problem. I guess I'm too
> late for you to test it now?


verified to work against my testcase.
--- cut (pasted out of console log w/ other debugging printfs) ---
> sysctl kern.openfiles
kern.openfiles: 43
> ./exec-closed123-ping
> sysctl kern.openfiles
kern.openfiles: 43
> ./exec-closed123-ping
> sysctl kern.openfiles
kern.openfiles: 43
--- cut ---

please commit.


> Index: kern_descrip.c
> ===================================================================
> RCS file: /cvs/FreeBSD-CVS/src/sys/kern/kern_descrip.c,v
> retrieving revision 1.215
> diff -u -r1.215 kern_descrip.c
> --- kern_descrip.c	19 Oct 2003 20:41:06 -0000	1.215
> +++ kern_descrip.c	28 Dec 2003 17:55:00 -0000
> _at__at_ -1730,6 +1730,7 _at__at_
>  			fp->f_type = DTYPE_VNODE;
>  			VOP_UNLOCK(nd.ni_vp, 0, td);
>  			devnull = fd;
> +			fdrop(fp, td);
>  		} else {
>  			error = do_dup(td, DUP_FIXED, devnull, i, &retval);
>  			if (error != 0)

-- 
Bjoern A. Zeeb				bzeeb at Zabbadoz dot NeT
56 69 73 69 74				http://www.zabbadoz.net/
Received on Sun Dec 28 2003 - 09:49:52 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:37:35 UTC