nfsd: nfsd should drop CAP_MKNOD for non-root
[safe/jmp/linux-2.6] / mm / mempolicy.c
index b23492e..3eb4a6f 100644 (file)
@@ -489,12 +489,6 @@ check_range(struct mm_struct *mm, unsigned long start, unsigned long end,
        int err;
        struct vm_area_struct *first, *vma, *prev;
 
-       if (flags & (MPOL_MF_MOVE | MPOL_MF_MOVE_ALL)) {
-
-               err = migrate_prep();
-               if (err)
-                       return ERR_PTR(err);
-       }
 
        first = find_vma(mm, start);
        if (!first)
@@ -809,9 +803,13 @@ int do_migrate_pages(struct mm_struct *mm,
        const nodemask_t *from_nodes, const nodemask_t *to_nodes, int flags)
 {
        int busy = 0;
-       int err = 0;
+       int err;
        nodemask_t tmp;
 
+       err = migrate_prep();
+       if (err)
+               return err;
+
        down_read(&mm->mmap_sem);
 
        err = migrate_vmas(mm, from_nodes, to_nodes, flags);
@@ -974,6 +972,12 @@ static long do_mbind(unsigned long start, unsigned long len,
                 start, start + len, mode, mode_flags,
                 nmask ? nodes_addr(*nmask)[0] : -1);
 
+       if (flags & (MPOL_MF_MOVE | MPOL_MF_MOVE_ALL)) {
+
+               err = migrate_prep();
+               if (err)
+                       return err;
+       }
        down_write(&mm->mmap_sem);
        vma = check_range(mm, start, end, nmask,
                          flags | MPOL_MF_INVERT, &pagelist);
@@ -1064,10 +1068,9 @@ static int copy_nodes_to_user(unsigned long __user *mask, unsigned long maxnode,
        return copy_to_user(mask, nodes_addr(*nodes), copy) ? -EFAULT : 0;
 }
 
-asmlinkage long sys_mbind(unsigned long start, unsigned long len,
-                       unsigned long mode,
-                       unsigned long __user *nmask, unsigned long maxnode,
-                       unsigned flags)
+SYSCALL_DEFINE6(mbind, unsigned long, start, unsigned long, len,
+               unsigned long, mode, unsigned long __user *, nmask,
+               unsigned long, maxnode, unsigned, flags)
 {
        nodemask_t nodes;
        int err;
@@ -1087,8 +1090,8 @@ asmlinkage long sys_mbind(unsigned long start, unsigned long len,
 }
 
 /* Set the process memory policy */
-asmlinkage long sys_set_mempolicy(int mode, unsigned long __user *nmask,
-               unsigned long maxnode)
+SYSCALL_DEFINE3(set_mempolicy, int, mode, unsigned long __user *, nmask,
+               unsigned long, maxnode)
 {
        int err;
        nodemask_t nodes;
@@ -1106,11 +1109,11 @@ asmlinkage long sys_set_mempolicy(int mode, unsigned long __user *nmask,
        return do_set_mempolicy(mode, flags, &nodes);
 }
 
-asmlinkage long sys_migrate_pages(pid_t pid, unsigned long maxnode,
-               const unsigned long __user *old_nodes,
-               const unsigned long __user *new_nodes)
+SYSCALL_DEFINE4(migrate_pages, pid_t, pid, unsigned long, maxnode,
+               const unsigned long __user *old_nodes,
+               const unsigned long __user *new_nodes)
 {
-       struct cred *cred, *tcred;
+       const struct cred *cred = current_cred(), *tcred;
        struct mm_struct *mm;
        struct task_struct *task;
        nodemask_t old;
@@ -1145,14 +1148,16 @@ asmlinkage long sys_migrate_pages(pid_t pid, unsigned long maxnode,
         * capabilities, superuser privileges or the same
         * userid as the target process.
         */
-       cred = current->cred;
-       tcred = task->cred;
+       rcu_read_lock();
+       tcred = __task_cred(task);
        if (cred->euid != tcred->suid && cred->euid != tcred->uid &&
            cred->uid  != tcred->suid && cred->uid  != tcred->uid &&
            !capable(CAP_SYS_NICE)) {
+               rcu_read_unlock();
                err = -EPERM;
                goto out;
        }
+       rcu_read_unlock();
 
        task_nodes = cpuset_mems_allowed(task);
        /* Is the user allowed to access the target nodes? */
@@ -1179,10 +1184,9 @@ out:
 
 
 /* Retrieve NUMA policy */
-asmlinkage long sys_get_mempolicy(int __user *policy,
-                               unsigned long __user *nmask,
-                               unsigned long maxnode,
-                               unsigned long addr, unsigned long flags)
+SYSCALL_DEFINE5(get_mempolicy, int __user *, policy,
+               unsigned long __user *, nmask, unsigned long, maxnode,
+               unsigned long, addr, unsigned long, flags)
 {
        int err;
        int uninitialized_var(pval);