This commit was manufactured by cvs2svn to create tag
[linux-2.6.git] / ipc / shm.c
index 714933b..598f1c8 100644 (file)
--- a/ipc/shm.c
+++ b/ipc/shm.c
@@ -26,6 +26,8 @@
 #include <linux/proc_fs.h>
 #include <linux/shmem_fs.h>
 #include <linux/security.h>
+#include <linux/vs_base.h>
+
 #include <asm/uaccess.h>
 
 #include "util.h"
@@ -60,7 +62,7 @@ void __init shm_init (void)
 {
        ipc_init_ids(&shm_ids, 1);
 #ifdef CONFIG_PROC_FS
-       create_proc_read_entry("sysvipc/shm", 0, 0, sysvipc_shm_read_proc, NULL);
+       create_proc_read_entry("sysvipc/shm", 0, NULL, sysvipc_shm_read_proc, NULL);
 #endif
 }
 
@@ -114,7 +116,7 @@ static void shm_destroy (struct shmid_kernel *shp)
        shm_rmid (shp->id);
        shm_unlock(shp);
        if (!is_file_hugepages(shp->shm_file))
-               shmem_lock(shp->shm_file, 0);
+               shmem_lock(shp->shm_file, 0, shp->mlock_user);
        fput (shp->shm_file);
        security_shm_free(shp);
        ipc_rcu_free(shp, sizeof(struct shmid_kernel));
@@ -163,6 +165,10 @@ static struct vm_operations_struct shm_vm_ops = {
        .open   = shm_open,     /* callback for a new vm-area open */
        .close  = shm_close,    /* callback for when the vm-area is released */
        .nopage = shmem_nopage,
+#ifdef CONFIG_NUMA
+       .set_policy = shmem_set_policy,
+       .get_policy = shmem_get_policy,
+#endif
 };
 
 static int newseg (key_t key, int shmflg, size_t size)
@@ -185,6 +191,7 @@ static int newseg (key_t key, int shmflg, size_t size)
                return -ENOMEM;
 
        shp->shm_perm.key = key;
+       shp->shm_perm.xid = current->xid;
        shp->shm_flags = (shmflg & S_IRWXUGO);
 
        shp->shm_perm.security = NULL;
@@ -217,6 +224,7 @@ static int newseg (key_t key, int shmflg, size_t size)
        shp->shm_nattch = 0;
        shp->id = shm_buildid(id,shp->shm_perm.seq);
        shp->shm_file = file;
+       shp->mlock_user = NULL;
        file->f_dentry->d_inode->i_ino = shp->id;
        if (shmflg & SHM_HUGETLB)
                set_file_hugepages(file);
@@ -500,14 +508,11 @@ asmlinkage long sys_shmctl (int shmid, int cmd, struct shmid_ds __user *buf)
        case SHM_LOCK:
        case SHM_UNLOCK:
        {
-/* Allow superuser to lock segment in memory */
-/* Should the pages be faulted in here or leave it to user? */
-/* need to determine interaction with current->swappable */
-               if (!capable(CAP_IPC_LOCK)) {
+               /* Allow superuser to lock segment in memory */
+               if (!can_do_mlock()) {
                        err = -EPERM;
                        goto out;
                }
-
                shp = shm_lock(shmid);
                if(shp==NULL) {
                        err = -EINVAL;
@@ -522,12 +527,14 @@ asmlinkage long sys_shmctl (int shmid, int cmd, struct shmid_ds __user *buf)
                        goto out_unlock;
                
                if(cmd==SHM_LOCK) {
-                       if (!is_file_hugepages(shp->shm_file))
-                               shmem_lock(shp->shm_file, 1);
-                       shp->shm_flags |= SHM_LOCKED;
+                       if (!is_file_hugepages(shp->shm_file)) {
+                               err = shmem_lock(shp->shm_file, 1, current->user);
+                               if (!err)
+                                       shp->shm_flags |= SHM_LOCKED;
+                       }
                } else {
                        if (!is_file_hugepages(shp->shm_file))
-                               shmem_lock(shp->shm_file, 0);
+                               shmem_lock(shp->shm_file, 0, shp->mlock_user);
                        shp->shm_flags &= ~SHM_LOCKED;
                }
                shm_unlock(shp);
@@ -843,11 +850,15 @@ static int sysvipc_shm_read_proc(char *buffer, char **start, off_t offset, int l
                struct shmid_kernel* shp;
 
                shp = shm_lock(i);
-               if(shp!=NULL) {
+               if (shp) {
 #define SMALL_STRING "%10d %10d  %4o %10u %5u %5u  %5d %5u %5u %5u %5u %10lu %10lu %10lu\n"
 #define BIG_STRING   "%10d %10d  %4o %21u %5u %5u  %5d %5u %5u %5u %5u %10lu %10lu %10lu\n"
                        char *format;
 
+                       if (!vx_check(shp->shm_perm.xid, VX_IDENT)) {
+                               shm_unlock(shp);
+                               continue;       
+                       }
                        if (sizeof(size_t) <= sizeof(int))
                                format = SMALL_STRING;
                        else