From 68edc861e29789501feec43035ddfcb28f497fea Mon Sep 17 00:00:00 2001 From: Eric Paris Date: Fri, 31 Jul 2009 12:54:05 -0400 Subject: [PATCH] --- yaml --- r: 157320 b: refs/heads/master c: 84336d1a77ccd2c06a730ddd38e695c2324a7386 h: refs/heads/master v: v3 --- [refs] | 2 +- trunk/security/selinux/hooks.c | 14 +++++++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/[refs] b/[refs] index 89ea3f6f8422..5cc440f09597 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: 7c73875e7dda627040b12c19b01db634fa7f0fd1 +refs/heads/master: 84336d1a77ccd2c06a730ddd38e695c2324a7386 diff --git a/trunk/security/selinux/hooks.c b/trunk/security/selinux/hooks.c index e65677da36bd..8a78f584f46e 100644 --- a/trunk/security/selinux/hooks.c +++ b/trunk/security/selinux/hooks.c @@ -3034,9 +3034,21 @@ static int selinux_file_mmap(struct file *file, unsigned long reqprot, int rc = 0; u32 sid = current_sid(); - if (addr < mmap_min_addr) + /* + * notice that we are intentionally putting the SELinux check before + * the secondary cap_file_mmap check. This is such a likely attempt + * at bad behaviour/exploit that we always want to get the AVC, even + * if DAC would have also denied the operation. + */ + if (addr < mmap_min_addr) { rc = avc_has_perm(sid, sid, SECCLASS_MEMPROTECT, MEMPROTECT__MMAP_ZERO, NULL); + if (rc) + return rc; + } + + /* do DAC check on address space usage */ + rc = cap_file_mmap(file, reqprot, prot, flags, addr, addr_only); if (rc || addr_only) return rc;