PERFORCE change 173670 for review
Jonathan Anderson
jona at FreeBSD.org
Mon Jan 25 16:10:03 UTC 2010
http://p4web.freebsd.org/chv.cgi?CH=173670
Change 173670 by jona at jona-belle-freebsd8 on 2010/01/25 16:09:42
Fixed dupfdopen() error in kern_openat() - we must finstall() the file to give it a valid descriptor before dupfdopen() is called
Affected files ...
.. //depot/projects/trustedbsd/capabilities/src/sys/kern/vfs_syscalls.c#26 edit
Differences ...
==== //depot/projects/trustedbsd/capabilities/src/sys/kern/vfs_syscalls.c#26 (text+ko) ====
@@ -74,6 +74,9 @@
#ifdef KTRACE
#include <sys/ktrace.h>
#endif
+#ifdef KDB
+#include <sys/kdb.h>
+#endif
#include <machine/stdarg.h>
@@ -1097,7 +1100,7 @@
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 @@
* 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 @@
}
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
More information about the p4-projects
mailing list