ima: verify mprotect change is consistent with mmap policy
authorMimi Zohar <zohar@linux.ibm.com>
Sun, 3 May 2020 05:00:02 +0000 (01:00 -0400)
committerMimi Zohar <zohar@linux.ibm.com>
Fri, 22 May 2020 18:41:04 +0000 (14:41 -0400)
commit8eb613c0b8f19627ba1846dcf78bb2c85edbe8dd
tree7cd7a2a48ae7c51b0d1db9b2aa71ede32f76812d
parent0c4395fb2aa77341269ea619c5419ea48171883f
ima: verify mprotect change is consistent with mmap policy

Files can be mmap'ed read/write and later changed to execute to circumvent
IMA's mmap appraise policy rules.  Due to locking issues (mmap semaphore
would be taken prior to i_mutex), files can not be measured or appraised at
this point.  Eliminate this integrity gap, by denying the mprotect
PROT_EXECUTE change, if an mmap appraise policy rule exists.

On mprotect change success, return 0.  On failure, return -EACESS.

Reviewed-by: Lakshmi Ramasubramanian <nramas@linux.microsoft.com>
Signed-off-by: Mimi Zohar <zohar@linux.ibm.com>
include/linux/ima.h
security/integrity/ima/ima_main.c
security/security.c