elf_validity_ehdr(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… 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:


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