Subject: Re: race in select() ?
To: Manuel Bouyer <bouyer@antioche.lip6.fr>
From: David Laight <david@l8s.co.uk>
List: tech-kern
Date: 10/09/2003 18:01:53
On Thu, Oct 09, 2003 at 05:20:10PM +0200, Manuel Bouyer wrote:
> On Thu, Oct 09, 2003 at 02:13:51PM +0100, David Laight wrote:
> >
> > I presume inetd takes the fd out of its select list until the rpc.rstatd
> > process exits. Otherwise there would be a nasty loop.
>
> Yes it does.
There is a timing bug in inetd itself. rev 1.76 reads:
readable = allsock;
if ((n = select(maxsock + 1, &readable, (fd_set *)0,
...
and reapchild does:
FD_SET(sep->se_fd, &allsock);
So if a child exits after the copy is made, but before the system call
the select won't be looking for the correct fdset.
If reapchild set the bit in readable then there could be a false
positive if the SIGCHLD happened in the system call return path,
that might be easier to check though (eg detect it happening, and
call select again).
Of course, you may not be hitting this one...
Oh, inetd in current uses kqueue.
David
--
David Laight: david@l8s.co.uk