Matthew Dillon wrote:
>     The issue with dup2() was a race against open() or close()
>     I believe, where dup2() could potentially dup into a
>     descriptor that open() was about to use.  Unfortunately, it
>     does appear that dup() has the same issue.
> 
>     fdalloc() does not reserve the descriptor number it
>     returns, it simply finds a free slot and says 'this
>     index is a free slot'.  Even in the latest -current,
>     fdalloc() releases the fdp lock when it goes to
>     MALLOC so the race appears to still be present.

The correct way to deal with this is to make the descriptor
slot allocation happen at a higher layer, and pass the address
of it in as an agrument to the code.

This will incidently let you pass in a static or other non-FD
table associated descriptor in place to all these calls, which
will have the effect of permitting you to do "descriptor" based
file I/O from kernel space much, much easier.

If the work would be accepted as a delta against -stable, I
would be willing to do it, since I need kernel file I/O, and
the problem hasn't been solving itself for about six years now.

-- Terry

To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-current" in the body of the message

Reply via email to