Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 18 Jul 2002 14:42:20 -0700
From:      Terry Lambert <tlambert2@mindspring.com>
To:        Matthew Dillon <dillon@apollo.backplane.com>
Cc:        John Baldwin <jhb@FreeBSD.ORG>, current@FreeBSD.ORG
Subject:   Re: Questions about kern_descrip.c
Message-ID:  <3D37363C.3DF4C315@mindspring.com>
References:  <XFMail.20020718134618.jhb@FreeBSD.org> <200207181840.g6IIe25G019269@apollo.backplane.com>

next in thread | previous in thread | raw e-mail | index | archive | help
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 majordomo@FreeBSD.org
with "unsubscribe freebsd-current" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?3D37363C.3DF4C315>