Index: linux-2.6.9-rc3-bk5/security/commoncap.c
===================================================================
--- linux-2.6.9-rc3-bk5.orig/security/commoncap.c	2004-10-06 21:46:13.471568438 +1000
+++ linux-2.6.9-rc3-bk5/security/commoncap.c	2004-10-06 21:55:32.669127551 +1000
@@ -308,16 +308,24 @@ int cap_syslog (int type)
 int cap_vm_enough_memory(long pages)
 {
 	unsigned long free, allowed;
+	int effective_overcommit = sysctl_overcommit_memory;
+
+	if (vm_hardmaplimit && vm_mapped)
+		/*
+		 * If we're using a hardmaplimit always overcommit to prevent
+		 * very easy oom.
+		 */
+		effective_overcommit = OVERCOMMIT_ALWAYS;
 
 	vm_acct_memory(pages);
 
 	/*
 	 * Sometimes we want to use more memory than we have
 	 */
-	if (sysctl_overcommit_memory == OVERCOMMIT_ALWAYS)
+	if (effective_overcommit == OVERCOMMIT_ALWAYS)
 		return 0;
 
-	if (sysctl_overcommit_memory == OVERCOMMIT_GUESS) {
+	if (effective_overcommit == OVERCOMMIT_GUESS) {
 		unsigned long n;
 
 		free = get_page_cache_size();
Index: linux-2.6.9-rc3-bk5/security/dummy.c
===================================================================
--- linux-2.6.9-rc3-bk5.orig/security/dummy.c	2004-10-06 21:46:13.472568282 +1000
+++ linux-2.6.9-rc3-bk5/security/dummy.c	2004-10-06 21:56:58.869383643 +1000
@@ -115,16 +115,24 @@ static int dummy_syslog (int type)
 static int dummy_vm_enough_memory(long pages)
 {
 	unsigned long free, allowed;
+	int effective_overcommit = sysctl_overcommit_memory;
+
+	if (vm_hardmaplimit && vm_mapped)
+		/*
+		 * If we're using a hardmaplimit always overcommit to prevent
+		 * very easy oom.
+		 */
+		effective_overcommit = OVERCOMMIT_ALWAYS;
 
 	vm_acct_memory(pages);
 
 	/*
 	 * Sometimes we want to use more memory than we have
 	 */
-	if (sysctl_overcommit_memory == OVERCOMMIT_ALWAYS)
+	if (effective_overcommit == OVERCOMMIT_ALWAYS)
 		return 0;
 
-	if (sysctl_overcommit_memory == OVERCOMMIT_GUESS) {
+	if (effective_overcommit == OVERCOMMIT_GUESS) {
 		free = get_page_cache_size();
 		free += nr_free_pages();
 		free += nr_swap_pages;
Index: linux-2.6.9-rc3-bk5/security/selinux/hooks.c
===================================================================
--- linux-2.6.9-rc3-bk5.orig/security/selinux/hooks.c	2004-10-06 21:46:13.473568126 +1000
+++ linux-2.6.9-rc3-bk5/security/selinux/hooks.c	2004-10-06 21:58:16.608611008 +1000
@@ -1546,7 +1546,15 @@ static int selinux_syslog(int type)
 static int selinux_vm_enough_memory(long pages)
 {
 	unsigned long free, allowed;
-	int rc;
+	int rc, effective_overcommit = sysctl_overcommit_memory;
+
+	if (vm_hardmaplimit && vm_mapped)
+		/*
+		 * If we're using a hardmaplimit always overcommit to prevent
+		 * very easy oom.
+		 */
+		effective_overcommit = OVERCOMMIT_ALWAYS;
+
 	struct task_security_struct *tsec = current->security;
 
 	vm_acct_memory(pages);
@@ -1554,10 +1562,10 @@ static int selinux_vm_enough_memory(long
         /*
 	 * Sometimes we want to use more memory than we have
 	 */
-	if (sysctl_overcommit_memory == OVERCOMMIT_ALWAYS)
+	if (effective_overcommit == OVERCOMMIT_ALWAYS)
 		return 0;
 
-	if (sysctl_overcommit_memory == OVERCOMMIT_GUESS) {
+	if (effective_overcommit == OVERCOMMIT_GUESS) {
 		free = get_page_cache_size();
 		free += nr_free_pages();
 		free += nr_swap_pages;

