diff options
| author | Konstantin Belousov <kib@FreeBSD.org> | 2020-12-17 19:51:39 +0000 |
|---|---|---|
| committer | Konstantin Belousov <kib@FreeBSD.org> | 2020-12-17 19:51:39 +0000 |
| commit | 551e205f6dfa469f4f32a166ee3fb691201d27a7 (patch) | |
| tree | 5d17034dc32d257c8c89e7adbe6e9f7ba2f65fef /sys/kern | |
| parent | 0ebcbcc0efdd733b11311c840c47cc22f83c7408 (diff) | |
Notes
Diffstat (limited to 'sys/kern')
| -rw-r--r-- | sys/kern/tty.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/sys/kern/tty.c b/sys/kern/tty.c index 7526638b92116..8d4d25a4ac0b6 100644 --- a/sys/kern/tty.c +++ b/sys/kern/tty.c @@ -1474,6 +1474,7 @@ void tty_signal_sessleader(struct tty *tp, int sig) { struct proc *p; + struct session *s; tty_assert_locked(tp); MPASS(sig >= 1 && sig < NSIG); @@ -1482,8 +1483,14 @@ tty_signal_sessleader(struct tty *tp, int sig) tp->t_flags &= ~TF_STOPPED; tp->t_termios.c_lflag &= ~FLUSHO; - if (tp->t_session != NULL && tp->t_session->s_leader != NULL) { - p = tp->t_session->s_leader; + /* + * Load s_leader exactly once to avoid race where s_leader is + * set to NULL by a concurrent invocation of killjobc() by the + * session leader. Note that we are not holding t_session's + * lock for the read. + */ + if ((s = tp->t_session) != NULL && + (p = atomic_load_ptr(&s->s_leader)) != NULL) { PROC_LOCK(p); kern_psignal(p, sig); PROC_UNLOCK(p); |
