From nobody Thu Mar 28 05:07:53 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 4V4s492hXzz5GCrT; Thu, 28 Mar 2024 05:07:53 +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 4V4s4922Cbz4Wxm; Thu, 28 Mar 2024 05:07:53 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1711602473; 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=uF2kgbYEdJW6pYbMZIPtZLnM/Q2c39HZTw0CkjPbAsM=; b=AB0SVIHCPiA+FGvg0ZBAmLnq9EegEj19LZx8smGtaZCjmDBU3XtIvLATsgbj6Xzj6VpOPY hPp/K21ihudijzCuqtI+p1x8e5WL/SyWb1SzaPz0NF8nTVkKcdB3UuKXvHoLoaWd0EZPh+ msuKMpsMfCuSSCzeZSB6aeRcFjlT5hcn7KwuzNSysbVxOO7oxF3qvQtlszUTPm5xNqdbBF YRUHaRnIptIRlyEhv2e0/R5fqKSxHsrJGRlztmD8+fj/W6ZpTQigflwoWQaVd1DPfRDlfx u0dtePjR9ckto75gi/YMw/oyzULlC4FwpqpBEDCBnAdNeC2n2VkQj7W+WQHinw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1711602473; a=rsa-sha256; cv=none; b=vBTi1hJXuSrElavInRxnDBwqNdVQqzQYoaup/k0Fsa0iVmgdtECPrF1aH2sMVQt+IGro3Y nAeMr6pBV04Zsf+MwR6WwxgwkCcohmK9YTJLOfVxq1pquUyqB5nZShPAl74oSVn6hj3VHh 8IRr2hmzlxfSR8z9DciORL6eyzDEHkD2abi719FejxTuG8VzussFwRLtXMc+hiC8Qbtutj XHm5UgB3/oni5lc1Erh/WiZvRXCymOZUMG6TAyVoDRa8qMF9ZtOHUi5iO/q3skicsYW5+Q OCld0FJ++XO8McMACslFGs2IHp24dHDGktgdKs1Zi7nrf2RPE0OG/nPpHfmUzQ== 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=1711602473; 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=uF2kgbYEdJW6pYbMZIPtZLnM/Q2c39HZTw0CkjPbAsM=; b=PynoeGYjUdGB/Bjef9drDOD1rAAgsO4l7CGx8iiMpV5ogu1uPg6Hs8rWj1rcglb3djcFE5 hFCqLUJO1HMuoeD0dQaM18s9Ve9fRU9awZs0vutP+jveGEXj2u2pqSmOYGk0T8F00FzMnF 5B0HQu2ryfa5dbOGNFCcNhC7EqwO1/TV/C5R+7HQS5OTCtXJpJcxT8KzipYViCZLL01jHj YHyRTQcgKHHm2jqR0NKJuKi9uaPAVgOuxzoxIHbMJesbLlUz0YyRVr96+hfvl5eKf4670k bB/gk4yJM5Hr5KTca2uUJ7m8fp7DEEeR6kX1pxZ2GKfwqZ2PgsJ39YqcXW5a2g== 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 4V4s491dkzzDt6; Thu, 28 Mar 2024 05:07:53 +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 42S57rdD099729; Thu, 28 Mar 2024 05:07:53 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 42S57rV2099726; Thu, 28 Mar 2024 05:07:53 GMT (envelope-from git) Date: Thu, 28 Mar 2024 05:07:53 GMT Message-Id: <202403280507.42S57rV2099726@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Gordon Tetlow Subject: git: f3195cc08ccc - releng/13.2 - 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: gordon X-Git-Repository: src X-Git-Refname: refs/heads/releng/13.2 X-Git-Reftype: branch X-Git-Commit: f3195cc08ccc99365ec00900a3c1abc59ceefc9c Auto-Submitted: auto-generated The branch releng/13.2 has been updated by gordon: URL: https://cgit.FreeBSD.org/src/commit/?id=f3195cc08ccc99365ec00900a3c1abc59ceefc9c commit f3195cc08ccc99365ec00900a3c1abc59ceefc9c Author: Ed Maste AuthorDate: 2024-02-26 15:38:45 +0000 Commit: Gordon Tetlow CommitDate: 2024-03-28 03:05: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 Approved by: so Security: FreeBSD-EN-24:05.tty (cherry picked from commit 975d7730828a8bde28c2a0092b6e95c4c4e22f34) (cherry picked from commit 8d22744f5be165a2a82a2a204789e44bbdc5a2ee) (cherry picked from commit a60220bbb5511469fe53fd4290713ba891f8f48a) --- 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 22c4bb6dffce..92dee3ceefc9 100644 --- a/sys/kern/tty.c +++ b/sys/kern/tty.c @@ -1314,7 +1314,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); @@ -1327,8 +1328,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);