Linux Kernel Modules
Purpose
Guide agents through writing loadable Linux kernel modules (LKMs): the Kbuild build system, module parameters, /proc and sysfs interfaces, character device implementation, kernel debugging with KGDB and ftrace, and module signing for Secure Boot.
Triggers
- "How do I write a Linux kernel module?"
- "How do I add parameters to my kernel module?"
- "How do I create a /proc or sysfs entry?"
- "How do I implement a character device driver?"
- "How do I debug a kernel module with KGDB?"
- "How do I sign a kernel module for Secure Boot?"
Workflow
1. Minimal kernel module
2. Module parameters
3. /proc filesystem interface
4. sysfs interface
5. Character device
6. Debugging with KGDB and ftrace
7. EXPORT_SYMBOL vs EXPORT_SYMBOL_GPL
Use EXPORT_SYMBOL_GPL for symbols that touch GPL-only kernel internals. Loading a non-GPL module that imports GPL symbols fails with a taint warning. Check with modinfo and dmesg after insmod.
8. KUnit in-kernel unit tests
See skills/kernel/kernel-testing for full KUnit, kselftest, and syzkaller workflows.
9. Rust kernel modules (kernel 6.x + CONFIG_RUST=y)
Requires kernel built with CONFIG_RUST=y and appropriate Rust toolchain pinned by the kernel tree.
10. Module signing (Secure Boot, kernel 6.x)
Kernel 6.x enforces module signature verification when CONFIG_MODULE_SIG is enabled (default on most distro kernels with Secure Boot).
With lockdown integrity or confidentiality, unsigned modules are rejected. Distro kernels may also require keys enrolled in the kernel's built-in trusted keyring (CONFIG_SYSTEM_TRUSTED_KEYS).
For Kbuild system details, see references/kbuild-basics.md [blocked].
Related skills
- Use
skills/kernel/kernel-testingfor KUnit and kselftest harnesses - Use
skills/kernel/device-driversfor char/platform driver patterns beyond minimal modules - Use
skills/kernel/kernel-debuggingfor kgdb, ftrace, and kprobes - Use
skills/observability/ebpffor userspace kernel tracing without modules - Use
skills/debuggers/gdbfor GDB session management with KGDB - Use
skills/binaries/elf-inspectionfor inspecting module ELF structure


