From owner-freebsd-current Thu Jul 18 14:43:18 2002 Delivered-To: freebsd-current@freebsd.org Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id A328A37B400; Thu, 18 Jul 2002 14:43:15 -0700 (PDT) Received: from gull.mail.pas.earthlink.net (gull.mail.pas.earthlink.net [207.217.120.84]) by mx1.FreeBSD.org (Postfix) with ESMTP id 3C2C643E58; Thu, 18 Jul 2002 14:43:15 -0700 (PDT) (envelope-from tlambert2@mindspring.com) Received: from pool0180.cvx22-bradley.dialup.earthlink.net ([209.179.198.180] helo=mindspring.com) by gull.mail.pas.earthlink.net with esmtp (Exim 3.33 #1) id 17VJ3B-00050n-00; Thu, 18 Jul 2002 14:43:05 -0700 Message-ID: <3D37363C.3DF4C315@mindspring.com> Date: Thu, 18 Jul 2002 14:42:20 -0700 From: Terry Lambert X-Mailer: Mozilla 4.79 [en] (Win98; U) X-Accept-Language: en MIME-Version: 1.0 To: Matthew Dillon Cc: John Baldwin , current@FreeBSD.ORG Subject: Re: Questions about kern_descrip.c References: <200207181840.g6IIe25G019269@apollo.backplane.com> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG 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