Linux Headquarters
[ Register ]
[ About us ] [ Home Page ]

Advertisement
[ Kernel ] [ Documentation ] [ Links ] [ Books ]

Kernel v2.5.75 /security/dummy.c

Filename:/security/dummy.c
Lines Added:52
Lines Deleted:0
Also changed in: (Previous) 2.5.74-bk7  2.5.74-bk6  2.5.74-bk5  2.5.74-bk4  2.5.74-bk3  2.5.74-bk2 
(Following)

Location
[  2.5.75
  [  security
     o  dummy.c

Patch

diff -Nru a/security/dummy.c b/security/dummy.c
--- a/security/dummy.c   Thu Jul 10 13:16:26 2003
+++ b/security/dummy.c   Thu Jul 10 13:16:26 2003
@@ -17,6 +17,9 @@
 #include <linux/config.h>
 #include <linux/module.h>
 #include <linux/kernel.h>
+#include <linux/mman.h>
+#include <linux/pagemap.h>
+#include <linux/swap.h>
 #include <linux/security.h>
 #include <linux/skbuff.h>
 #include <linux/netlink.h>
@@ -97,6 +100,54 @@
    return 0;
 }
 
+static int dummy_vm_enough_memory(long pages)
+{
+   unsigned long free, allowed;
+
+   vm_acct_memory(pages);
+
+        /*
+    * Sometimes we want to use more memory than we have
+    */
+   if (sysctl_overcommit_memory == 1)
+      return 0;
+
+   if (sysctl_overcommit_memory == 0) {
+      free = get_page_cache_size();
+      free += nr_free_pages();
+      free += nr_swap_pages;
+
+      /*
+       * Any slabs which are created with the
+       * SLAB_RECLAIM_ACCOUNT flag claim to have contents
+       * which are reclaimable, under pressure.  The dentry
+       * cache and most inode caches should fall into this
+       */
+      free += atomic_read(&slab_reclaim_pages);
+
+      /*
+       * Leave the last 3% for root
+       */
+      if (current->euid)
+         free -= free / 32;
+
+      if (free > pages)
+         return 0;
+      vm_unacct_memory(pages);
+      return -ENOMEM;
+   }
+
+   allowed = totalram_pages * sysctl_overcommit_ratio / 100;
+   allowed += total_swap_pages;
+
+   if (atomic_read(&vm_committed_space) < allowed)
+      return 0;
+
+   vm_unacct_memory(pages);
+
+   return -ENOMEM;
+}
+
 static int dummy_bprm_alloc_security (struct linux_binprm *bprm)
 {
    return 0;
@@ -793,6 +844,7 @@
    set_to_dummy_if_null(ops, quota_on);
    set_to_dummy_if_null(ops, sysctl);
    set_to_dummy_if_null(ops, syslog);
+   set_to_dummy_if_null(ops, vm_enough_memory);
    set_to_dummy_if_null(ops, bprm_alloc_security);
    set_to_dummy_if_null(ops, bprm_free_security);
    set_to_dummy_if_null(ops, bprm_compute_creds);


Comments: webmaster (at) linuxhq.com.
Advertising: banners (at) linuxhq.com.
Compilation ©1998-2008 Linux Headquarters, Inc.