From nobody Thu Feb 29 00:29:43 2024 X-Original-To: dev-commits-src-branches@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 4TlXD73HSSz5Cj1J; Thu, 29 Feb 2024 00:29:43 +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 4TlXD72QPyz57gP; Thu, 29 Feb 2024 00:29:43 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1709166583; 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=+RuEqcybfvJaYB9zdkXc+td10Zib1IlPC/Es8RBJ9Vw=; b=qIGhikT9eF2ZFIo0UpFvOoFXw7x0CFg+m2e8UQA4m282MXcSSLuQ4Gkwd7gHeC646L66AI WkcxsAYVOV+xDHT5NwodS6HUttrmJ5KvoIWthB57+9IE7MFLXPCKjXaoQEf2BEqvX3joBv N8FTw+YLF8+l5ogCd1zEQ1QAZuVkdGYhJn1mNwqE/itslhF3vt1bsp6QuLNyHSYmLfSiyj vsJ8nOFD7MSqJ3Q4fEW+1fL+qyT+/GRJVHrQp45kmk/PO4xuGm7EGpik7YvgcxpBCwGt24 h9IETyM+mC3MHYQlqsawcCA5Fo+6W16uTFgCFHwvF7fhgJwbSP7hfKD+hsuZwg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1709166583; a=rsa-sha256; cv=none; b=S6njsEF/aszQo9iZRqHLA1qCOk+DdVJO1ok6DVjtvRFyZ7oQIYZp2ycfoCbEuj2sc2/ynU rpuJT1rIOlN5gSYdULU3ofmf5F7/iZhhPeQxyH/4jpqsuPHB03h32pdmUxaKo92bTihVgt eHy1ody05fjI+ROKmSnNGXR616B9xwnJKqmCaHFKWHlSRNEOnokBW9CYo8V836i04ozzDB 6kXVxh+TX3l3ZiWdbFUXE6tz9Zfak27j5UTtoKseez/R5DgnHTZgdQscx4d/2/wsdSS8V4 U9S2QG87Va9nMxRycNPOhp5BK9pV6fc6uBg5XVteX/iGWyVWA03984BsJiwHGQ== 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=1709166583; 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=+RuEqcybfvJaYB9zdkXc+td10Zib1IlPC/Es8RBJ9Vw=; b=FIvIbYPu7lJY8x/cmhcRHCr+nucTBT2UpVMZzL6lkikls/qLe7nGFWnHLKnW2Hs5rzI48d /QE8U+SkQ8lNTtzyXCsAjq0AuljnhloraUPbv/aMOliH+qT1Wr+dWOSYfZFR6X1ipMzoiY ZhLuuhzJhkj35zVcVxS7jl/S6XkWuC7vfRwFbze56wksWz8amGOC1Xr/eG+SJ/hGGUr1aR mDaBVwlM5AT44FFZQrRsa1VTONqM+Uh6o81u6fHg+SXCl+H9x2EFf86RcIefS4SDS7ifjd tpbg/geOSwKgECmPkeJ15/xaO/FTJ0HKlIhZrMiRNLsXiXop6QZinLAX0esNVw== 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 4TlXD722NczK9R; Thu, 29 Feb 2024 00:29:43 +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 41T0Th8g097583; Thu, 29 Feb 2024 00:29:43 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 41T0ThmN097580; Thu, 29 Feb 2024 00:29:43 GMT (envelope-from git) Date: Thu, 29 Feb 2024 00:29:43 GMT Message-Id: <202402290029.41T0ThmN097580@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: 8d22744f5be1 - stable/14 - kern: fix panic with disabled ttys List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@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/14 X-Git-Reftype: branch X-Git-Commit: 8d22744f5be165a2a82a2a204789e44bbdc5a2ee Auto-Submitted: auto-generated The branch stable/14 has been updated by emaste: URL: https://cgit.FreeBSD.org/src/commit/?id=8d22744f5be165a2a82a2a204789e44bbdc5a2ee commit 8d22744f5be165a2a82a2a204789e44bbdc5a2ee Author: Ed Maste AuthorDate: 2024-02-26 15:38:45 +0000 Commit: Ed Maste CommitDate: 2024-02-29 00:29:13 +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) --- 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 eaf6fe98fe2e..6848fbf558b0 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);