NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

kern/45420: kernel should verify both /dev/constty and /dev/console



>Number:         45420
>Category:       kern
>Synopsis:       kernel should verify both /dev/constty and /dev/console
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    kern-bug-people
>State:          open
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Tue Oct 04 18:35:00 +0000 2011
>Originator:     Greg A. Woods
>Release:        -current 2011/10/04
>Organization:
Planix, Inc.; Kelowna, BC; Canada
>Environment:
System: NetBSD
Architecture: all
Machine: all
>Description:

        the kernel checks to see if /dev/console exits, but fails to
        also check if /dev/constty exits

        both should exist for constty to be used properly

        also note the updated comment -- is it really that much more
        work to craft up open file descriptors for the active console
        device?

>How-To-Repeat:

>Fix:

--- init_main.c 28 Sep 2011 16:06:27 -0700      1.436
+++ init_main.c 04 Oct 2011 10:56:04 -0700      
@@ -832,6 +832,15 @@
                printf("warning: no /dev/console\n");
        else
                printf("warning: lookup /dev/console: error %d\n", error);
+
+       error = namei_simple_kernel("/dev/constty",
+                               NSM_FOLLOW_NOEMULROOT, &vp);
+       if (error == 0)
+               vrele(nd.ni_vp);
+       else if (error == ENOENT)
+               printf("warning: no /dev/constty\n");
+       else
+               printf("warning: lookup /dev/constty: error %d\n", error);
 }
 
 /*
@@ -881,10 +890,16 @@
        mutex_exit(proc_lock);
 
        /*
-        * This is not the right way to do this.  We really should
-        * hand-craft a descriptor onto /dev/console to hand to init,
-        * but that's a _lot_ more work, and the benefit from this easy
-        * hack makes up for the "good is the enemy of the best" effect.
+        * This is not the right way to do this.  We really should hand-craft
+        * descriptors onto the active console device we're using internally in
+        * the kernel, just as if they were open on /dev/constty, and pass
+        * those to init as its STDIO descriptors, but apparently that's a
+        * _lot_ more work.
+        *
+        * This easy hack at least leaves hints on the real console whenever
+        * there's a potential problem with the /dev/console and/or
+        * /dev/constty files; and init's attempts to hook on to the console
+        * will hopefully do for now.
         */
        check_console(l);
 



Home | Main Index | Thread Index | Old Index