Proc locking.

This commit is contained in:
jhb 2001-01-23 23:59:38 +00:00
parent f5fbc62142
commit 80649f2bc1
6 changed files with 41 additions and 8 deletions

View File

@ -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;
}

View File

@ -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));
}

View File

@ -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;
}

View File

@ -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 */

View File

@ -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);
}

View File

@ -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) {