[2/2] SELinux: selinux_file_mmap always enforce mapping the 0 page
diff mbox series

Message ID 20090721144204.14159.30971.stgit@paris.rdu.redhat.com
State New, archived
Headers show
  • [1/2] VM/SELinux: require CAP_SYS_RAWIO for all mmap_zero operations
Related show

Commit Message

Eric Paris July 21, 2009, 2:42 p.m. UTC
Currently SELinux enforcement of controls on the ability to map the 0 page
is determined by the mmap_min_addr tunable.  This patch causes SELinux to
ignore the tunable and to always (but ONLY) protect the 0 page.

The tunable will now only control the need for CAP_SYS_RAWIO and SELinux
permissions will always protect the 0 page based on it's mmap_zero

This allows users who need to disable the mmap_min_addr controls (usual reason
being they run WINE as a non-root user) to do so and still have SELinux
controls preventing confined domains (like a web server) from being able to
map the 0 page.

Note: the additional SELinux restriction will now ONLY protect the 0 page.
CAP_SYS_RAWIO will protect anything between 0 and mmap_min_addr, but SELinux
will only protect between 0 and PAGE_SIZE.

Signed-off-by: Eric Paris <eparis@redhat.com>

 include/linux/security.h |    1 -
 security/selinux/hooks.c |    2 +-
 2 files changed, 1 insertions(+), 2 deletions(-)

To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

diff mbox series

diff --git a/include/linux/security.h b/include/linux/security.h
index f7d198a..de774f7 100644
--- a/include/linux/security.h
+++ b/include/linux/security.h
@@ -91,7 +91,6 @@  struct seq_file;
 extern int cap_netlink_send(struct sock *sk, struct sk_buff *skb);
 extern int cap_netlink_recv(struct sk_buff *skb, int cap);
-extern unsigned long mmap_min_addr;
  * Values used in the task_security_ops calls
diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c
index e65677d..7bbac1d 100644
--- a/security/selinux/hooks.c
+++ b/security/selinux/hooks.c
@@ -3034,7 +3034,7 @@  static int selinux_file_mmap(struct file *file, unsigned long reqprot,
 	int rc = 0;
 	u32 sid = current_sid();
-	if (addr < mmap_min_addr)
+	if (addr < PAGE_SIZE)
 		rc = avc_has_perm(sid, sid, SECCLASS_MEMPROTECT,
 	if (rc || addr_only)