Linking and Unlinking Modules
A user can link a module into the
running kernel by executing the
insmod
external program. This program performs
the following operations:
Reads from the command line the name of the module to be linked.
Locates the file containing the module’s object code in the system directory tree. The file is usually placed in some subdirectory below
/lib/modules.Computes the size of the memory area needed to store the module code, its name, and the
moduleobject.Invokes the
create_module( )system call, passing to it the name and size of the new module. The correspondingsys_create_module( )service routine performs the following operations:Checks whether the user is allowed to link the module (the current process must have the
CAP_SYS_MODULEcapability). In any situation where one is adding functionality to a kernel, which has access to all data and processes on the system, security is a paramount concern.Invokes the
find_module( )function to scan themodule_listlist ofmoduleobjects looking for a module with the specified name. If it is found, the module has already been linked, so the system call terminates.Invokes
vmalloc( )to allocate a memory area for the new module.Initializes the fields of the
moduleobject at the beginning of the memory area and copies the name of the module right below the object.Inserts the
moduleobject into the list pointed to bymodule_list.Returns the starting address of the memory area allocated to the module.
Invokes ...