From owner-svn-src-projects@FreeBSD.ORG Sat Jan 30 19:44:37 2010 Return-Path: Delivered-To: svn-src-projects@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 57A0C1065676; Sat, 30 Jan 2010 19:44:37 +0000 (UTC) (envelope-from rwatson@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 2F4278FC0C; Sat, 30 Jan 2010 19:44:37 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o0UJibaH089715; Sat, 30 Jan 2010 19:44:37 GMT (envelope-from rwatson@svn.freebsd.org) Received: (from rwatson@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o0UJibZ8089713; Sat, 30 Jan 2010 19:44:37 GMT (envelope-from rwatson@svn.freebsd.org) Message-Id: <201001301944.o0UJibZ8089713@svn.freebsd.org> From: Robert Watson Date: Sat, 30 Jan 2010 19:44:37 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org X-SVN-Group: projects MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r203236 - projects/capabilities8/sys/kern X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 30 Jan 2010 19:44:37 -0000 Author: rwatson Date: Sat Jan 30 19:44:36 2010 New Revision: 203236 URL: http://svn.freebsd.org/changeset/base/203236 Log: Merge c173670 from the p4 TrustedBSD Capabilities branch to capabilities8: Fixed dupfdopen() error in kern_openat() - we must finstall() the file to give it a valid descriptor before dupfdopen() is called. Submitted by: Jonathan Anderson Modified: projects/capabilities8/sys/kern/vfs_syscalls.c Modified: projects/capabilities8/sys/kern/vfs_syscalls.c ============================================================================== --- projects/capabilities8/sys/kern/vfs_syscalls.c Sat Jan 30 19:43:27 2010 (r203235) +++ projects/capabilities8/sys/kern/vfs_syscalls.c Sat Jan 30 19:44:36 2010 (r203236) @@ -74,6 +74,9 @@ __FBSDID("$FreeBSD$"); #ifdef KTRACE #include #endif +#ifdef KDB +#include +#endif #include @@ -1097,7 +1100,7 @@ kern_openat(struct thread *td, int fd, c struct mount *mp; int cmode; struct file *nfp; - int type, indx, error; + int type, indx = -1, error; struct flock lf; struct nameidata nd; int vfslocked; @@ -1159,10 +1162,17 @@ kern_openat(struct thread *td, int fd, c * it ever should. */ if (!nd.ni_basedir && (error == ENODEV || error == ENXIO) && - td->td_dupfd >= 0 && /* XXX from fdopen */ - (error = - dupfdopen(td, fdp, indx, td->td_dupfd, flags, error)) == 0) - goto success; + td->td_dupfd >= 0) { + /* XXX from fdopen */ + int olderror = error; + + if ((error = finstall(td, fp, &indx)) != 0) + goto bad_unlocked; + + if ((error = dupfdopen(td, fdp, indx, td->td_dupfd, + flags, olderror)) == 0) + goto success; + } /* * Clean up the descriptor, but only if another thread hadn't @@ -1238,8 +1248,10 @@ success: } else #endif - if ((error = finstall(td, fp, &indx)) != 0) - goto bad_unlocked; + /* if we haven't already installed the FD (for dupfdopen), do so now */ + if (indx == -1) + if((error = finstall(td, fp, &indx)) != 0) + goto bad_unlocked; /* * Release our private reference, leaving the one associated with