From 00a2881c809fbf6cbefedb5df303417130b10b82 Mon Sep 17 00:00:00 2001 From: Eric Paris Date: Fri, 31 Jul 2009 12:54:05 -0400 Subject: [PATCH] --- yaml --- r: 156842 b: refs/heads/master c: 8cf948e744e0218af604c32edecde10006dc8e9e 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 566f26229b5d..75a4970f66d5 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: 9c0d90103c7e0eb6e638e5b649e9f6d8d9c1b4b3 +refs/heads/master: 8cf948e744e0218af604c32edecde10006dc8e9e diff --git a/trunk/security/selinux/hooks.c b/trunk/security/selinux/hooks.c index 1e8cfc4c2ed6..e6d1432b0800 100644 --- a/trunk/security/selinux/hooks.c +++ b/trunk/security/selinux/hooks.c @@ -3030,9 +3030,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;