NetBSD-Bugs archive

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

kern/40167: compat32's shadow sysctl tree is non-functional

>Number:         40167
>Category:       kern
>Synopsis:       compat32's shadow sysctl tree is non-functional
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    kern-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sun Dec 14 14:15:01 +0000 2008
>Originator:     Paul Goyette
>Release:        NetBSD 5.99.5
|   Paul Goyette   | PGP DSS Key fingerprint: |  E-mail addresses:   |
| Customer Service | FA29 0E3B 35AF E8AE 6651 |   |
| Network Engineer | 0786 F758 55DE 53BA 7731 | |
System: NetBSD 5.99.5 NetBSD 5.99.5 (QUICKY (ASUS M2N32 WS) 
2008-12-13 16:13:04) #3: Sat Dec 13 08:19:58 PST 2008
Architecture: x86_64
Machine: amd64
With the introduction of modular kernels, the netbsd32 "shadow" sysctl tree
is non-functional.  Routine netbsd32_sysctl_init() is called long after the
"real" sysctl tree has been initialized and "frozen" (by setting the
CTLFLAGS_PERMANENT bit in its root node), which causes sysctl_create() to
reject creation of the nodes _in_any_tree_ with error EPERM.

This can be seen by booting a modular kernel with options COMPAT_NETBSD32
and observe the following console messages:
        sysctl_createv: sysctl_create(kern) returned 1
        sysctl_createv: sysctl_locate(boottime) returned 2
        sysctl_createv: sysctl_create(vm) returned 1
        sysctl_createv: sysctl_locate(loadavg) returned 2
        sysctl_createv: sysctl_create(hw) returned 1
        sysctl_createv: sysctl_locate(machine) returned 2
        sysctl_createv: sysctl_locate(machine_arch) returned 2
Boot a modular kernel and watch for the above messages.
The following patch changes sysctl_create() to examine the PERMANENT flag
in the root of the tree being modified, rather than in the default tree.
It therefore checks if the tree being modified has previously been locked,
rather than checking the default tree.

Index: kern/kern_sysctl.c
RCS file: /cvsroot/src/sys/kern/kern_sysctl.c,v
retrieving revision 1.219
diff -u -p -r1.219 kern_sysctl.c
--- kern/kern_sysctl.c  12 Nov 2008 12:36:16 -0000      1.219
+++ kern/kern_sysctl.c  14 Dec 2008 14:01:33 -0000
@@ -733,7 +733,7 @@ sysctl_create(SYSCTLFN_ARGS)
         * the tree itself is not writeable or
         * the entire sysctl system is not writeable
-       if ((sysctl_root.sysctl_flags & CTLFLAG_PERMANENT) &&
+       if ((sysctl_rootof(rnode)->sysctl_flags & CTLFLAG_PERMANENT) &&
            (!(sysctl_rootof(rnode)->sysctl_flags & CTLFLAG_READWRITE) ||
             !(sysctl_root.sysctl_flags & CTLFLAG_READWRITE)))
                return (EPERM);


Home | Main Index | Thread Index | Old Index