Date: Mon, 20 Mar 2006 15:28:51 GMT From: Todd Miller <millert@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 93628 for review Message-ID: <200603201528.k2KFSpwT013135@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=93628 Change 93628 by millert@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);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200603201528.k2KFSpwT013135>