diff --git a/sys/i386/ibcs2/ibcs2_fcntl.c b/sys/i386/ibcs2/ibcs2_fcntl.c index 88c9c1d8c854..61c37cc81888 100644 --- a/sys/i386/ibcs2/ibcs2_fcntl.c +++ b/sys/i386/ibcs2/ibcs2_fcntl.c @@ -188,14 +188,17 @@ ibcs2_open(p, uap) ret = spx_open(p, uap); } else #endif /* SPX_HACK */ + PROC_LOCK(p); if (!ret && !noctty && SESS_LEADER(p) && !(p->p_flag & P_CONTROLT)) { struct filedesc *fdp = p->p_fd; struct file *fp = fdp->fd_ofiles[p->p_retval[0]]; + PROC_UNLOCK(p); /* ignore any error, just give it a try */ if (fp->f_type == DTYPE_VNODE) fo_ioctl(fp, TIOCSCTTY, (caddr_t) 0, p); - } + } else + PROC_UNLOCK(p); return ret; } diff --git a/sys/i386/ibcs2/ibcs2_ioctl.c b/sys/i386/ibcs2/ibcs2_ioctl.c index bc188f4b13ee..1350c1ac6160 100644 --- a/sys/i386/ibcs2/ibcs2_ioctl.c +++ b/sys/i386/ibcs2/ibcs2_ioctl.c @@ -499,8 +499,11 @@ ibcs2_ioctl(p, uap) return ioctl(p, (struct ioctl_args *)uap); case IBCS2_TIOCGPGRP: - return copyout((caddr_t)&p->p_pgrp->pg_id, SCARG(uap, data), + PROC_LOCK(p); + error = copyout((caddr_t)&p->p_pgrp->pg_id, SCARG(uap, data), sizeof(p->p_pgrp->pg_id)); + PROC_UNLOCK(p); + return error; case IBCS2_TIOCSPGRP: /* XXX - is uap->data a pointer to pgid? */ { @@ -526,6 +529,7 @@ ibcs2_ioctl(p, uap) short bitx, bity; } ibcs2_jwinsize; + PROC_LOCK(p); ibcs2_jwinsize.bytex = 80; /* p->p_session->s_ttyp->t_winsize.ws_col; XXX */ ibcs2_jwinsize.bytey = 25; @@ -534,6 +538,7 @@ ibcs2_ioctl(p, uap) p->p_session->s_ttyp->t_winsize.ws_xpixel; ibcs2_jwinsize.bity = p->p_session->s_ttyp->t_winsize.ws_ypixel; + PROC_UNLOCK(p); return copyout((caddr_t)&ibcs2_jwinsize, SCARG(uap, data), sizeof(ibcs2_jwinsize)); } diff --git a/sys/i386/ibcs2/ibcs2_misc.c b/sys/i386/ibcs2/ibcs2_misc.c index de67da470878..b53788fb9695 100644 --- a/sys/i386/ibcs2/ibcs2_misc.c +++ b/sys/i386/ibcs2/ibcs2_misc.c @@ -122,6 +122,7 @@ ibcs2_ulimit(p, uap) return 0; #endif case IBCS2_GETPSIZE: + mtx_assert(&Giant, MA_OWNED); p->p_retval[0] = p->p_rlimit[RLIMIT_RSS].rlim_cur; /* XXX */ return 0; case IBCS2_GETDTABLESIZE: @@ -946,7 +947,9 @@ ibcs2_pgrpsys(p, uap) { switch (SCARG(uap, type)) { case 0: /* getpgrp */ + PROC_LOCK(p); p->p_retval[0] = p->p_pgrp->pg_id; + PROC_UNLOCK(p); return 0; case 1: /* setpgrp */ @@ -956,7 +959,9 @@ ibcs2_pgrpsys(p, uap) SCARG(&sa, pid) = 0; SCARG(&sa, pgid) = 0; setpgid(p, &sa); + PROC_LOCK(p); p->p_retval[0] = p->p_pgrp->pg_id; + PROC_UNLOCK(p); return 0; } diff --git a/sys/i386/ibcs2/ibcs2_other.c b/sys/i386/ibcs2/ibcs2_other.c index 3578b3a07e5d..23b97436e270 100644 --- a/sys/i386/ibcs2/ibcs2_other.c +++ b/sys/i386/ibcs2/ibcs2_other.c @@ -48,7 +48,9 @@ ibcs2_secure(struct proc *p, struct ibcs2_secure_args *uap) switch (uap->cmd) { case IBCS2_SECURE_GETLUID: /* get login uid */ + PROC_LOCK(p); p->p_retval[0] = p->p_ucred->cr_uid; + PROC_UNLOCK(p); return 0; case IBCS2_SECURE_SETLUID: /* set login uid */ diff --git a/sys/i386/ibcs2/ibcs2_signal.c b/sys/i386/ibcs2/ibcs2_signal.c index f8829f149760..70b5f57e4410 100644 --- a/sys/i386/ibcs2/ibcs2_signal.c +++ b/sys/i386/ibcs2/ibcs2_signal.c @@ -318,13 +318,16 @@ ibcs2_sigsys(p, uap) p->p_retval[0] = (int)sa.sa_handler; /* special sigset() check */ - if(IBCS2_SIGCALL(SCARG(uap, sig)) == IBCS2_SIGSET_MASK) + if(IBCS2_SIGCALL(SCARG(uap, sig)) == IBCS2_SIGSET_MASK) { + PROC_LOCK(p); /* check to make sure signal is not blocked */ if(sigismember(&p->p_sigmask, signum)) { /* return SIG_HOLD and unblock signal*/ p->p_retval[0] = (int)IBCS2_SIG_HOLD; SIGDELSET(p->p_sigmask, signum); } + PROC_UNLOCK(p); + } return 0; } @@ -369,7 +372,9 @@ ibcs2_sigsys(p, uap) sigset_t mask; struct sigsuspend_args sa; + PROC_LOCK(p); mask = p->p_sigmask; + PROC_UNLOCK(p); SIGDELSET(mask, signum); SCARG(&sa, sigmask) = &mask; return sigsuspend(p, &sa); @@ -391,7 +396,9 @@ ibcs2_sigprocmask(p, uap) if (SCARG(uap, oset) != NULL) { /* Fix the return value first if needed */ + PROC_LOCK(p); bsd_to_ibcs2_sigset(&p->p_sigmask, &iss); + PROC_UNLOCK(p); if ((error = copyout(&iss, SCARG(uap, oset), sizeof(iss))) != 0) return error; } @@ -405,7 +412,7 @@ ibcs2_sigprocmask(p, uap) ibcs2_to_bsd_sigset(&iss, &bss); - (void) splhigh(); + PROC_LOCK(p); switch (SCARG(uap, how)) { case IBCS2_SIG_BLOCK: @@ -427,7 +434,7 @@ ibcs2_sigprocmask(p, uap) break; } - (void) spl0(); + PROC_UNLOCK(p); return error; } @@ -440,8 +447,10 @@ ibcs2_sigpending(p, uap) sigset_t bss; ibcs2_sigset_t iss; + PROC_LOCK(p); bss = p->p_siglist; SIGSETAND(bss, p->p_sigmask); + PROC_UNLOCK(p); bsd_to_ibcs2_sigset(&bss, &iss); return copyout(&iss, SCARG(uap, mask), sizeof(iss)); @@ -473,7 +482,9 @@ ibcs2_pause(p, uap) sigset_t mask; struct sigsuspend_args sa; + PROC_LOCK(p); mask = p->p_sigmask; + PROC_UNLOCK(p); SCARG(&sa, sigmask) = &mask; return sigsuspend(p, &sa); } diff --git a/sys/i386/ibcs2/ibcs2_util.c b/sys/i386/ibcs2/ibcs2_util.c index 0a361fd39f30..1d710be46881 100644 --- a/sys/i386/ibcs2/ibcs2_util.c +++ b/sys/i386/ibcs2/ibcs2_util.c @@ -62,6 +62,7 @@ ibcs2_emul_find(p, sgp, prefix, path, pbuf, cflag) struct nameidata ndroot; struct vattr vat; struct vattr vatroot; + struct ucred *uc; int error; char *ptr, *buf, *cp; size_t sz, len; @@ -140,14 +141,20 @@ ibcs2_emul_find(p, sgp, prefix, path, pbuf, cflag) return error; } - if ((error = VOP_GETATTR(nd.ni_vp, &vat, p->p_ucred, p)) != 0) { + PROC_LOCK(p); + uc = p->p_ucred; + crhold(uc); + PROC_UNLOCK(p); + if ((error = VOP_GETATTR(nd.ni_vp, &vat, uc, p)) != 0) { + crfree(uc); goto done; } - if ((error = VOP_GETATTR(ndroot.ni_vp, &vatroot, p->p_ucred, p)) - != 0) { + if ((error = VOP_GETATTR(ndroot.ni_vp, &vatroot, uc, p)) != 0) { + crfree(uc); goto done; } + crfree(uc); if (vat.va_fsid == vatroot.va_fsid && vat.va_fileid == vatroot.va_fileid) {