Platform:Linux kernel
Appearance
| On this wiki | Facts · Code · Notes · Topics |
|---|
The Linux kernel as an analyst meets it in files: vmlinux and compressed boot images, loadable modules (.ko), the kallsyms symbol table, BTF type information and the initramfs archive.
Hub for the file artifacts of the Linux kernel (GPL-2.0, torvalds/linux). Kernel binaries are ELF files (vmlinux; .ko modules are ET_REL objects), but analysis often starts from something that is not ELF yet.
Topics
- Format:Linux x86 boot image (bzImage): setup header with
HdrS, boot protocol versions, the compressed payload that holds vmlinux. - Format:kallsyms: the compressed symbol table inside the image; how tools recover function names from a raw blob.
- Format:Linux kernel module (.ko):
.modinfo,__versionsCRCs,__ksymtablayouts,.gnu.linkonce.this_module. - Format:BTF (BPF Type Format): struct layouts and prototypes without DWARF.
- Format:cpio newc (initramfs): the
070701archive unpacked into the root filesystem at boot. - Format:Linux arm64 Image: the 64-byte AArch64 header with the
ARM\x64magic at 0x38. - Tool:Vmlinux-to-elf: rebuilds an analyzable ELF with symbols from a raw or compressed image.
- The version banner
Linux version ...is in every image: Fact:Linux kernel/string/Linux version banner;/proc/kallsymslines: Fact:Kallsyms/behavior/proc kallsyms format.
Workflow
- Identify the container: bzImage (
HdrSat 0x202), U-Boot uImage (27 05 19 56), Android boot.img (ANDROID!), or a plain vmlinux ELF. - Find and decompress the payload (gzip, xz, bzip2, lzma, lzo, lz4, zstd);
scripts/extract-vmlinuxin the kernel tree and vmlinux-to-elf do this. - Recover symbols from kallsyms and types from BTF when present.
- For modules read
.modinfofirst: vermagic gives the kernel release and configuration flags.
Pitfalls
- Layouts differ per kernel version and configuration (CONFIG_KALLSYMS_BASE_RELATIVE, CONFIG_MODVERSIONS, RANDSTRUCT); read the
Linux version ...banner before trusting a layout. - Vendor kernels (Android, router firmware) patch the upstream sources.