From owner-p4-projects@FreeBSD.ORG Mon Mar 20 15:28:53 2006 Return-Path: X-Original-To: p4-projects@freebsd.org Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id AF8A616A428; Mon, 20 Mar 2006 15:28:53 +0000 (UTC) X-Original-To: perforce@freebsd.org Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 8D90D16A41F for ; Mon, 20 Mar 2006 15:28:53 +0000 (UTC) (envelope-from millert@freebsd.org) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id 5DE1243D68 for ; Mon, 20 Mar 2006 15:28:51 +0000 (GMT) (envelope-from millert@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.13.1/8.13.1) with ESMTP id k2KFSp2Z013138 for ; Mon, 20 Mar 2006 15:28:51 GMT (envelope-from millert@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.1/8.13.1/Submit) id k2KFSpwT013135 for perforce@freebsd.org; Mon, 20 Mar 2006 15:28:51 GMT (envelope-from millert@freebsd.org) Date: Mon, 20 Mar 2006 15:28:51 GMT Message-Id: <200603201528.k2KFSpwT013135@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to millert@freebsd.org using -f From: Todd Miller To: Perforce Change Reviews Cc: Subject: PERFORCE change 93628 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 20 Mar 2006 15:28:54 -0000 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);