elf_validity_ehdr(9)
π elf_validity_ehdr(9) β like, the vibe check for ELF headers π€β¨
ok so real talk: this is from the Kernel API Manual, and it's the function that decides whether an ELF header is even allowed to be a module. bestie, it's the bouncer at the club π
β¨ SYNOPSIS β¨
int elf_validity_ehdr (const struct load_info *info );
π«Ά ARGUMENTS π«Ά
infoβ the load info struct that's carrying the ELF header we're about to judge. it's giving "show me what you're working with" π
πΈ DESCRIPTION πΈ
okay so what this does is check whether an ELF header could legitimately belong to a valid module. like, is this actually a module or is it cosplaying as one π it checks:
- the ELF header is actually inside the data the user handed over (no reaching outside the buffer, we don't do that here π)
- the ELF magic is present β¨ (yes the magic bytes, iconic behavior)
- it's relocatable β so like, not final linked, not a core file, etc. π
- the header's machine type matches what the architecture expects π
- there's an optional arch-specific hook for checking other properties π¦
and a lil note on that last one: module_elf_check_arch is currently only used by PPC to check the ELF ABI version, but ngl, others might use it in the future π (that's literally what the docs say, i'm not making it up)
β RETURN β
0 if valid, -ENOEXEC on failure π
so yeah β zero means slay, -ENOEXEC means "not today, bestie" π
π SEE ALSO π
Kernel file ./kernel/module/main.c plus the whole friend group:
find_any_unique_sec(9)is_module_percpu_address(9)module_refcount(9)verify_module_namespace(9)elf_validity_cache_sechdrs(9)elf_validity_cache_secstrings(9)elf_validity_cache_index_info(9)elf_validity_cache_index_mod(9)elf_validity_cache_index_sym(9)elf_validity_cache_index_str(9)elf_validity_cache_index_versions(9)elf_validity_cache_index(9)elf_validity_cache_strtab(9)is_module_address(9)__module_address(9)is_module_text_address(9)__module_text_address(9)
and that's the whole page, periodt π this lil gem lives in ./kernel/module and the version is October 2026 β iykyk π§ββοΈβ¨
π¦ where this page comes from
- nixpkgs unstable: linux-manual 7.3.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms