Manual Pages for Linux CentOS command on man finit_module
MyWebUniversity

Manual Pages for Linux CentOS command on man finit_module

INITMODULE(2) Linux Programmer's Manual INITMODULE(2)

NAME

initmodule, finitmodule - load a kernel module SYNOPSIS int initmodule(void *moduleimage, unsigned long len, const char *paramvalues); int finitmodule(int fd, const char *paramvalues, int flags); Note: There are no glibc wrappers for these system calls; see NOTES. DESCRIPTION initmodule() loads an ELF image into kernel space, performs any neces‐ sary symbol relocations, initializes module parameters to values pro‐ vided by the caller, and then runs the module's init function. This system call requires privilege. The moduleimage argument points to a buffer containing the binary image to be loaded; len specifies the size of that buffer. The module image should be a valid ELF image, built for the running kernel.

The paramvalues argument is a string containing space-delimited speci‐ fications of the values for module parameters (defined inside the mod‐ ule using moduleparam() and moduleparamarray()). The kernel parses this string and initializes the specified parameters. Each of the parameter specifications has the form: name[=value[,value...]] The parameter name is one of those defined within the module using mod‐ uleparam() (see the Linux kernel source file include/linux/mod‐ uleparam.h). The parameter value is optional in the case of bool and invbool parameters. Values for array parameters are specified as a

comma-separated list. finitmodule() The finitmodule() system call is like initmodule(), but reads the module to be loaded from the file descriptor fd. It is useful when the authenticity of a kernel module can be determined from its location in the file system; in cases where that is possible, the overhead of using cryptographically signed modules to determine the authenticity of a module can be avoided. The paramvalues argument is as for initmod‐ ule(). The flags argument modifies the operation of finitmodule(). It is a bit mask value created by ORing together zero or more of the following flags: MODULEINITIGNOREMODVERSIONS Ignore symbol version hashes. MODULEINITIGNOREVERMAGIC Ignore kernel version magic. There are some safety checks built into a module to ensure that it matches the kernel against which it is loaded. These checks are recorded when the module is built and verified when the module is loaded. First, the module records a "vermagic" string containing the kernel version number and prominent features (such as the CPU type). Second, if the module was built with the CONFIGMODVERSIONS configura‐ tion option enabled, a version hash is recorded for each symbol the module uses. This hash is based on the types of the arguments and return value for the function named by the symbol. In this case, the kernel version number within the "vermagic" string is ignored, as the symbol version hashes are assumed to be sufficiently reliable. Using the MODULEINITIGNOREVERMAGIC flag indicates that the "ver‐ magic" string is to be ignored, and the MODULEINITIGNOREMODVERSIONS flag indicates that the symbol version hashes are to be ignored. If the kernel is built to permit forced loading (i.e., configured with CONFIGMODULEFORCELOAD), then loading will continue, otherwise it will fail with ENOEXEC as expected for malformed modules. RETURN VALUE

On success, these system calls return 0. On error, -1 is returned and errno is set appropriately. ERRORS EBADMSG (since Linux 3.7) Module signature is misformatted. EBUSY Timeout while trying to resolve a symbol reference by this mod‐ ule. EFAULT An address argument referred to a location that is outside the process's accessible address space. ENOKEY (since Linux 3.7) Module signature is invalid or the kernel does not have a key for this module. This error is returned only if the kernel was configured with CONFIGMODULESIGFORCE; if the kernel was not configured with this option, then an invalid or unsigned module simply taints the kernel. ENOMEM Out of memory. EPERM The caller was not privileged (did not have the CAPSYSMODULE capability), or module loading is disabled (see /proc/sys/ker‐ nel/modulesdisabled in proc(5)). The following errors may additionally occur for initmodule(): EEXIST A module with this name is already loaded. EINVAL paramvalues is invalid, or some part of the ELF image in mod‐ uleimage contains inconsistencies. ENOEXEC The binary image supplied in moduleimage is not an ELF image, or is an ELF image that is invalid or for a different architec‐ ture. The following errors may additionally occur for finitmodule(): EBADF The file referred to by fd is not opened for reading. EFBIG The file referred to by fd is too large. EINVAL flags is invalid. ENOEXEC fd does not refer to an open file. In addition to the above errors, if the module's init function is exe‐ cuted and returns an error, then initmodule() or finitmodule() fails and errno is set to the value returned by the init function. VERSIONS finitmodule () is available since Linux 3.8. CONFORMING TO

initmodule() and finitmodule() are Linux-specific. NOTES Glibc does not provide a wrapper for these system calls; call them using syscall(2). Information about currently loaded modules can be found in /proc/mod‐

ules and in the file trees under the per-module subdirectories under /sys/module. See the Linux kernel source file include/linux/module.h for some useful background information. Linux 2.4 and earlier In Linux 2.4 and earlier, the initmodule() system call was rather dif‐ ferent:

#include int initmodule(const char *name, struct module *image);

(User-space applications can detect which version of initmodule() is available by calling querymodule(); the latter call fails with the error ENOSYS on Linux 2.6 and later.) The older version of the system call loads the relocated module image pointed to by image into kernel space and runs the module's init func‐ tion. The caller is responsible for providing the relocated image (since Linux 2.6, the initmodule() system call does the relocation). The module image begins with a module structure and is followed by code and data as appropriate. Since Linux 2.2, the module structure is defined as follows: struct module { unsigned long sizeofstruct; struct module *next; const char *name; unsigned long size; long usecount; unsigned long flags; unsigned int nsyms; unsigned int ndeps; struct modulesymbol *syms; struct moduleref *deps; struct moduleref *refs; int (*init)(void); void (*cleanup)(void); const struct exceptiontableentry *extablestart; const struct exceptiontableentry *extableend;

#ifdef alpha unsigned long gp;

#endif }; All of the pointer fields, with the exception of next and refs, are expected to point within the module body and be initialized as appro‐ priate for kernel space, that is, relocated with the rest of the mod‐ ule. SEE ALSO createmodule(2), deletemodule(2), querymodule(2), lsmod(8), mod‐ probe(8) COLOPHON

This page is part of release 3.53 of the Linux man-pages project. A description of the project, and information about reporting bugs, can

be found at http://www.kernel.org/doc/man-pages/.

Linux 2013-01-07 INITMODULE(2)




Contact us      |      About us      |      Term of use      |       Copyright © 2000-2019 MyWebUniversity.com ™