aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHans Petter Selasky <hselasky@FreeBSD.org>2020-05-22 09:01:26 +0000
committerHans Petter Selasky <hselasky@FreeBSD.org>2020-05-22 09:01:26 +0000
commitced76afa5b2b1b529b0e5271528237119f92a5b0 (patch)
tree43075d8f1ca5081653676181e8c29a1d19fd0590
parent1c51f8afbba8cfc9e166fd18361d340d55836b85 (diff)
downloadsrc-ced76afa5b2b1b529b0e5271528237119f92a5b0.tar.gz
src-ced76afa5b2b1b529b0e5271528237119f92a5b0.zip
MFC r361075:
Assign process group of the TTY under the "proctree_lock". This fixes a race where concurrent calls to doenterpgrp() and leavepgrp() while TIOCSCTTY is executing may result in tp->t_pgrp changing value so that tty_rel_pgrp() misses clearing it to NULL. For more details refer to the use of pgdelete() in the kernel. No functional change intended. Panic backtrace: __mtx_lock_sleep() # page fault due to using destroyed mutex tty_signal_pgrp() tty_ioctl() ptsdev_ioctl() kern_ioctl() sys_ioctl() amd64_syscall() Sponsored by: Mellanox Technologies
Notes
Notes: svn path=/stable/10/; revision=361358
-rw-r--r--sys/kern/tty.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/sys/kern/tty.c b/sys/kern/tty.c
index e9771501ff53..84e690bd7499 100644
--- a/sys/kern/tty.c
+++ b/sys/kern/tty.c
@@ -1721,7 +1721,6 @@ tty_generic_ioctl(struct tty *tp, u_long cmd, void *data, int fflag,
tp->t_session = p->p_session;
tp->t_session->s_ttyp = tp;
tp->t_sessioncnt++;
- sx_xunlock(&proctree_lock);
/* Assign foreground process group. */
tp->t_pgrp = p->p_pgrp;
@@ -1729,6 +1728,7 @@ tty_generic_ioctl(struct tty *tp, u_long cmd, void *data, int fflag,
p->p_flag |= P_CONTROLT;
PROC_UNLOCK(p);
+ sx_xunlock(&proctree_lock);
return (0);
}
case TIOCSPGRP: {