PERFORCE change 93628 for review

Todd Miller millert at FreeBSD.org
Mon Mar 20 15:29:03 UTC 2006


http://perforce.freebsd.org/chv.cgi?CH=93628

Change 93628 by millert at millert_p3 on 2006/03/20 15:28:25

	Always zero fdp->fd_ofileflags[idx] when we NULL out
	fdp->fd_ofiles[idx].  Be more careful with locking
	fdp in fdcheckstd().  The current behavior is probably
	safe but a little paranoia goes a long way.

Affected files ...

.. //depot/projects/trustedbsd/sebsd/sys/kern/kern_descrip.c#19 edit

Differences ...

==== //depot/projects/trustedbsd/sebsd/sys/kern/kern_descrip.c#19 (text+ko) ====

@@ -1832,6 +1832,7 @@
 	FILEDESC_LOCK(fdp);
 	if (fdp->fd_ofiles[idx] == fp) {
 		fdp->fd_ofiles[idx] = NULL;
+		fdp->fd_ofileflags[idx] = 0;
 		fdunused(fdp, idx);
 		FILEDESC_UNLOCK(fdp);
 		fdrop(fp, td);
@@ -1911,12 +1912,18 @@
 	fdp = td->td_proc->p_fd;
 	if (fdp == NULL)
 		return (0);
+	FILEDESC_LOCK_FAST(fdp);
 	KASSERT(fdp->fd_refcnt == 1, ("the fdtable should not be shared"));
+	FILEDESC_UNLOCK_FAST(fdp);
 	devnull = -1;
 	error = 0;
 	for (i = 0; i < 3; i++) {
-		if (fdp->fd_ofiles[i] != NULL)
+		FILEDESC_LOCK_FAST(fdp);
+		if (fdp->fd_ofiles[i] != NULL) {
+			FILEDESC_UNLOCK_FAST(fdp);
 			continue;
+		}
+		FILEDESC_UNLOCK_FAST(fdp);
 		if (devnull < 0) {
 			int vfslocked;
 			error = falloc(td, &fp, &fd);
@@ -1938,6 +1945,7 @@
 				KASSERT(fdp->fd_ofiles[fd] == fp,
 				    ("table not shared, how did it change?"));
 				fdp->fd_ofiles[fd] = NULL;
+				fdp->fd_ofileflags[fd] = 0;
 				fdunused(fdp, fd);
 				FILEDESC_UNLOCK(fdp);
 				fdrop(fp, td);


More information about the trustedbsd-cvs mailing list