aboutsummaryrefslogtreecommitdiffstats
path: root/security/selinux/hooks.c
diff options
context:
space:
mode:
Diffstat (limited to 'security/selinux/hooks.c')
-rw-r--r--security/selinux/hooks.c20
1 files changed, 8 insertions, 12 deletions
diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c
index 4b34847208cc..a3230de656e4 100644
--- a/security/selinux/hooks.c
+++ b/security/selinux/hooks.c
@@ -3204,24 +3204,20 @@ error:
3204 3204
3205static int selinux_mmap_addr(unsigned long addr) 3205static int selinux_mmap_addr(unsigned long addr)
3206{ 3206{
3207 int rc = 0; 3207 int rc;
3208 u32 sid = current_sid(); 3208
3209 /* do DAC check on address space usage */
3210 rc = cap_mmap_addr(addr);
3211 if (rc)
3212 return rc;
3209 3213
3210 /*
3211 * notice that we are intentionally putting the SELinux check before
3212 * the secondary cap_file_mmap check. This is such a likely attempt
3213 * at bad behaviour/exploit that we always want to get the AVC, even
3214 * if DAC would have also denied the operation.
3215 */
3216 if (addr < CONFIG_LSM_MMAP_MIN_ADDR) { 3214 if (addr < CONFIG_LSM_MMAP_MIN_ADDR) {
3215 u32 sid = current_sid();
3217 rc = avc_has_perm(sid, sid, SECCLASS_MEMPROTECT, 3216 rc = avc_has_perm(sid, sid, SECCLASS_MEMPROTECT,
3218 MEMPROTECT__MMAP_ZERO, NULL); 3217 MEMPROTECT__MMAP_ZERO, NULL);
3219 if (rc)
3220 return rc;
3221 } 3218 }
3222 3219
3223 /* do DAC check on address space usage */ 3220 return rc;
3224 return cap_mmap_addr(addr);
3225} 3221}
3226 3222
3227static int selinux_mmap_file(struct file *file, unsigned long reqprot, 3223static int selinux_mmap_file(struct file *file, unsigned long reqprot,