Date: Wed, 19 Jul 2006 18:39:28 GMT From: John Baldwin <jhb@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 101953 for review Message-ID: <200607191839.k6JIdSce075033@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=101953 Change 101953 by jhb@jhb_mutex on 2006/07/19 18:39:19 - Fixes to fchroot(): - vput() the vnode if any of the checks fail - vrele() the vnode after change_root() to drop our earlier VREF(). - Fixes to waitsys(): - Compile fixes since ru isn't a pointer. - Fix a few more places that have q vs p mixed up since I switched them to match the usage in kern_wait(). Affected files ... .. //depot/projects/smpng/sys/compat/svr4/svr4_misc.c#54 edit Differences ... ==== //depot/projects/smpng/sys/compat/svr4/svr4_misc.c#54 (text+ko) ==== @@ -620,13 +620,20 @@ vfslocked = VFS_LOCK_GIANT(vp->v_mount); vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, td); error = change_dir(vp, td); + if (error) + goto fail; #ifdef MAC - if (error == 0) - error = mac_check_vnode_chroot(td->td_ucred, vp); + error = mac_check_vnode_chroot(td->td_ucred, vp); + if (error) + goto fail; #endif VOP_UNLOCK(vp, 0, td); - if (error == 0) - error = change_root(vp, td); + error = change_root(vp, td); + vrele(vp); + VFS_UNLOCK_GIANT(vfslocked); + return (error); +fail: + vput(vp); VFS_UNLOCK_GIANT(vfslocked); return (error); } @@ -1138,7 +1145,7 @@ pid_t pid; int nfound, status; int error, *retval = td->td_retval; - struct proc *p, *q, *t; + struct proc *p, *q; DPRINTF(("waitsys(%d, %d, %p, %x)\n", uap->grp, uap->id, @@ -1151,9 +1158,9 @@ break; case SVR4_P_PGID: - PROC_LOCK(p); + PROC_LOCK(q); pid = -q->p_pgid; - PROC_UNLOCK(p); + PROC_UNLOCK(q); break; case SVR4_P_ALL: @@ -1204,7 +1211,7 @@ PROC_LOCK(p); if (pid != WAIT_ANY && p->p_pid != pid && p->p_pgid != -pid) { - PROC_UNLOCK(q); + PROC_UNLOCK(p); DPRINTF(("pid %d pgid %d != %d\n", p->p_pid, p->p_pgid, pid)); continue; @@ -1228,8 +1235,8 @@ /* Found a zombie, so cache info in local variables. */ pid = p->p_pid; status = p->p_xstat; - ru = p->p_ru; - calcru(p, &ru->ru_utime, &ru->ru_stime); + ru = *p->p_ru; + calcru(p, &ru.ru_utime, &ru.ru_stime); PROC_UNLOCK(p); sx_sunlock(&proctree_lock); @@ -1254,8 +1261,8 @@ sx_sunlock(&proctree_lock); pid = p->p_pid; status = W_STOPCODE(p->p_xstat); - ru = p->p_ru; - calcru(p, &ru->ru_utime, &ru->ru_stime); + ru = *p->p_ru; + calcru(p, &ru.ru_utime, &ru.ru_stime); PROC_UNLOCK(p); if (((uap->options & SVR4_WNOWAIT)) == 0) { @@ -1275,9 +1282,9 @@ if (((uap->options & SVR4_WNOWAIT)) == 0) p->p_flag &= ~P_CONTINUED; pid = p->p_pid; - ru = p->p_ru; + ru = *p->p_ru; status = SIGCONT; - calcru(p, &ru->ru_utime, &ru->ru_stime); + calcru(p, &ru.ru_utime, &ru.ru_stime); PROC_UNLOCK(p); if (((uap->options & SVR4_WNOWAIT)) == 0) {
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200607191839.k6JIdSce075033>