aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEd Maste <emaste@FreeBSD.org>2024-02-26 15:38:45 +0000
committerEd Maste <emaste@FreeBSD.org>2024-02-29 13:16:47 +0000
commit814761540eb9d1e52d6210bf0468d379a9459be9 (patch)
treee3546d5041c4ddd74246e91c5800966594c84c1b
parent784695750ef3f73dec38150617684b9f757c787d (diff)
downloadsrc-814761540eb9d1e52d6210bf0468d379a9459be9.tar.gz
src-814761540eb9d1e52d6210bf0468d379a9459be9.zip
kern: fix panic with disabled ttys
PR: 277240, 277329 Reviewed by: kib (earlier version) Fixes: f1d0a0cbecf2 ("jail: Fix information leak.") MFC after: 3 days Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D44086 (cherry picked from commit 975d7730828a8bde28c2a0092b6e95c4c4e22f34) (cherry picked from commit 8d22744f5be165a2a82a2a204789e44bbdc5a2ee) (cherry picked from commit a60220bbb5511469fe53fd4290713ba891f8f48a) Approved by: re (cperciva)
-rw-r--r--sys/kern/tty.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/sys/kern/tty.c b/sys/kern/tty.c
index 508c0f14b861..8ed59fd166fa 100644
--- a/sys/kern/tty.c
+++ b/sys/kern/tty.c
@@ -1313,7 +1313,8 @@ sysctl_kern_ttys(SYSCTL_HANDLER_ARGS)
struct xtty *xtlist, *xt;
struct tty *tp;
struct proc *p;
- int cansee, error;
+ int error;
+ bool cansee;
sx_slock(&tty_list_sx);
lsize = tty_list_count * sizeof(struct xtty);
@@ -1326,8 +1327,8 @@ sysctl_kern_ttys(SYSCTL_HANDLER_ARGS)
TAILQ_FOREACH(tp, &tty_list, t_list) {
tty_lock(tp);
- if (tp->t_session != NULL) {
- p = tp->t_session->s_leader;
+ if (tp->t_session != NULL &&
+ (p = atomic_load_ptr(&tp->t_session->s_leader)) != NULL) {
PROC_LOCK(p);
cansee = (p_cansee(td, p) == 0);
PROC_UNLOCK(p);