aboutsummaryrefslogtreecommitdiffstats
path: root/security
diff options
context:
space:
mode:
authorAndrew Morton <akpm@osdl.org>2004-03-31 21:51:13 -0800
committerLinus Torvalds <torvalds@ppc970.osdl.org>2004-03-31 21:51:13 -0800
commitc1c0d51858eefd09a493eed31eab7babcb49e45f (patch)
treea1dc67613d25ebc20e92f690c22a67d3f79bac99 /security
parent112347bb4c455feaa03bfe632b54d5ec5dee9fa7 (diff)
downloadhistory-c1c0d51858eefd09a493eed31eab7babcb49e45f.tar.gz
[PATCH] Fix hugetlb-vs-memory overcommit
From: Andy Whitcroft <apw@shadowen.org> Two problems: a) The memory overcommit code fails oto take into account all the pages which are pinned by being reserved for the hugetlbpage pool b) We're performing overcommit accounting and checking on behalf of hugetlbpage vmas. The main thrust is to ensure that VM_ACCOUNT actually only gets set on vma's which are indeed accountable. With that ensured much of the rest comes out in the wash. It also removes the hugetlb memory for the overcommit_memory=2 case.
Diffstat (limited to 'security')
-rw-r--r--security/commoncap.c4
-rw-r--r--security/dummy.c4
-rw-r--r--security/selinux/hooks.c4
3 files changed, 9 insertions, 3 deletions
diff --git a/security/commoncap.c b/security/commoncap.c
index 574858fa0d2d18..e902b60ecc3005 100644
--- a/security/commoncap.c
+++ b/security/commoncap.c
@@ -22,6 +22,7 @@
#include <linux/netlink.h>
#include <linux/ptrace.h>
#include <linux/xattr.h>
+#include <linux/hugetlb.h>
int cap_capable (struct task_struct *tsk, int cap)
{
@@ -358,7 +359,8 @@ int cap_vm_enough_memory(long pages)
return -ENOMEM;
}
- allowed = totalram_pages * sysctl_overcommit_ratio / 100;
+ allowed = (totalram_pages - hugetlb_total_pages())
+ * sysctl_overcommit_ratio / 100;
allowed += total_swap_pages;
if (atomic_read(&vm_committed_space) < allowed)
diff --git a/security/dummy.c b/security/dummy.c
index 23cb2805afb454..3bf46b0f599767 100644
--- a/security/dummy.c
+++ b/security/dummy.c
@@ -25,6 +25,7 @@
#include <linux/netlink.h>
#include <net/sock.h>
#include <linux/xattr.h>
+#include <linux/hugetlb.h>
static int dummy_ptrace (struct task_struct *parent, struct task_struct *child)
{
@@ -146,7 +147,8 @@ static int dummy_vm_enough_memory(long pages)
return -ENOMEM;
}
- allowed = totalram_pages * sysctl_overcommit_ratio / 100;
+ allowed = (totalram_pages - hugetlb_total_pages())
+ * sysctl_overcommit_ratio / 100;
allowed += total_swap_pages;
if (atomic_read(&vm_committed_space) < allowed)
diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c
index 0c72dd49215f1c..4174931f78988a 100644
--- a/security/selinux/hooks.c
+++ b/security/selinux/hooks.c
@@ -59,6 +59,7 @@
#include <net/af_unix.h> /* for Unix socket types */
#include <linux/parser.h>
#include <linux/nfs_mount.h>
+#include <linux/hugetlb.h>
#include "avc.h"
#include "objsec.h"
@@ -1544,7 +1545,8 @@ static int selinux_vm_enough_memory(long pages)
return -ENOMEM;
}
- allowed = totalram_pages * sysctl_overcommit_ratio / 100;
+ allowed = (totalram_pages - hugetlb_total_pages())
+ * sysctl_overcommit_ratio / 100;
allowed += total_swap_pages;
if (atomic_read(&vm_committed_space) < allowed)