aboutsummaryrefslogtreecommitdiffstats
path: root/security/selinux/hooks.c
diff options
context:
space:
mode:
authorEric Paris <eparis@redhat.com>2009-07-31 12:54:05 -0400
committerJames Morris <jmorris@namei.org>2009-08-17 01:08:48 -0400
commit8cf948e744e0218af604c32edecde10006dc8e9e (patch)
treec5d48e9210976e28e5ce07d69ca9b87d4c437389 /security/selinux/hooks.c
parent9c0d90103c7e0eb6e638e5b649e9f6d8d9c1b4b3 (diff)
SELinux: call cap_file_mmap in selinux_file_mmap
Currently SELinux does not check CAP_SYS_RAWIO in the file_mmap hook. This means there is no DAC check on the ability to mmap low addresses in the memory space. This function adds the DAC check for CAP_SYS_RAWIO while maintaining the selinux check on mmap_zero. This means that processes which need to mmap low memory will need CAP_SYS_RAWIO and mmap_zero but will NOT need the SELinux sys_rawio capability. Signed-off-by: Eric Paris <eparis@redhat.com> Signed-off-by: James Morris <jmorris@namei.org>
Diffstat (limited to 'security/selinux/hooks.c')
-rw-r--r--security/selinux/hooks.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c
index 1e8cfc4c2ed6..e6d1432b0800 100644
--- a/security/selinux/hooks.c
+++ b/security/selinux/hooks.c
@@ -3030,9 +3030,21 @@ static int selinux_file_mmap(struct file *file, unsigned long reqprot,
3030 int rc = 0; 3030 int rc = 0;
3031 u32 sid = current_sid(); 3031 u32 sid = current_sid();
3032 3032
3033 if (addr < mmap_min_addr) 3033 /*
3034 * notice that we are intentionally putting the SELinux check before
3035 * the secondary cap_file_mmap check. This is such a likely attempt
3036 * at bad behaviour/exploit that we always want to get the AVC, even
3037 * if DAC would have also denied the operation.
3038 */
3039 if (addr < mmap_min_addr) {
3034 rc = avc_has_perm(sid, sid, SECCLASS_MEMPROTECT, 3040 rc = avc_has_perm(sid, sid, SECCLASS_MEMPROTECT,
3035 MEMPROTECT__MMAP_ZERO, NULL); 3041 MEMPROTECT__MMAP_ZERO, NULL);
3042 if (rc)
3043 return rc;
3044 }
3045
3046 /* do DAC check on address space usage */
3047 rc = cap_file_mmap(file, reqprot, prot, flags, addr, addr_only);
3036 if (rc || addr_only) 3048 if (rc || addr_only)
3037 return rc; 3049 return rc;
3038 3050