From nobody@FreeBSD.org  Thu Jun 26 02:26:28 2008
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 0CE5A1065675
	for <freebsd-gnats-submit@FreeBSD.org>; Thu, 26 Jun 2008 02:26:28 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (www.freebsd.org [IPv6:2001:4f8:fff6::21])
	by mx1.freebsd.org (Postfix) with ESMTP id EB3AE8FC13
	for <freebsd-gnats-submit@FreeBSD.org>; Thu, 26 Jun 2008 02:26:27 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.14.2/8.14.2) with ESMTP id m5Q2QRqZ080488
	for <freebsd-gnats-submit@FreeBSD.org>; Thu, 26 Jun 2008 02:26:27 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.14.2/8.14.1/Submit) id m5Q2QR1q080487;
	Thu, 26 Jun 2008 02:26:27 GMT
	(envelope-from nobody)
Message-Id: <200806260226.m5Q2QR1q080487@www.freebsd.org>
Date: Thu, 26 Jun 2008 02:26:27 GMT
From: Arthur Hartwig <arthur.hartwig@nokia.com>
To: freebsd-gnats-submit@FreeBSD.org
Subject: "filesystem goof: vop_panic[vop_revoke]" panic on removal of USB serial adapter
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         124996
>Category:       kern
>Synopsis:       [patch] "filesystem goof: vop_panic[vop_revoke]" panic on removal of USB serial adapter
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    jh
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Thu Jun 26 02:30:06 UTC 2008
>Closed-Date:    Thu Jul 15 06:14:02 UTC 2010
>Last-Modified:  Thu Jul 15 06:14:02 UTC 2010
>Originator:     Arthur Hartwig
>Release:        6.3 and 7.0, i386 and amd64 architectures
>Organization:
Nokia
>Environment:
>Description:
Removal of a USB serial adapter over which a login has occurred can cause a variety of panics. I seem to have resolved most of them by including the changes in src/sys/kern/tty.c from revision 1.273 to 1.273.2.4 however the filesystem goof panic remains.


>How-To-Repeat:
Edit /etc/ttys to allow login on /dev/ttyU0, plug in USB serial adapter, run the included usb-login program to start getty/login on the USB serial adapter, login, issue a command that generates a fair amount of output (e.g. "dmesg") and while output is active remove the USB adapter. It may be necessary to repeat this a couple of times to provoke the panic. Note that I have seen at least three different panics produced by this procedure on released versions of both FreeBSD 6.3 and 7.0 but including the mentioned change to tty.c eliminates the panics other than the "filesystem goof".

I used a ATEN UC-232A as the USB to serial adapter (FreeBSD uplcom driver), plugged it into the FreeBSD system and connected the RS-232 side of the adapter to a serial port on a PC running Linux. I used minicom on the Linux system to access the serial port and set the serial port speed to 9600.

>Fix:
Update sys/kern/tty.c to include the changes in revision 1.273.2.4 from 1.273 and add:

       /* Since the hardware has gone, carrier is not asserted */
       CLR(tp->t_state, TS_CARR_ON);
       ttymodem(tp, 0);

to ttygone() immediately before the sequence of calls to wakeup().

I built the following program by the command:

# cc -Wall usb-login.c -o usb-login -lc -lutil

--------------------------- usb-login.c ---------------------------------------
#include <sys/types.h>
#include <sys/wait.h>
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <termios.h>
#include <libutil.h>
#include <unistd.h>

int main(int argc, char **argv)
{
        int tfd, rc, savefd, pid;
        struct termios tattr;

        tfd = open("/dev/ttyU0", O_RDWR | O_NONBLOCK);
        if (tfd == -1 ) {
                perror("open(ttyU0) failed");
                exit(EXIT_FAILURE);
        }

        fcntl(tfd, F_SETFL, 0);         /* Clear O_NONBLOCK */
        tcgetattr(tfd, &tattr);
        if ((tattr.c_cflag & CLOCAL) ==0) {
                /* Set terminal local so modem signals are ignored */
                tattr.c_cflag |= CLOCAL;
                tattr.c_ispeed = 9600;
                tattr.c_ospeed = 9600;
                tcsetattr(tfd, TCSANOW, &tattr);
        }

        pid = fork();
        if (pid == 0) {
                /* Child process */
                savefd = dup(0);
                rc = login_tty(tfd);
                if (rc == -1) {
                        perror("login_tty() failed");
                        exit(EXIT_FAILURE);
                }

                execl("/usr/libexec/getty", "getty", "std.9600", "-", NULL);

                dup2(savefd, 0);
        }
        else {
                printf("getty/login in process %d\n", pid);
                wait(&rc);
        }
        exit(EXIT_SUCCESS);


>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->feedback 
State-Changed-By: jh 
State-Changed-When: Wed Jun 30 18:13:14 UTC 2010 
State-Changed-Why:  
Can you still reproduce this on 8.0 or later? If you can, please provide 
the backtrace. 


Responsible-Changed-From-To: freebsd-bugs->jh 
Responsible-Changed-By: jh 
Responsible-Changed-When: Wed Jun 30 18:13:14 UTC 2010 
Responsible-Changed-Why:  
Track. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=124996 
State-Changed-From-To: feedback->closed 
State-Changed-By: remko 
State-Changed-When: Thu Jul 15 06:14:00 UTC 2010 
State-Changed-Why:  
Feedback timeout, Arthur is no longer available within Nokia (mail 
bounced) 

http://www.freebsd.org/cgi/query-pr.cgi?pr=124996 
>Unformatted:
