Loadable Kernel Modules: Adding a Driver Without a Restart
Adding hardware can mean adding a driver, the software that lets an operating system work with a device. When that driver is available as a loadable kernel module, the system can add it while it keeps running. The new code joins the operating system's core.
A loadable kernel module, or LKM, extends the kernel, which manages resources and provides services to programs. An ordinary application asks the kernel to do things on its behalf. A loaded module runs inside the kernel's privileged environment.
Device drivers are one use for modules. Filesystem support can also be supplied this way, allowing the system to work with a particular format for organizing files on storage. Whether a feature needs a module depends on the installation; its support may already be built into the kernel.
What Is a Kernel?
Joining a Running Linux Kernel
Linux makes the loading process concrete. Its module-loading interface places the module in kernel space, the area where privileged kernel code runs. It then calls the module's initialization function to prepare it for use.
The code must fit the running kernel and processor architecture. Linux checks compatibility information during loading, so a module built for a different environment may be rejected.
Loading also requires a specific module-loading privilege. A Linux system can disable module loading altogether. The Linux manual documents these checks. They govern who can add code that will operate with the kernel's authority.
Deciding Which Code Gets In
The same access that makes a driver useful can serve an attacker. MITRE, which catalogs attack techniques, documents malicious kernel modules used to maintain access or hide activity. Such a module can be part of a rootkit, software designed to conceal an intrusion.
The loading mechanism serves legitimate drivers too. The security question concerns the code being admitted and what it does after loading, which an unfamiliar module name alone cannot settle.
Linux can check a module's digital signature at the loading step. If the system requires a valid signature from a trusted key, it can reject modules that fail that requirement. A permissive configuration may allow unsigned modules instead.
The kernel project's signing documentation explains those choices. A successfully verified signature connects the signed contents to a signing key and checks that those contents have not changed. It does not inspect the code's intentions or guarantee freedom from bugs. The signature has to pass verification; a signature marker in the file is not enough.
- Finally understand what the commands you type are doing behind the scenes.
- Fix problems yourself instead of pasting in fixes you found online and hoping.
- Go from following tutorials to knowing why they work, one clear chapter at a time.
Other Code May Still Need the Module
Once a module is working, a running program may be using its services, or another module may depend on it. Ordinary removal can fail while those dependencies remain.
Linux's module-removal manual explicitly warns that forced unloading is dangerous. It can take away code that active work still needs. Adding a driver without restarting the machine does not mean the driver can safely disappear in the middle of its work.
The Kernel: How Programs Share One Computer

Rootkits: When a Computer Gives a Doctored Answer

System Integrity: Is the Computer Still Doing Its Intended Job?

QUOTE:
"Amateurs hack systems, professionals hack people."
