From owner-svn-src-head@FreeBSD.ORG Wed Oct 22 08:26:28 2014 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id ADBBD77F; Wed, 22 Oct 2014 08:26:28 +0000 (UTC) Received: from mail-wi0-x236.google.com (mail-wi0-x236.google.com [IPv6:2a00:1450:400c:c05::236]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id C03779DF; Wed, 22 Oct 2014 08:26:27 +0000 (UTC) Received: by mail-wi0-f182.google.com with SMTP id bs8so615336wib.15 for ; Wed, 22 Oct 2014 01:26:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:from:to:cc:subject:message-id:references:mime-version :content-type:content-disposition:in-reply-to:user-agent; bh=dRixs16r4CTRcqYSSFqe3Zms82+v2/8ly47PwkAxYYQ=; b=K6GHpcag/TOVzbNjyHccSoyge1t6ZvLFZbh6waqoTQ4H+tDq1k9ReXAAUWAw76d8xB +zoWGeLKV+VZGKlSK43YLKcW7D8N/+K+b4WYZwtbV+vE7AUlhuQqplyaX69IXMW3kfEz 2DrA/7M0bdO0S/KcQkXrI8yShMZrlk/C+06gpfUrz9W9TEtviqMlkCzmJm5LqT6mSJs3 wFsXV/tu8WqbGALEAoz2YHyJL8utV7RzLY0MLOilCdUmS8i90crZTBE5i/p1NDIplavT v61X9Eaxqeo2vHjPgLQjOaRV9TBbldK3ZecfiObKnq4gGZR2ZjxcPZltpfAquQfGlVEJ ZziQ== X-Received: by 10.194.76.70 with SMTP id i6mr49953380wjw.13.1413966385112; Wed, 22 Oct 2014 01:26:25 -0700 (PDT) Received: from dft-labs.eu (n1x0n-1-pt.tunnel.tserv5.lon1.ipv6.he.net. [2001:470:1f08:1f7::2]) by mx.google.com with ESMTPSA id bi7sm1055877wib.17.2014.10.22.01.26.23 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Wed, 22 Oct 2014 01:26:24 -0700 (PDT) Date: Wed, 22 Oct 2014 10:26:21 +0200 From: Mateusz Guzik To: Konstantin Belousov Subject: Re: svn commit: r273441 - in head/sys: kern sys Message-ID: <20141022082621.GB4393@dft-labs.eu> References: <201410220023.s9M0NiBX089974@svn.freebsd.org> <20141022075131.GG1877@kib.kiev.ua> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20141022075131.GG1877@kib.kiev.ua> User-Agent: Mutt/1.5.21 (2010-09-15) 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:26:28 -0000 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. Any suggestions? -- Mateusz Guzik