[1/3] ima: verify mprotect change is consistent with mmap policy
diff mbox series

Message ID 1557161824-6623-2-git-send-email-zohar@linux.ibm.com
State New
Headers show
Series
  • ima: addressing mmap/mprotect concerns
Related show

Commit Message

Mimi Zohar May 6, 2019, 4:57 p.m. UTC
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@tycho.nsa.gov>
Signed-off-by: Mimi Zohar <zohar@linux.ibm.com>
---
 security/security.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

Patch
diff mbox series

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)