/lib/modules/6.6.117-45.1.oc9.x86_64/kernel/crypto/twofish-x86_64.ko.xz(GPL 许可,内核自带模块,白名单第 1 类)。仅只读静态解析,模块从未被加载执行。Linux kernel module analysis with rea — a real .ko, decoded
Linux kernel module analysis is one of those tasks that looks simple until you try it: a .ko file is a relocatable ELF, but most of what matters in it — modinfo metadata, __versions CRC tables, ksymtab sections, the appended PKCS#7 signature — lives outside what a plain readelf -S pass surfaces. In this guide we run linux kernel module analysis with rea (rea-agents 6.8.0) against a real cryptographic module that ships with the Linux kernel itself, and show the complete evidence output. Every line below is from our lab machine, run 2026-11-03.
Prerequisites: the setup from our REA setup guide. No root, no loaded module, no kernel headers needed — rea's linux kernel module analysis is purely static, and the evidence contract says so explicitly.
The target — a kernel-shipped Twofish cipher module
We picked twofish-x86_64.ko because it is small (15,481 bytes decompressed), license-clean (GPL), and present on virtually every distro — you can repeat this linux kernel module analysis on your own machine in under a minute. We decompressed it with xz -dc and pointed rea at the result:
bash — lab@realearn (rea-agents 6.8.0, static inspect) verified: ran 2026-11-03
$ xz -dc /lib/modules/6.6.117-45.1.oc9.x86_64/kernel/crypto/twofish-x86_64.ko.xz > /tmp/twofish-x86_64.ko $ npx rea inspect-kernel-module /tmp/twofish-x86_64.ko evidence_id: ev_d98a16d330f1ceded118f63e7f8ee6ccf3bae2de0b9a58c5b816586915b42ed8 subject: twofish-x86_64.ko / sha256 3cb3069167260a7d50224def8227ed0dcd245e35aaf3ac25fa41084ff8ceedde / elf / x86_64 / 15481 bytes provider: rea-kernel-module parser v1 format: elf64 · little-endian · machine 62 · type relocatable · applicability: applicable coverage: complete (examined_entries 20) confidence: observed
Note what rea does not claim: confidence: observed means the parser read real bytes at real offsets — every value below carries its own offset and sha256 in the raw evidence, so the same file re-analyzed reproduces the same content-addressed evidence_id. That is the difference between a screenshot and evidence.
modinfo — 12 entries, straight from the binary
The first thing linux kernel module analysis usually needs is the metadata block. rea located it at file offset 5336 (302 bytes) and decoded all 12 entries:
| key | value (observed) |
|---|---|
| alias | crypto-twofish-asm |
| alias | twofish-asm |
| alias | crypto-twofish |
| alias | twofish |
| description | Twofish Cipher Algorithm, asm optimized |
| license | GPL |
| srcversion | 4688CE86A435111427AA5B8 |
| depends | twofish_common |
| retpoline | Y |
| intree | Y |
| name | twofish_x86_64 |
| vermagic | 6.6.117-45.1.oc9.x86_64 SMP mod_unload modversions |
The two entries that matter most for real linux kernel module analysis triage: vermagic and depends. vermagic is the kernel-build fingerprint — SMP, mod_unload, and crucially modversions, which tells you symbol CRCs are in play. depends: twofish_common tells you this module will not satisfy a load on its own. If you have ever hit Invalid module format, the vermagic string in the modinfo block is the first thing to compare against your running kernel — and now you can read it without loading anything.
__versions — the symbol CRC table
Because this module was built with modversions, rea decoded the classic __versions table at offset 5920: six 64-byte entries, layout: elf64_unsigned_long_name56. Each pairs a symbol name with the CRC the module was built against:
text — __versions table, decoded (offset 5920, 6 entries) verified: ran 2026-11-03
index 0 crc 000000002d03e1e7 crypto_unregister_alg index 1 crc 00000000bdfb6dbb __fentry__ index 2 crc 0000000061fa9e12 crypto_register_alg index 3 crc 00000000308e51bd twofish_setkey index 4 crc 000000005b8239ca __x86_return_thunk index 5 crc 00000000d8e7190a module_layout
module_layout is the one to watch: its CRC changes across kernel builds even when source is unchanged, which is exactly why out-of-tree modules break after a distro kernel update. A CRC mismatch between this table and the running kernel's symbol table is the mechanical cause of "Unknown symbol in module" errors — linux kernel module analysis with rea surfaces it statically, before anyone attempts a load.
Alongside __versions, rea reported the GPL-only symbol sections __ksymtab_gpl (offset 4464) and __ksymtab_strings (offset 5880), plus init text (33 bytes) and exit text (28 bytes) — the module's entire executable footprint on load and unload.
The appended PKCS#7 signature
Distro kernels ship signed modules, and the signature is not an ELF section — it is appended after the ELF data, terminated by a 28-byte module_signature trailer. rea identified the magic at offset 15453, the PKCS#7 blob at offset 14760 (681 bytes, sha256 85459e662229022f4d2f7919781ffcb7266469fbdc9fd3bde182293a00439db1), and the signature info fields (algo 0 / hash 0 / id_type 2, sig_len 681).
What it does not do matters just as much: the evidence limitations state plainly that rea identifies and hashes the PKCS#7 bytes but does not validate the certificate chain, the signer, or digest coverage — [official docs] for the kernel's CONFIG_MODULE_SIG verification behavior, which happens at load time inside the kernel, not in any static tool. Good linux kernel module analysis tools are honest about this boundary; ours writes it into the evidence itself.
Limitations — what static linux kernel module analysis cannot see
Six limitations ship in the evidence, and they define the honest boundary of the whole technique:
- No module execution, no imported-symbol resolution, no signature validation.
struct modulein.gnu.linkonce.this_module(offset 7040, 1408 bytes, present) is kernel-version specific — layoutunknown, not decoded.__ksymtabentry layout is kernel-version specific — presence is reported, entries are not decoded.- Only classic
__versionsrecords are decoded; absence does not rule outCONFIG_EXTENDED_MODVERSIONSmetadata in__version_ext_names/__version_ext_crcs. - Metadata strings use a byte-preserving Latin1 projection; original encoding is unobserved.
- PKCS#7 bytes are identified and hashed, not verified.
The free upgrade path we have not run yet: /lib/modules on our lab box holds seven kernels, so a vermagic-vs-vermagic comparison matrix across builds is a one-afternoon follow-up. We will publish it when we run it — not before.
FAQ
Does linux kernel module analysis with rea require loading the module?
No. The entire workflow in this guide is static — the evidence records type: relocatable and the parser never loads, inserts, or executes anything. The limitations block states explicitly that the module is not executed.
Can it tell me why a module fails to load on my kernel?
It gives you the two artifacts you need to diagnose it yourself: the module's vermagic string and its __versions symbol CRC table. Compare them against your running kernel [official docs: kernel module signing/modversion documentation]. It will not perform the load-time check for you.
Where does the sample come from?
The Linux kernel itself — twofish-x86_64.ko.xz, GPL, shipped in /lib/modules on our lab machine. Same-command reruns reproduce the same evidence_id because rea evidence is content-addressed (see our evidence contract explainer).
Is this the same as running <code>modinfo</code>?
modinfo reads the same block, but it is a lookup tool. Linux kernel module analysis with rea returns the modinfo block plus the CRC table, ksymtab sections, init/exit text and the signature trailer in one content-addressed evidence record with per-entry offsets and hashes — the artifacts you need when the question is "what is actually inside this .ko".
Related: the REA setup guide (prerequisites) · the evidence contract (how evidence_id is derived) · ELF layout on three real targets (sister lesson) · linux crash dump analysis with rea · the measured 6.9.0 changelog (kernel-module metadata shipped in 6.8, CLI surface now 211 commands)