elf_validity...he_index_mod(9)
π elf_validity_cache_index_mod(9) π
okay so bestie, this page is from the Kernel API Manual β¨ and it's giving βtiny validator with main character energyβ β but make no mistake, every check here matters. Let's get into it π«Ά
πΈ NAME πΈ
elf_validity_cache_index_mod β Validates and caches this_module section π
β¨ SYNOPSIS β¨
int elf_validity_cache_index_mod (struct load_info *info );
π ARGUMENTS π
infoβ Load info to cachethis_moduleon. Must haveload_info->sechdrsandload_info->secstringspopulated. No cap, those fields gotta be there π«‘
π¦ DESCRIPTION π¦
The .gnu.linkonce.this_module ELF section is special, okay? It's what modpost uses to refer to __this_module, and it's how we rely on THIS_MODULE pointing to __this_module properly. The kernel's modpost declares it on each module's *.mod.c file. And if the struct module of the kernel changes, a full kernel rebuild is required β like, literally, not optional π
We have a few expectations for this special section, and this function validates all of them for us:
- The section has contents β
- The section is unique β
- We expect the kernel to always have to allocate it:
SHF_ALLOCβ - The section size must match the kernel's run time's
struct modulesize β
If all checks pass, the index will be cached in load_info->index.mod β slay, cached and validated π
π₯ RETURN π₯
0 on validation success, -ENOEXEC on failure. That's the whole vibe check π€
π SEE ALSO π
Kernel file ./kernel/module/main.c and these besties:
find_any_unique_sec(9)is_module_percpu_address(9)module_refcount(9)verify_module_namespace(9)elf_validity_ehdr(9)elf_validity_cache_sechdrs(9)elf_validity_cache_secstrings(9)elf_validity_cache_index_info(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)
xoxo, your kernel bestie π
β source/version: ./kernel/module, dated October 2026 π
π¦ 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