Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 31 May 1999 16:33:15 -0700 (PDT)
From:      aron@cs.rice.edu
To:        freebsd-gnats-submit@freebsd.org
Subject:   kern/11968: kldload should call module entry point before initializing kernel data structures
Message-ID:  <19990531233315.BE40E14CE6@hub.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         11968
>Category:       kern
>Synopsis:       kldload should call module entry point before initializing kernel data structures
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Mon May 31 16:40:01 PDT 1999
>Closed-Date:
>Last-Modified:
>Originator:     Mohit Aron
>Release:        FreeBSD-3.2-RELEASE
>Organization:
Rice University
>Environment:
FreeBSD luzern.cs.rice.edu 3.2-RELEASE FreeBSD 3.2-RELEASE #2: Fri May 28 15:22:48 CDT 1999     aron@luzern.cs.rice.edu:/usr/src/sys/compile/LUZERN  i386
>Description:

It seems that kldload calls the entry point in the module only after
the kernel data structures pertaining to the module have been initialized. 
For example, if the module defines a new system call, the entry point
is called only after the name of the system call and its arguments have
been definined in the kernel. This deviates from modload which used to
call the entry point before doing such initializations. 

With the lkm interface, I used to have a boilerplate code for the 
module that used to call module specific initialization function to 
get the number of arguments for the syscall. Currently there's no way
to do this with the kld interface and the arguments and name of the
syscall has to be defined statically using the SYSCALL_MODULE(). 
Changing these later in the code for the module entry point has no 
effect. If the kld interface were to initialze the kernel structures
after calling the module entry point, it'll become possible for
dynamically specifying the number of arguments and name of the system
call. 

The above is more a matter of good taste in software engineering and 
so I'm putting the problem under the non-critical category with low
priority.



>How-To-Repeat:
Try increasing the number of arguments to the syscall defined in
/usr/share/examples/kld/syscall/module/syscall.c in the module 
entry point function - load(). This can be done by setting
hello_sysent.sy_narg to an appropriate value. Within the actual
system call, try printing the arguments. When you load this module
and the user application makes the system call with some arguments, 
all that the actual system call code gets is junk. This is because
the kernel already thinks that the system call needs no arguments (because
the number of arguments were 0 when SYSCALL_MODULE() was defined). 

>Fix:
The module entry point should be called before the kernel data structures
are initialized to reflect the name and number of arguments of the system
call being defined.

>Release-Note:
>Audit-Trail:
>Unformatted:


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




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