Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 25 Jan 2003 20:40:18 +0100
From:      phk@freebsd.org
To:        "Peter Edwards" <pmedwards@eircom.net>
Cc:        freebsd-current@freebsd.org
Subject:   Re: Opening /dev/tty in session leader after controlling terminal is revoked causes panic. 
Message-ID:  <12903.1043523618@critter.freebsd.dk>
In-Reply-To: Your message of "Sat, 25 Jan 2003 18:34:06 GMT." <20030125183411.997FE43F43@mx1.FreeBSD.org> 

next in thread | previous in thread | raw e-mail | index | archive | help
In message <20030125183411.997FE43F43@mx1.FreeBSD.org>, "Peter Edwards" writes:

>The problem is in kern/tty_tty.c:ctty_clone. It's assuming that if the process
>has its P_CONTROLT flag set, then it's session has a valid vnode for it's
>controlling terminal. This doesn't hold if the terminal was revoked.

Can you try this patch ?

Index: tty_tty.c
===================================================================
RCS file: /home/ncvs/src/sys/kern/tty_tty.c,v
retrieving revision 1.46
diff -u -r1.46 tty_tty.c
--- tty_tty.c	19 Jan 2003 11:03:07 -0000	1.46
+++ tty_tty.c	25 Jan 2003 19:39:15 -0000
@@ -70,10 +70,12 @@
 		return;
 	if (strcmp(name, "tty"))
 		return;
-	if (curthread->td_proc->p_flag & P_CONTROLT)
-		*dev = curthread->td_proc->p_session->s_ttyvp->v_rdev;
-	else
+	if (!(curthread->td_proc->p_flag & P_CONTROLT))
+		*dev = ctty;
+	else if (curthread->td_proc->p_session->s_ttyvp == NULL)
 		*dev = ctty;
+	else
+		*dev = curthread->td_proc->p_session->s_ttyvp->v_rdev;
 }
 
 static void
-- 
Poul-Henning Kamp       | UNIX since Zilog Zeus 3.20
phk@FreeBSD.ORG         | TCP/IP since RFC 956
FreeBSD committer       | BSD since 4.3-tahoe    
Never attribute to malice what can adequately be explained by incompetence.

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-current" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?12903.1043523618>