Fix races between tty.c and sessrele() / doenterpgrp() / leavepgrp(). The tty
code is still under giant lock, but the session/pgrp release code just used proctree_locks. This explains why moving the proctree_lock in sys/kern/tty.c rev. 1.258 did fix the panics in our SMP systems. This should also fix some race panics with revoked ttys. Reviewed by: jhb MFC after: 1 week
This commit is contained in:
parent
da7bf2bb26
commit
d7b167b57b
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=162452
@ -401,6 +401,7 @@ doenterpgrp(p, pgrp)
|
||||
fixjobc(p, pgrp, 1);
|
||||
fixjobc(p, p->p_pgrp, 0);
|
||||
|
||||
mtx_lock(&Giant); /* XXX TTY */
|
||||
PGRP_LOCK(pgrp);
|
||||
PGRP_LOCK(savepgrp);
|
||||
PROC_LOCK(p);
|
||||
@ -410,6 +411,7 @@ doenterpgrp(p, pgrp)
|
||||
LIST_INSERT_HEAD(&pgrp->pg_members, p, p_pglist);
|
||||
PGRP_UNLOCK(savepgrp);
|
||||
PGRP_UNLOCK(pgrp);
|
||||
mtx_unlock(&Giant); /* XXX TTY */
|
||||
if (LIST_EMPTY(&savepgrp->pg_members))
|
||||
pgdelete(savepgrp);
|
||||
}
|
||||
@ -425,12 +427,14 @@ leavepgrp(p)
|
||||
|
||||
sx_assert(&proctree_lock, SX_XLOCKED);
|
||||
savepgrp = p->p_pgrp;
|
||||
mtx_lock(&Giant); /* XXX TTY */
|
||||
PGRP_LOCK(savepgrp);
|
||||
PROC_LOCK(p);
|
||||
LIST_REMOVE(p, p_pglist);
|
||||
p->p_pgrp = NULL;
|
||||
PROC_UNLOCK(p);
|
||||
PGRP_UNLOCK(savepgrp);
|
||||
mtx_unlock(&Giant); /* XXX TTY */
|
||||
if (LIST_EMPTY(&savepgrp->pg_members))
|
||||
pgdelete(savepgrp);
|
||||
return (0);
|
||||
@ -455,6 +459,7 @@ pgdelete(pgrp)
|
||||
*/
|
||||
funsetownlst(&pgrp->pg_sigiolst);
|
||||
|
||||
mtx_lock(&Giant); /* XXX TTY */
|
||||
PGRP_LOCK(pgrp);
|
||||
if (pgrp->pg_session->s_ttyp != NULL &&
|
||||
pgrp->pg_session->s_ttyp->t_pgrp == pgrp)
|
||||
@ -465,6 +470,7 @@ pgdelete(pgrp)
|
||||
PGRP_UNLOCK(pgrp);
|
||||
mtx_destroy(&pgrp->pg_mtx);
|
||||
FREE(pgrp, M_PGRP);
|
||||
mtx_unlock(&Giant); /* XXX TTY */
|
||||
}
|
||||
|
||||
static void
|
||||
|
Loading…
Reference in New Issue
Block a user