IMA can be configured to measure and appraise a file's integrity being mmap'ed execute. Files can be mmap'ed read/write and later changed to execute to circumvent IMA's mmap measurement and appraisal policy rules. To prevent this from happening, this patch similarly calls ima_file_mmap() for mprotect changes. Suggested-by: Stephen Smalley <sds@xxxxxxxxxxxxx> Signed-off-by: Mimi Zohar <zohar@xxxxxxxxxxxxx> --- security/security.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/security/security.c b/security/security.c index 23cbb1a295a3..98ce27933e72 100644 --- a/security/security.c +++ b/security/security.c @@ -1411,7 +1411,12 @@ int security_mmap_addr(unsigned long addr) int security_file_mprotect(struct vm_area_struct *vma, unsigned long reqprot, unsigned long prot) { - return call_int_hook(file_mprotect, 0, vma, reqprot, prot); + int ret; + + ret = call_int_hook(file_mprotect, 0, vma, reqprot, prot); + if (ret) + return ret; + return ima_file_mmap(vma->vm_file, prot); } int security_file_lock(struct file *file, unsigned int cmd) -- 2.7.5