From nobody Thu Feb 29 00:31:14 2024 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4TlXFt5v6vz5Cj9N; Thu, 29 Feb 2024 00:31:14 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4TlXFt5PnXz57tV; Thu, 29 Feb 2024 00:31:14 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1709166674; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=2fdBd1r1cxhmjdf2r3vrTGw1ux4j96cMGBacXIckVW0=; b=e5118036T0lTbFtnlt2KrREqQ/Q7d3ijvJwXZT1Antm2hXpUx9MbTBhzdjnDdAWYfVeB2Z q8h08xydfRWDvzI0GnuQO7iCzotJlQNI72W+ernYw5y8j1sdPA05Hx+qNOO5QfNDFj/QxJ OAtOwT6zqPq3/kCchFUk4pIx/nlEew6Xqpvh/1xqKFUV3T8zK5+oijl0cIyWDwGrYXfmU2 GQ7RDFps5d+U7VKa7fs6GCM2gZSd8+HKTh3+XTdzU2pVRLbMKcC7xQDuC3sCzfwfn8T1zE B9FLRV1ZggcyAB/WGM3u5MM+qLgvCNTkdb/s7Jp8lCPg1hvNMi8vtfeggZjskg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1709166674; a=rsa-sha256; cv=none; b=AEXMQUQHo+y7j0iNyL+FEprOklRs/mm3qj/sGlb3PqgEhPkrPRW9OZrY7co5fB0g7uB9ak jmsK8kz33zylAt6KNR7zk8g4oY9p7+ZlDPUI6DkG10m+AuIXFAKW9YsOmyzbqvshx9Jidg jjaJow+hfv1L5r5Q/GKLz6PvcY5n8i8ILOcfFX0re7/csqcqqPqK/6rMHcpqCfsYstKMYe 5ysQQk8ysEAse1GQOtSqRvCS0MZj8Rm34Qy6+3KJZNU9N7DxUFJmnMe4X5zwJZ9/4oeo5u +RIDWrSxuESCf99vQRCQZZNenuluCVZunt7s5kvHZv8tnESQjKzQBU+g7Tw53w== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1709166674; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=2fdBd1r1cxhmjdf2r3vrTGw1ux4j96cMGBacXIckVW0=; b=FdIEBf4dgKQOqLui3+pMQWnf9PuOOEcQSztnjUpdWRApY+wRaQOZ1spZ9rlpmcHRkiKvnI 5FdjVf9lEMsLY6aJElonWyPtPQxZYEcx9ze4G4bzaeJ7DQ8xE6NQnyeQQp/aczuRdUWN1Y QDXSkitxPfuLHZ4G5RQ25FFoYbXmjYnbkvnf1bfuNox3mlY4zJ+7yrsrw2wb5xn8iLBh6K bGkDLH8aq1t9qQkH8Ge/yjDvr9jCmTaD5t+yVocTbsSSsrEBapZRSuYH3hYklY/+pzqIaU xxBozlp7sQ8p9kgcFKkhZ8VhZsZZvp7Ifo8639zw4i88bmhFX7G6mOQJkgRLDA== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4TlXFt51jJzJqd; Thu, 29 Feb 2024 00:31:14 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 41T0VEgb010997; Thu, 29 Feb 2024 00:31:14 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 41T0VExS010994; Thu, 29 Feb 2024 00:31:14 GMT (envelope-from git) Date: Thu, 29 Feb 2024 00:31:14 GMT Message-Id: <202402290031.41T0VExS010994@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Ed Maste Subject: git: a60220bbb551 - stable/13 - kern: fix panic with disabled ttys List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: emaste X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: a60220bbb5511469fe53fd4290713ba891f8f48a Auto-Submitted: auto-generated The branch stable/13 has been updated by emaste: URL: https://cgit.FreeBSD.org/src/commit/?id=a60220bbb5511469fe53fd4290713ba891f8f48a commit a60220bbb5511469fe53fd4290713ba891f8f48a Author: Ed Maste AuthorDate: 2024-02-26 15:38:45 +0000 Commit: Ed Maste CommitDate: 2024-02-29 00:30:12 +0000 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) --- sys/kern/tty.c | 7 ++++--- 1 file 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);