inetd fd leak?

Denys Vlasenko vda.linux at googlemail.com
Fri Sep 4 00:25:18 UTC 2009


On Friday 04 September 2009 01:16, Doug Graham wrote:
> Doug Graham wrote:
> > "inetd -e" does fix it for me, but LOG_NDELAY does not.
> >
> Thinking a bit more about this (I guess vfork is totally weird isn't a 
> particularly satisfying answer),
> and I think it probably goes something like this:
> 
>   - parent calls vfork
>   - child running in shared address space calls closelog()
>   - closelog closes the fd in the child but also sets a global (shared) 
> variable to -1 to indicate that the
>     log descriptor is not open
>   - when parent is resumed after the child execs, it finds the global 
> set to -1 and thinks the
>     descriptor is not open.  So it opens it again and sets the global to 
> the new descriptor.

You are right. That closelog() is wrong.

> Conclusion: vfork is totally weird :-)

No, it just requires you to be much more careful.
But on the bright side, it's many times fater than fork,
and exists on NOMMU too.

Please try attached patch, it should fix the bug.
--
vda


-------------- next part --------------
A non-text attachment was scrubbed...
Name: 7.patch
Type: text/x-diff
Size: 2368 bytes
Desc: not available
URL: <http://lists.busybox.net/pipermail/busybox/attachments/20090904/f533fead/attachment.bin>


More information about the busybox mailing list