kernel/module/strict_rwx.c
Source file repositories/reference/linux-study-clean/kernel/module/strict_rwx.c
File Facts
- System
- Linux kernel
- Corpus path
kernel/module/strict_rwx.c- Extension
.c- Size
- 3622 bytes
- Lines
- 152
- Domain
- Core OS
- Bucket
- Scheduler, Processes, Timers, Sync, And Syscalls
- Inferred role
- Core OS: implementation source
- Status
- source implementation candidate
Why This File Exists
Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.
- Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/module.hlinux/mm.hlinux/vmalloc.hlinux/set_memory.hlinux/execmem.hinternal.h
Detected Declarations
function Copyrightfunction module_enable_text_roxfunction module_enable_rodata_rofunction module_enable_rodata_ro_after_initfunction module_enable_data_nxfunction for_class_mod_mem_typefunction module_enforce_rwx_sectionsfunction module_mark_ro_after_init
Annotated Snippet
if ((sechdrs[i].sh_flags & shf_wx) == shf_wx) {
pr_err("%s: section %s (index %d) has invalid WRITE|EXEC flags\n",
mod->name, secstrings + sechdrs[i].sh_name, i);
return -ENOEXEC;
}
}
return 0;
}
static const char *const ro_after_init[] = {
/*
* Section .data..ro_after_init holds data explicitly annotated by
* __ro_after_init.
*/
".data..ro_after_init",
/*
* Section __jump_table holds data structures that are never modified,
* with the exception of entries that refer to code in the __init
* section, which are marked as such at module load time.
*/
"__jump_table",
#ifdef CONFIG_HAVE_STATIC_CALL_INLINE
/*
* Section .static_call_sites holds data structures that need to be
* sorted and processed at module load time but are never modified
* afterwards.
*/
".static_call_sites",
#endif
};
void module_mark_ro_after_init(const Elf_Ehdr *hdr, Elf_Shdr *sechdrs,
const char *secstrings)
{
int i, j;
for (i = 1; i < hdr->e_shnum; i++) {
Elf_Shdr *shdr = &sechdrs[i];
for (j = 0; j < ARRAY_SIZE(ro_after_init); j++) {
if (strcmp(secstrings + shdr->sh_name,
ro_after_init[j]) == 0) {
shdr->sh_flags |= SHF_RO_AFTER_INIT;
break;
}
}
}
}
Annotation
- Immediate include surface: `linux/module.h`, `linux/mm.h`, `linux/vmalloc.h`, `linux/set_memory.h`, `linux/execmem.h`, `internal.h`.
- Detected declarations: `function Copyright`, `function module_enable_text_rox`, `function module_enable_rodata_ro`, `function module_enable_rodata_ro_after_init`, `function module_enable_data_nx`, `function for_class_mod_mem_type`, `function module_enforce_rwx_sections`, `function module_mark_ro_after_init`.
- Atlas domain: Core OS / Scheduler, Processes, Timers, Sync, And Syscalls.
- Implementation status: source implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.