Lock proctree_lock instead of pgrpsess_lock.
This commit is contained in:
parent
596325f154
commit
ba626c1db2
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=94861
@ -95,11 +95,11 @@
|
||||
|
||||
#define INIT_IN(in, op, ident, p) \
|
||||
(in)->opcode = (op); \
|
||||
PGRPSESS_SLOCK(); \
|
||||
sx_slock(&proctree_lock); \
|
||||
(in)->pid = p ? p->p_pid : -1; \
|
||||
(in)->pgid = p ? p->p_pgid : -1; \
|
||||
(in)->sid = (p && p->p_session && p->p_session->s_leader) ? (p->p_session->s_leader->p_pid) : -1; \
|
||||
PGRPSESS_SUNLOCK(); \
|
||||
sx_sunlock(&proctree_lock); \
|
||||
if (ident != NOCRED) { \
|
||||
(in)->cred.cr_uid = ident->cr_uid; \
|
||||
(in)->cred.cr_groupid = ident->cr_gid; \
|
||||
|
@ -95,11 +95,11 @@
|
||||
|
||||
#define INIT_IN(in, op, ident, p) \
|
||||
(in)->opcode = (op); \
|
||||
PGRPSESS_SLOCK(); \
|
||||
sx_slock(&proctree_lock); \
|
||||
(in)->pid = p ? p->p_pid : -1; \
|
||||
(in)->pgid = p ? p->p_pgid : -1; \
|
||||
(in)->sid = (p && p->p_session && p->p_session->s_leader) ? (p->p_session->s_leader->p_pid) : -1; \
|
||||
PGRPSESS_SUNLOCK(); \
|
||||
sx_sunlock(&proctree_lock); \
|
||||
if (ident != NOCRED) { \
|
||||
(in)->cred.cr_uid = ident->cr_uid; \
|
||||
(in)->cred.cr_groupid = ident->cr_gid; \
|
||||
|
@ -587,7 +587,7 @@ spec_close(ap)
|
||||
* plus the session), release the reference from the session.
|
||||
*/
|
||||
oldvp = NULL;
|
||||
PGRPSESS_XLOCK();
|
||||
sx_xlock(&proctree_lock);
|
||||
if (vcount(vp) == 2 && td && (vp->v_flag & VXLOCK) == 0 &&
|
||||
vp == td->td_proc->p_session->s_ttyvp) {
|
||||
SESS_LOCK(td->td_proc->p_session);
|
||||
@ -595,7 +595,7 @@ spec_close(ap)
|
||||
SESS_UNLOCK(td->td_proc->p_session);
|
||||
oldvp = vp;
|
||||
}
|
||||
PGRPSESS_XUNLOCK();
|
||||
sx_xunlock(&proctree_lock);
|
||||
if (oldvp != NULL)
|
||||
vrele(oldvp);
|
||||
/*
|
||||
|
@ -641,7 +641,7 @@ fsetown(pgid, sigiop)
|
||||
sigio->sio_ucred = crhold(curthread->td_ucred);
|
||||
sigio->sio_myref = sigiop;
|
||||
|
||||
PGRPSESS_SLOCK();
|
||||
sx_slock(&proctree_lock);
|
||||
if (pgid > 0) {
|
||||
proc = pfind(pgid);
|
||||
if (proc == NULL) {
|
||||
@ -699,14 +699,14 @@ fsetown(pgid, sigiop)
|
||||
sigio->sio_pgrp = pgrp;
|
||||
PGRP_UNLOCK(pgrp);
|
||||
}
|
||||
PGRPSESS_SUNLOCK();
|
||||
sx_sunlock(&proctree_lock);
|
||||
s = splhigh();
|
||||
*sigiop = sigio;
|
||||
splx(s);
|
||||
return (0);
|
||||
|
||||
fail:
|
||||
PGRPSESS_SUNLOCK();
|
||||
sx_sunlock(&proctree_lock);
|
||||
crfree(sigio->sio_ucred);
|
||||
FREE(sigio, M_SIGIO);
|
||||
return (ret);
|
||||
|
@ -538,7 +538,7 @@ fork1(td, flags, procp)
|
||||
FILEDESC_UNLOCK(p1->p_fd);
|
||||
} else
|
||||
fd = fdshare(p1);
|
||||
PGRPSESS_XLOCK();
|
||||
sx_xlock(&proctree_lock);
|
||||
PGRP_LOCK(p1->p_pgrp);
|
||||
PROC_LOCK(p2);
|
||||
p2->p_fd = fd;
|
||||
@ -573,7 +573,7 @@ fork1(td, flags, procp)
|
||||
PROC_UNLOCK(p1);
|
||||
PROC_UNLOCK(p2);
|
||||
PGRP_UNLOCK(p1->p_pgrp);
|
||||
PGRPSESS_XUNLOCK();
|
||||
sx_xunlock(&proctree_lock);
|
||||
|
||||
/*
|
||||
* Attach the new process to its parent.
|
||||
|
@ -357,16 +357,16 @@ ktrace(td, uap)
|
||||
/*
|
||||
* by process group
|
||||
*/
|
||||
PGRPSESS_SLOCK();
|
||||
sx_slock(&proctree_lock);
|
||||
pg = pgfind(-uap->pid);
|
||||
if (pg == NULL) {
|
||||
PGRPSESS_SUNLOCK();
|
||||
sx_sunlock(&proctree_lock);
|
||||
error = ESRCH;
|
||||
goto done;
|
||||
}
|
||||
/*
|
||||
* ktrops() may call vrele(). Lock pg_members
|
||||
* by the pgrpsess_lock rather than pg_mtx.
|
||||
* by the proctree_lock rather than pg_mtx.
|
||||
*/
|
||||
PGRP_UNLOCK(pg);
|
||||
LIST_FOREACH(p, &pg->pg_members, p_pglist)
|
||||
@ -374,7 +374,7 @@ ktrace(td, uap)
|
||||
ret |= ktrsetchildren(td, p, ops, facs, vp);
|
||||
else
|
||||
ret |= ktrops(td, p, ops, facs, vp);
|
||||
PGRPSESS_SUNLOCK();
|
||||
sx_sunlock(&proctree_lock);
|
||||
} else {
|
||||
/*
|
||||
* by pid
|
||||
|
@ -110,18 +110,18 @@ getpriority(td, uap)
|
||||
case PRIO_PGRP: {
|
||||
register struct pgrp *pg;
|
||||
|
||||
PGRPSESS_SLOCK();
|
||||
sx_slock(&proctree_lock);
|
||||
if (uap->who == 0) {
|
||||
pg = td->td_proc->p_pgrp;
|
||||
PGRP_LOCK(pg);
|
||||
} else {
|
||||
pg = pgfind(uap->who);
|
||||
if (pg == NULL) {
|
||||
PGRPSESS_SUNLOCK();
|
||||
sx_sunlock(&proctree_lock);
|
||||
break;
|
||||
}
|
||||
}
|
||||
PGRPSESS_SUNLOCK();
|
||||
sx_sunlock(&proctree_lock);
|
||||
LIST_FOREACH(p, &pg->pg_members, p_pglist) {
|
||||
PROC_LOCK(p);
|
||||
if (!p_cansee(td->td_proc, p) && p->p_ksegrp.kg_nice /* XXXKSE */ < low)
|
||||
@ -200,18 +200,18 @@ setpriority(td, uap)
|
||||
case PRIO_PGRP: {
|
||||
register struct pgrp *pg;
|
||||
|
||||
PGRPSESS_SLOCK();
|
||||
sx_slock(&proctree_lock);
|
||||
if (uap->who == 0) {
|
||||
pg = curp->p_pgrp;
|
||||
PGRP_LOCK(pg);
|
||||
} else {
|
||||
pg = pgfind(uap->who);
|
||||
if (pg == NULL) {
|
||||
PGRPSESS_SUNLOCK();
|
||||
sx_sunlock(&proctree_lock);
|
||||
break;
|
||||
}
|
||||
}
|
||||
PGRPSESS_SUNLOCK();
|
||||
sx_sunlock(&proctree_lock);
|
||||
LIST_FOREACH(p, &pg->pg_members, p_pglist) {
|
||||
PROC_LOCK(p);
|
||||
if (!p_cansee(td->td_proc, p)) {
|
||||
|
@ -1019,7 +1019,7 @@ killpg1(td, sig, pgid, all)
|
||||
}
|
||||
sx_sunlock(&allproc_lock);
|
||||
} else {
|
||||
PGRPSESS_SLOCK();
|
||||
sx_slock(&proctree_lock);
|
||||
if (pgid == 0) {
|
||||
/*
|
||||
* zero pgid means send to my process group.
|
||||
@ -1029,11 +1029,11 @@ killpg1(td, sig, pgid, all)
|
||||
} else {
|
||||
pgrp = pgfind(pgid);
|
||||
if (pgrp == NULL) {
|
||||
PGRPSESS_SUNLOCK();
|
||||
sx_sunlock(&proctree_lock);
|
||||
return (ESRCH);
|
||||
}
|
||||
}
|
||||
PGRPSESS_SUNLOCK();
|
||||
sx_sunlock(&proctree_lock);
|
||||
LIST_FOREACH(p, &pgrp->pg_members, p_pglist) {
|
||||
PROC_LOCK(p);
|
||||
if (p->p_pid <= 1 || p->p_flag & P_SYSTEM) {
|
||||
@ -1145,9 +1145,9 @@ gsignal(pgid, sig)
|
||||
struct pgrp *pgrp;
|
||||
|
||||
if (pgid != 0) {
|
||||
PGRPSESS_SLOCK();
|
||||
sx_slock(&proctree_lock);
|
||||
pgrp = pgfind(pgid);
|
||||
PGRPSESS_SUNLOCK();
|
||||
sx_sunlock(&proctree_lock);
|
||||
if (pgrp != NULL) {
|
||||
pgsignal(pgrp, sig, 0);
|
||||
PGRP_UNLOCK(pgrp);
|
||||
|
@ -794,9 +794,9 @@ aio_daemon(void *uproc)
|
||||
MALLOC(newsess, struct session *, sizeof(struct session), M_SESSION,
|
||||
M_WAITOK | M_ZERO);
|
||||
|
||||
PGRPSESS_XLOCK();
|
||||
sx_xlock(&proctree_lock);
|
||||
enterpgrp(mycp, mycp->p_pid, newpgrp, newsess);
|
||||
PGRPSESS_XUNLOCK();
|
||||
sx_xunlock(&proctree_lock);
|
||||
|
||||
/* Mark special process type. */
|
||||
mycp->p_flag |= P_SYSTEM;
|
||||
|
@ -701,9 +701,9 @@ vn_ioctl(fp, com, data, td)
|
||||
if (error == 0 && com == TIOCSCTTY) {
|
||||
|
||||
/* Do nothing if reassigning same control tty */
|
||||
PGRPSESS_SLOCK();
|
||||
sx_slock(&proctree_lock);
|
||||
if (td->td_proc->p_session->s_ttyvp == vp) {
|
||||
PGRPSESS_SUNLOCK();
|
||||
sx_sunlock(&proctree_lock);
|
||||
return (0);
|
||||
}
|
||||
|
||||
@ -713,7 +713,7 @@ vn_ioctl(fp, com, data, td)
|
||||
td->td_proc->p_session->s_ttyvp = vp;
|
||||
SESS_UNLOCK(td->td_proc->p_session);
|
||||
|
||||
PGRPSESS_SUNLOCK();
|
||||
sx_sunlock(&proctree_lock);
|
||||
|
||||
/* Get rid of reference to old control tty */
|
||||
if (vpold)
|
||||
|
Loading…
Reference in New Issue
Block a user