From nobody Mon Feb 26 20:13:40 2024 X-Original-To: dev-commits-src-main@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 4TkBdd1fLdz5C5VF; Mon, 26 Feb 2024 20:13:41 +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 4TkBdd0ttwz45P7; Mon, 26 Feb 2024 20:13:41 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1708978421; 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=RuJ972vOX1OLfiq0tTtdO1hQ1tIlLLB253PI4LzAqJE=; b=RuPO8FeuyKjIytCkV1NDH3Spy2TzweLmi1pjvy7fc9ZNwwfuyIV09KZ34YFD0jpvDgHPDo C9p+Pu6Vy3iVEu8ntra8GpAcd3aHlG7QrugHlGJneFSnWSgPreaMxX+fjRX6u1MDLh9IV0 Is44Da7p+7T50heBTtsP6iq6yv743MdU69fGJJfhgj16oSwDoq0ukF9OL1CYYoaSI3DYJe EFaqzDMBX0UMQMyWrUCQ2a1L4l7U64OMu+7hsQtGQLNa5qakR9+sFm1QHlYv69bnQwyesc xd5j/wLmMAEeQLPJv5YzBVCv4eKqGfQFLhA/zc0MOIEXA+USNAh64Lqb7ePkHg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1708978421; a=rsa-sha256; cv=none; b=q7YYgTUxt9qop2Os0JnOCPPRViiRirk/PVHyGKGYnKrUvpk/PoeUgmsVTeyf28CQFjEung KPWwO0Vg9wagYcIT1MlqBZOxCQu1nzu6ZWvcX5jpg/KtJGenhue585+npDbQmr1Q/yaO3w 0HD7Fyh8pEnC3YPAbm+QexFYZXy2N5TaAOdnvso0I04aJKvQxANEalFjroo6/2m6woKhSn hlYiUaKFiopQBPwttf6eoyHpy1rwrSFSJtebBlgik635RiRoOJ6Igy7a+VOr+4yLMUyKoT bR8Bh4Iz4VI/wwTDOvyCQSAwU2o/UWGCgXrBGHH4CYXK8qxTOoldQhW2HSx1tA== 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=1708978421; 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=RuJ972vOX1OLfiq0tTtdO1hQ1tIlLLB253PI4LzAqJE=; b=BB3EW3NmLoLc8gZB4sQGraU4JNR+g5dShqIrwlgqiI2R1RYMxYhX4bAN1swbET86b2oDpD UhnPcYTlLdm8n8UelvTTafrbtcCv9d6Sv5z2T00F+1z5CyegorOuC1fvrIrzMedWBmcrlE ZVjTOLhQ6Y74QZ3IlwZnUObmavj2RYs3X3s4LjhZF0cZr8ejGaVd+lGUkFDTO7QBWBapMW mZqJY5dGfhYu1frWVOCRXFS1mcvU4WkRI4Ma2EdwUaboR8hX52kpPLTqd32PIoqaakd0Ee tNizS7UuF3Zjf2/36hLP0sdxyf1Kp0pjZbTzfNB0oPJDRGXGEWVOWQpKNnMy1Q== 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 4TkBdc73Tyzj79; Mon, 26 Feb 2024 20:13:40 +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 41QKDeGG004301; Mon, 26 Feb 2024 20:13:40 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 41QKDeuN004298; Mon, 26 Feb 2024 20:13:40 GMT (envelope-from git) Date: Mon, 26 Feb 2024 20:13:40 GMT Message-Id: <202402262013.41QKDeuN004298@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Ed Maste Subject: git: 975d7730828a - main - kern: fix panic with disabled ttys List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@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/main X-Git-Reftype: branch X-Git-Commit: 975d7730828a8bde28c2a0092b6e95c4c4e22f34 Auto-Submitted: auto-generated The branch main has been updated by emaste: URL: https://cgit.FreeBSD.org/src/commit/?id=975d7730828a8bde28c2a0092b6e95c4c4e22f34 commit 975d7730828a8bde28c2a0092b6e95c4c4e22f34 Author: Ed Maste AuthorDate: 2024-02-26 15:38:45 +0000 Commit: Ed Maste CommitDate: 2024-02-26 20:11:27 +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 --- 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 ba20f5727829..b6e300321e9c 100644 --- a/sys/kern/tty.c +++ b/sys/kern/tty.c @@ -1315,7 +1315,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); @@ -1328,8 +1329,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);