From owner-svn-src-head@FreeBSD.ORG Wed Oct 22 08:41:44 2014 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 47DC6C1C; Wed, 22 Oct 2014 08:41:44 +0000 (UTC) Received: from kib.kiev.ua (kib.kiev.ua [IPv6:2001:470:d5e7:1::1]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id AD40EB77; Wed, 22 Oct 2014 08:41:43 +0000 (UTC) Received: from tom.home (kostik@localhost [127.0.0.1]) by kib.kiev.ua (8.14.9/8.14.9) with ESMTP id s9M8fcYp002654 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 22 Oct 2014 11:41:38 +0300 (EEST) (envelope-from kostikbel@gmail.com) DKIM-Filter: OpenDKIM Filter v2.9.2 kib.kiev.ua s9M8fcYp002654 Received: (from kostik@localhost) by tom.home (8.14.9/8.14.9/Submit) id s9M8fca1002653; Wed, 22 Oct 2014 11:41:38 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: tom.home: kostik set sender to kostikbel@gmail.com using -f Date: Wed, 22 Oct 2014 11:41:38 +0300 From: Konstantin Belousov To: Mateusz Guzik Subject: Re: svn commit: r273441 - in head/sys: kern sys Message-ID: <20141022084138.GI1877@kib.kiev.ua> References: <201410220023.s9M0NiBX089974@svn.freebsd.org> <20141022075131.GG1877@kib.kiev.ua> <20141022082621.GB4393@dft-labs.eu> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20141022082621.GB4393@dft-labs.eu> User-Agent: Mutt/1.5.23 (2014-03-12) X-Spam-Status: No, score=-2.0 required=5.0 tests=ALL_TRUSTED,BAYES_00, DKIM_ADSP_CUSTOM_MED,FREEMAIL_FROM,NML_ADSP_CUSTOM_MED autolearn=no autolearn_force=no version=3.4.0 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on tom.home Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org, Mateusz Guzik X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 22 Oct 2014 08:41:44 -0000 On Wed, Oct 22, 2014 at 10:26:21AM +0200, Mateusz Guzik wrote: > On Wed, Oct 22, 2014 at 10:51:31AM +0300, Konstantin Belousov wrote: > > On Wed, Oct 22, 2014 at 12:23:44AM +0000, Mateusz Guzik wrote: > > > Author: mjg > > > Date: Wed Oct 22 00:23:43 2014 > > > New Revision: 273441 > > > URL: https://svnweb.freebsd.org/changeset/base/273441 > > > > > > Log: > > > filedesc: cleanup setugidsafety a little > > > > > > Rename it to fdsetugidsafety for consistency with other functions. > > > > > > There is no need to take filedesc lock if not closing any files. > > > > > > The loop has to verify each file and we are guaranteed fdtable has space > > > for at least 20 fds. As such there is no need to check fd_lastfile. > > ^^^^^^^^^^^^^^^^^^^^^^^^ * > > > [..] > > > fdp = td->td_proc->p_fd; > > > KASSERT(fdp->fd_refcnt == 1, ("the fdtable should not be shared")); > > > - FILEDESC_XLOCK(fdp); > > > - for (i = 0; i <= fdp->fd_lastfile; i++) { > > > - if (i > 2) > > > - break; > > > + for (i = 0; i <= 2; i++) { > > [*] This requires an assert. > > > > I was considering adding one, but failed to come up with anything good. > > Ideally we would compile-time assert that NDFILE is at least 3, but that > seems weirdly circumventable by sufficient accident. > > MPASS(fdp->fd_nfiles > 3) does not guarantee we wont run into trouble, > has a potential to help. What troubles do you mean ? Also, why > 3, and not >= 3 ? Old code used fd_lastfile, which, for purpose of the assert, is also fine.