From mboxrd@z Thu Jan 1 00:00:00 1970 From: Davide Libenzi Subject: Re: [PATCH/RFC 1/2] anon-inodes: Remove fd_install() from anon_inode_getfd() Date: Thu, 28 Feb 2008 12:04:10 -0800 (PST) Message-ID: References: <20080225191043.GA32342@lst.de> Mime-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Cc: Christoph Hellwig , linux-fsdevel@vger.kernel.org, Linux Kernel Mailing List , Avi Kivity , kvm-devel@lists.sourceforge.net, Andrew Morton , Al Viro To: Roland Dreier Return-path: Received: from x35.xmailserver.org ([64.71.152.41]:43485 "EHLO x35.xmailserver.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751040AbYB1UEM (ORCPT ); Thu, 28 Feb 2008 15:04:12 -0500 Received: from alien.or.mcafeemobile.com by x35.xmailserver.org with [XMail 1.25 ESMTP Server] id for from ; Thu, 28 Feb 2008 15:04:11 -0500 In-Reply-To: Sender: linux-fsdevel-owner@vger.kernel.org List-ID: On Wed, 27 Feb 2008, Roland Dreier wrote: > > http://git.kernel.org/?p=linux/kernel/git/viro/vfs-2.6.git;a=commit;h=49be4f8114e6ff0efdab10ebba2493fb67bc3034 > > Actually, looking closer at the kvm changes here, I think that > create_vcpu_fd() needs the same treatment as kvm_dev_ioctl_create_vm() > gets in the patch because of the race I mentioned in the changelog > for my patch: otherwise kvm_vcpu_release() could drop the last > reference to vcpu->kvm->filp before the get_file() gets an extra > reference. > > I'm beginning to think that moving the fd_install() out of > anon_inode_getfd() really is worth it to make a safer interface. If we let the caller call fd_install(), then it may be messed up WRT cleanup (fd, file, inode). How about removing the inode pointer handout altogether, and *doing* fd_install() inside anon_inode_getfd() like: if (pfile != NULL) { get_file(file); *pfile = file; } fd_install(fd, file); In this way, if the caller want the file* back, he gets the reference bumped before fd_install(). - Davide