Linux-Rootkit-Kernel-Modules-1
Part 1: Understanding Kernel Modules
1.1 What Are Kernel Modules?
┌─────────────────────────────────────────────┐
│ Userspace Applications │
│ (bash, firefox, your programs) │
└─────────────────────────────────────────────┘
↕ System Calls
┌─────────────────────────────────────────────┐
│ Linux Kernel Core │
│ • Process Management │
│ • Memory Management │
│ • File Systems │
└─────────────────────────────────────────────┘
↕
┌─────────────────────────────────────────────┐
│ Kernel Modules (Loadable) │
│ ┌──────────┐ ┌──────────┐ ┌──────────┐ │
│ │ USB │ │ Graphics │ │ Your │ │
│ │ Driver │ │ Driver │ │ Module │ │
│ └──────────┘ └──────────┘ └──────────┘ │
└─────────────────────────────────────────────┘
↕
┌─────────────────────────────────────────────┐
│ Hardware │
│ (CPU, RAM, USB devices, GPU) │
└─────────────────────────────────────────────┘1.2 Why Use Modules Instead of Built-in Code?
1.3 What Can Kernel Modules Do?
Part 2: Your First Kernel Module - "Hello World"
2.1 The Simplest Possible Module
2.2 Understanding Each Part
2.3 printk() - The Kernel's printf()
Part 3: Compiling Kernel Modules - The Makefile
3.1 Why We Need a Special Makefile
3.2 The Basic Makefile
3.3 Understanding the Makefile
3.4 Important Makefile Notes
Part 4: Building and Loading Your Module
4.1 Compilation
4.2 Checking Module Information
4.3 Loading the Module
4.4 Listing Loaded Modules
4.5 Unloading the Module
Part 5: Common Issues and Troubleshooting
5.1 "Module not found" Error
5.2 "Operation not permitted"
5.3 Module Won't Unload
5.4 Compilation Errors
Part 6: Module Parameters
6.1 What Are Module Parameters?
6.2 Adding Parameters
6.3 Using Parameters
6.4 Parameter Types
Part 7: Debugging Kernel Modules
7.1 Using printk() for Debugging
7.2 Controlling Log Verbosity
7.3 Dynamic Debug
Part 8: Practical Example - A Counter Module
8.1 The Code
8.2 Testing the Counter
8.3 What This Demonstrates
Part 9: Best Practices
9.1 Error Handling
9.2 Resource Cleanup
9.3 Naming Conventions
9.4 Static vs. Global
Part 10: Common Commands Reference
10.1 Module Management
10.2 Debugging Commands
10.3 Build Commands
Last updated