Skip to Content
Understanding the Linux Kernel, Second Edition
book

Understanding the Linux Kernel, Second Edition

by Daniel P. Bovet, Marco Cesati
December 2002
Intermediate to advanced
784 pages
27h 7m
English
O'Reilly Media, Inc.
Content preview from Understanding the Linux Kernel, Second Edition

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:

  1. Reads from the command line the name of the module to be linked.

  2. 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.

  3. Computes the size of the memory area needed to store the module code, its name, and the module object.

  4. Invokes the create_module( ) system call, passing to it the name and size of the new module. The corresponding sys_create_module( ) service routine performs the following operations:

    1. Checks whether the user is allowed to link the module (the current process must have the CAP_SYS_MODULE capability). 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.

    2. Invokes the find_module( ) function to scan the module_list list of module objects looking for a module with the specified name. If it is found, the module has already been linked, so the system call terminates.

    3. Invokes vmalloc( ) to allocate a memory area for the new module.

    4. Initializes the fields of the module object at the beginning of the memory area and copies the name of the module right below the object.

    5. Inserts the module object into the list pointed to by module_list.

    6. Returns the starting address of the memory area allocated to the module.

  5. Invokes ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Understanding the Linux Kernel, 3rd Edition

Understanding the Linux Kernel, 3rd Edition

Daniel P. Bovet, Marco Cesati
Understanding the Linux Kernel

Understanding the Linux Kernel

Daniel P. Bovet, Marco Cesati
Linux Kernel Programming

Linux Kernel Programming

Kaiwan N. Billimoria

Publisher Resources

ISBN: 0596002130Catalog PageErrata