ima_file_mprotect(9)
π ima_file_mprotect(9) β Kernel API Manual
okay so bestie, pull up a chair, because we're talking about ima_file_mprotect β and the name literally tells you what it does: based on policy, limit mprotect change. that's it, that's the whole vibe. no cap. π
β¨ SYNOPSIS β¨
int ima_file_mprotect (struct vm_area_struct *vma , unsigned long
reqprot , unsigned long prot );
yes the spacing is a little feral, we don't judge. π¦
πΈ ARGUMENTS πΈ
vmaβ thevm_area_structwhose protection is being set. this is the little guy getting a glow-up (or not π).reqprotβ the protection the application is asking for. miss girl filed a request, we'll see if it gets approved.protβ the protection the kernel is actually going to apply. yeah, those two aren't always the same, iykyk.
π DESCRIPTION π
okay so the whole plot: files can be mmap'ed read/write and then later flipped to execute β which is lowkey a way to circumvent IMA's mmap appraisal policy rules. sneaky sneaky π. and the reason we can't just handle it at that moment is a locking situation: due to locking issues (the mmap semaphore would be taken before i_mutex), files can not be measured or appraised at this point. the locks said "not today."
so to eliminate this integrity gap, the kernel denies the mprotect PROT_EXECUTE change β if an mmap appraise policy rule exists. that's the entire slay. π«Ά
on mprotect change success, return 0. on failure, return -EACESS.
π fair warning bestie:-EACESSis exactly how it's written here β letter for letter. do not "fix" it to-EACCESin your head and then wonder why greps aren't matching. copy it as-is, periodt.
π₯ SEE ALSO π₯
kernel file ./security/integrity/ima/ima_main.c, plus the whole friend group:
ima_file_free(9)ima_file_mmap(9)ima_bprm_check(9)ima_creds_check(9)ima_bprm_creds_for_exec(9)ima_file_check(9)ima_file_hash(9)ima_inode_hash(9)ima_post_create_tmpfile(9)ima_post_path_mknod(9)ima_read_file(9)ima_post_read_file(9)ima_load_data(9)ima_post_load_data(9)process_buffer_measurement(9)ima_kexec_cmdline(9)ima_measure_critical_data(9)ima_measure_raw_policy(9)ima_kernel_module_request(9)
mwah π this little page lives over at ./security/integrity/ima, dated October 2026 β yes, the future, main character energy fr fr. go be iconic with your integrity checks bestie πβ¨
π¦ 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