From owner-svn-src-head@FreeBSD.ORG Fri Jun 28 01:03:52 2013 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 4B991ED2; Fri, 28 Jun 2013 01:03:52 +0000 (UTC) (envelope-from mjguzik@gmail.com) Received: from mail-we0-x229.google.com (mail-we0-x229.google.com [IPv6:2a00:1450:400c:c03::229]) by mx1.freebsd.org (Postfix) with ESMTP id 6209F194A; Fri, 28 Jun 2013 01:03:51 +0000 (UTC) Received: by mail-we0-f169.google.com with SMTP id n57so1093707wev.14 for ; Thu, 27 Jun 2013 18:03:50 -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=1PeIlRsjJy7WLzCDnnm0uMgYEDTWeJKk9FF7c1RW+iA=; b=almxupJDdkmxQdqMz9yhLlTIpox5h6f48gR0tCR7mx2uYiRCM8Q/4HTePwomPiokjJ IU+9a/eau047uzOvonP34a1k0zBhavEQM1cwcCkTwPhhlKnoo6KNZYcCftP/mIVD3QG5 +JGZ0JthEMfzucIkFwpIE91eLJZesVFqw4y8fwXgoTje6YSwi49WzCCgFiQ78A/mPCpp 5juAFKcb4MkQNyixY1xH6vAp731FAx7Ec2NrhyNLJxjq0ns3QQrEv77D5sLKqf29+veL UM5/n6vWmKHKOQslE92Ke30wkZwca/G8/KdFiAj2RdFdE/2RDb4a9p/3zj1CCbKbEc3F Ryxg== X-Received: by 10.194.176.41 with SMTP id cf9mr7809569wjc.66.1372381430548; Thu, 27 Jun 2013 18:03:50 -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 fo10sm6963951wib.8.2013.06.27.18.03.48 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Thu, 27 Jun 2013 18:03:49 -0700 (PDT) Date: Fri, 28 Jun 2013 03:03:46 +0200 From: Mateusz Guzik To: Mikolaj Golub Subject: Re: svn commit: r252313 - head/sys/kern Message-ID: <20130628010345.GA25051@dft-labs.eu> References: <201306271914.r5RJE4on047806@svn.freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <201306271914.r5RJE4on047806@svn.freebsd.org> User-Agent: Mutt/1.5.21 (2010-09-15) Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.14 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: Fri, 28 Jun 2013 01:03:52 -0000 On Thu, Jun 27, 2013 at 07:14:04PM +0000, Mikolaj Golub wrote: > Author: trociny > Date: Thu Jun 27 19:14:03 2013 > New Revision: 252313 > URL: http://svnweb.freebsd.org/changeset/base/252313 > > Log: > To avoid LOR, always drop the filedesc lock before exporting fd to sbuf. > > Reviewed by: kib > MFC after: 3 days > > Modified: > head/sys/kern/kern_descrip.c > > Modified: head/sys/kern/kern_descrip.c > ============================================================================== > --- head/sys/kern/kern_descrip.c Thu Jun 27 18:59:07 2013 (r252312) > +++ head/sys/kern/kern_descrip.c Thu Jun 27 19:14:03 2013 (r252313) > @@ -3427,12 +3427,10 @@ kern_proc_filedesc_out(struct proc *p, > * re-validate and re-evaluate its properties when > * the loop continues. > */ > - if (type == KF_TYPE_VNODE || type == KF_TYPE_FIFO) > - FILEDESC_SUNLOCK(fdp); > + FILEDESC_SUNLOCK(fdp); > error = export_fd_to_sb(data, type, i, fflags, refcnt, > offset, fd_cap_rights, kif, sb, &remainder); > - if (type == KF_TYPE_VNODE || type == KF_TYPE_FIFO) > - FILEDESC_SLOCK(fdp); > + FILEDESC_SLOCK(fdp); > if (error) > break; > } Is this really ok? What prevents given fd from going away during export_fd_to_sb execution? Both DTYPE_VNODE and DTYPE_FIFO pass down a vrefed vnode so these are safe. But for example DTYPE_SOCKET goes with fp->f_data, which can go away in the meantime (or I'm misreading the code). I suggest obtainng ref to fp and passing it down in all cases. -- Mateusz Guzik