|
@@ -1275,33 +1275,42 @@ SYSCALL_DEFINE4(migrate_pages, pid_t, pid, unsigned long, maxnode,
|
|
const unsigned long __user *, new_nodes)
|
|
const unsigned long __user *, new_nodes)
|
|
{
|
|
{
|
|
const struct cred *cred = current_cred(), *tcred;
|
|
const struct cred *cred = current_cred(), *tcred;
|
|
- struct mm_struct *mm;
|
|
|
|
|
|
+ struct mm_struct *mm = NULL;
|
|
struct task_struct *task;
|
|
struct task_struct *task;
|
|
- nodemask_t old;
|
|
|
|
- nodemask_t new;
|
|
|
|
nodemask_t task_nodes;
|
|
nodemask_t task_nodes;
|
|
int err;
|
|
int err;
|
|
|
|
+ nodemask_t *old;
|
|
|
|
+ nodemask_t *new;
|
|
|
|
+ NODEMASK_SCRATCH(scratch);
|
|
|
|
+
|
|
|
|
+ if (!scratch)
|
|
|
|
+ return -ENOMEM;
|
|
|
|
|
|
- err = get_nodes(&old, old_nodes, maxnode);
|
|
|
|
|
|
+ old = &scratch->mask1;
|
|
|
|
+ new = &scratch->mask2;
|
|
|
|
+
|
|
|
|
+ err = get_nodes(old, old_nodes, maxnode);
|
|
if (err)
|
|
if (err)
|
|
- return err;
|
|
|
|
|
|
+ goto out;
|
|
|
|
|
|
- err = get_nodes(&new, new_nodes, maxnode);
|
|
|
|
|
|
+ err = get_nodes(new, new_nodes, maxnode);
|
|
if (err)
|
|
if (err)
|
|
- return err;
|
|
|
|
|
|
+ goto out;
|
|
|
|
|
|
/* Find the mm_struct */
|
|
/* Find the mm_struct */
|
|
read_lock(&tasklist_lock);
|
|
read_lock(&tasklist_lock);
|
|
task = pid ? find_task_by_vpid(pid) : current;
|
|
task = pid ? find_task_by_vpid(pid) : current;
|
|
if (!task) {
|
|
if (!task) {
|
|
read_unlock(&tasklist_lock);
|
|
read_unlock(&tasklist_lock);
|
|
- return -ESRCH;
|
|
|
|
|
|
+ err = -ESRCH;
|
|
|
|
+ goto out;
|
|
}
|
|
}
|
|
mm = get_task_mm(task);
|
|
mm = get_task_mm(task);
|
|
read_unlock(&tasklist_lock);
|
|
read_unlock(&tasklist_lock);
|
|
|
|
|
|
|
|
+ err = -EINVAL;
|
|
if (!mm)
|
|
if (!mm)
|
|
- return -EINVAL;
|
|
|
|
|
|
+ goto out;
|
|
|
|
|
|
/*
|
|
/*
|
|
* Check if this process has the right to modify the specified
|
|
* Check if this process has the right to modify the specified
|
|
@@ -1322,12 +1331,12 @@ SYSCALL_DEFINE4(migrate_pages, pid_t, pid, unsigned long, maxnode,
|
|
|
|
|
|
task_nodes = cpuset_mems_allowed(task);
|
|
task_nodes = cpuset_mems_allowed(task);
|
|
/* Is the user allowed to access the target nodes? */
|
|
/* Is the user allowed to access the target nodes? */
|
|
- if (!nodes_subset(new, task_nodes) && !capable(CAP_SYS_NICE)) {
|
|
|
|
|
|
+ if (!nodes_subset(*new, task_nodes) && !capable(CAP_SYS_NICE)) {
|
|
err = -EPERM;
|
|
err = -EPERM;
|
|
goto out;
|
|
goto out;
|
|
}
|
|
}
|
|
|
|
|
|
- if (!nodes_subset(new, node_states[N_HIGH_MEMORY])) {
|
|
|
|
|
|
+ if (!nodes_subset(*new, node_states[N_HIGH_MEMORY])) {
|
|
err = -EINVAL;
|
|
err = -EINVAL;
|
|
goto out;
|
|
goto out;
|
|
}
|
|
}
|
|
@@ -1336,10 +1345,13 @@ SYSCALL_DEFINE4(migrate_pages, pid_t, pid, unsigned long, maxnode,
|
|
if (err)
|
|
if (err)
|
|
goto out;
|
|
goto out;
|
|
|
|
|
|
- err = do_migrate_pages(mm, &old, &new,
|
|
|
|
|
|
+ err = do_migrate_pages(mm, old, new,
|
|
capable(CAP_SYS_NICE) ? MPOL_MF_MOVE_ALL : MPOL_MF_MOVE);
|
|
capable(CAP_SYS_NICE) ? MPOL_MF_MOVE_ALL : MPOL_MF_MOVE);
|
|
out:
|
|
out:
|
|
- mmput(mm);
|
|
|
|
|
|
+ if (mm)
|
|
|
|
+ mmput(mm);
|
|
|
|
+ NODEMASK_SCRATCH_FREE(scratch);
|
|
|
|
+
|
|
return err;
|
|
return err;
|
|
}
|
|
}
|
|
|
|
|