inspect_binary_layoutHow to REA Linux Kernel Modules (.ko): Modinfo, Vermagic & Unresolved Symbols
Audit loadable kernel modules (.ko), proprietary drivers, and suspected rootkits statically: extract .modinfo metadata, verify vermagic compatibility, inspect exported symbols (__ksymtab), and audit unresolved kernel APIs.
In this official REA guide for Linux Kernel Modules (.ko), AI coding agents (Claude Code, Cursor, Windsurf) execute 'rea inspect-binary-layout ./driver.ko --json' to safely extract file layout, symbols, and code logic without launching unverified binaries.
The Problem & Target Artifact
Incident response or driver vulnerability assessment: An unknown kernel module 'backdoor.ko' was recovered from a compromised server. You must determine what kernel symbols it hooks and which kernel versions it targets without inserting it into your own host kernel via insmod.
Natural Language Agent Instructions
Copy and paste this prompt directly into your AI coding agent when REA is registered via Model Context Protocol (MCP):
Use REA to inspect the binary layout of ./driver.ko. Extract the .modinfo section to find vermagic, license, and author, then list all undefined symbols (SHN_UNDEF) to identify kernel APIs it calls.Run REA Analysis Command
Execute the following command in your terminal or inspect the MCP JSON-RPC call executed by your agent:
rea inspect-binary-layout ./driver.ko --jsonWhat REA Extracts & Returns
Extracted Kernel Module Blueprint (.modinfo & Symbols)
The verified findings and synthesized clean-room structures generated from this investigation:
{
"image_type": "ET_REL",
"sections": [
{ "name": ".modinfo", "size": "0x140", "type": "SHT_PROGBITS" },
{ "name": "__ksymtab", "size": "0x30", "type": "SHT_PROGBITS" }
],
"modinfo": {
"vermagic": "6.8.0-45-generic SMP preempt mod_unload modversions",
"license": "GPL",
"retpoline": "Y",
"depends": "nf_conntrack"
},
"unresolved_symbols": ["printk", "nf_register_net_hook", "kfree"]
}Zero-Kernel-Crash Safety & Relocatable Relocation Traversal
Because kernel modules are relocatable objects (ET_REL), addresses inside the file are section-relative offsets rather than virtual memory addresses. REA never executes `insmod` or `modprobe`, preventing kernel panics, null-pointer dereferences, or hostile init() payloads from executing. It traverses section relocations (R_X86_64_64, R_X86_64_PC32) to map function call sites directly to candidate symbol entries.