NetBSD/share/man/man4/lkm.4

168 lines
6.0 KiB
Groff
Raw Normal View History

.\" $NetBSD: lkm.4,v 1.17 2001/09/22 01:22:49 wiz Exp $
.\"
1993-06-08 07:07:11 +04:00
.\" Copyright (c) 1993 Christopher G. Demetriou
.\" All rights reserved.
2001-06-12 15:39:02 +04:00
.\"
1993-06-08 07:07:11 +04:00
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\" notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\" 3. All advertising materials mentioning features or use of this software
.\" must display the following acknowledgement:
.\" This product includes software developed for the
.\" NetBSD Project. See http://www.netbsd.org/ for
.\" information about NetBSD.
.\" 4. The name of the author may not be used to endorse or promote products
.\" derived from this software without specific prior written permission.
2001-06-12 15:39:02 +04:00
.\"
1993-06-08 07:07:11 +04:00
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2001-06-12 15:39:02 +04:00
.\"
.\" <<Id: LICENSE,v 1.2 2000/06/14 15:57:33 cgd Exp>>
1993-06-08 07:07:11 +04:00
.\"
1993-09-05 07:55:21 +04:00
.Dd September 4, 1993
1993-06-08 07:07:11 +04:00
.Dt LKM 4
.Os
1993-06-08 07:07:11 +04:00
.Sh NAME
.Nm lkm
1993-06-08 07:07:11 +04:00
.Nd Loadable Kernel Modules interface
.Sh SYNOPSIS
.Cd "options LKM"
.Sh DESCRIPTION
Loadable kernel modules allow the system administrator to
dynamically add and remove functionality from a running system.
This ability also helps software developers to develop
new parts of the kernel without constantly rebooting to
test their changes.
.Pp
2000-07-05 06:30:18 +04:00
Various types of modules can be loaded into the system.
1993-06-08 07:07:11 +04:00
There are several defined module types, listed below, which can
be added to the system in a predefined way. In addition, there
is a generic type, for which the module itself handles loading and
unloading.
.Pp
The
.Nm
interface is used by performing
.Xr ioctl 2
calls on the
.Pa /dev/lkm
device. Normally all operations involving
Loadable Kernel Modules are handled by the
.Xr modload 8 ,
.Xr modunload 8 ,
and
.Xr modstat 8
programs. Users should never have to interact with
.Pa /dev/lkm
directly.
.Sh MODULE TYPES
.Ss System Call modules
1993-06-08 07:07:11 +04:00
System calls may be replaced by loading
new ones via the
.Nm
interface. All system calls may be
replaced, but special care should
be taken with the
.Xr ioctl 2
system call, as it is used to load and
unload modules.
.Pp
When a system call module is unloaded,
the system call which
was replaced by the loadable module
is returned to its rightful place
in the system call table by LKM code.
.Ss Virtual File System modules
Virtual file systems may be added via the
1993-06-08 07:07:11 +04:00
.Nm
interface.
.Ss Device Driver modules
1993-06-08 07:07:11 +04:00
New block and character device
drivers may be loaded into the system with
.Li "options LKM" .
A problem with loading a device driver is that the driver's device
nodes must be exist for the devices to be accessed. They are
usually created by instructing
1993-06-08 07:07:11 +04:00
.Xr modload 8
to run an appropriate program when the driver has been successfully loaded.
.Ss Emulation modules
2001-03-29 12:47:47 +04:00
Emulation modules allow to load an emulation support for foreign
operating systems.
.Ss Execution Interpreters
Execution interpreters allow to load support for execution of new type
of binaries, not normally supported by kernel. This also allows to load
2001-03-29 12:47:47 +04:00
support for executing foreign system binaries.
Execution Interpreters normally depend on
Emulation modules, in that appropriate Emulation module has to
be loaded before Execution Interpreter can be.
.Ss Miscellaneous modules
Miscellaneous modules are modules for which there are not currently
well-defined or well-used interfaces for extension.
They are provided for extension, and the user is expected to
write their own loader to handle the kernel pointer/table
manipulation to "wire in" their loaded module (and "unwire"
it on uload).
An example of a "miscellaneous module" might be a loader for
2001-06-12 15:39:02 +04:00
card-specific VGA drivers or alternate terminal emulations in
an appropriately layered console driver.
.Sh NOTES
.Ss Security considerations
Loaded kernel module can do anything with kernel structures. There is
no memory protection between module and rest of kernel. Hence, potential
attacker controlling
.Pa /dev/lkm
can do anything they want with the system.
.Pp
To avoid associated security risk, new LKMs cannot be loaded on
.Pa securelevel
higher than zero.
.Ss Module might crash system
Loading and using a buggy module is likely to crash operating system -
since the module becomes part of kernel, a code error is much more
fatal than for userland programs. If you are doing kernel development,
this would hopefully end up happening
less frequently than changing, recompiling, installing, and
2001-06-12 15:39:02 +04:00
rebooting would normally occur. This should speed development
considerably for a lot of the in-kernel work that is currently
taking place.
1993-06-08 07:07:11 +04:00
.Sh FILES
.Bl -tag -width /usr/include/sys/lkm.h -compact
.It Pa /dev/lkm
.Nm
interface device
.It Pa /usr/include/sys/lkm.h
2000-07-05 06:24:11 +04:00
file containing definitions of module types
.It Pa lkm/*
subdirectory
.Pa lkm
within kernel source tree contains many LKMs which are suitable as a base
for new ones
1999-03-10 12:29:08 +03:00
.El
1993-06-08 07:07:11 +04:00
.Sh SEE ALSO
.Xr modload 8 ,
.Xr modstat 8 ,
.Xr modunload 8
1993-06-08 07:07:11 +04:00
.Sh HISTORY
The
.Nm
facility was designed to be similar in functionality
to the loadable kernel modules facility provided by
.Tn "SunOS 4.1.3" .
.Sh AUTHORS
1993-06-08 07:07:11 +04:00
.Bl -tag
Terrence R. Lambert, terry@cs.weber.edu
.El