Commit 55cfaa3c authored by Zeng Zhaoming's avatar Zeng Zhaoming Committed by Linus Torvalds

mm/mempolicy.c: add rcu read lock to protect pid structure

find_task_by_vpid() should be protected by rcu_read_lock(), to prevent
free_pid() reclaiming pid.
Signed-off-by: default avatarZeng Zhaoming <zengzm.kernel@gmail.com>
Cc: "Paul E. McKenney" <paulmck@us.ibm.com>
Cc: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
Cc: Christoph Lameter <cl@linux-foundation.org>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 1f64d69c
...@@ -1307,15 +1307,18 @@ SYSCALL_DEFINE4(migrate_pages, pid_t, pid, unsigned long, maxnode, ...@@ -1307,15 +1307,18 @@ SYSCALL_DEFINE4(migrate_pages, pid_t, pid, unsigned long, maxnode,
goto out; goto out;
/* Find the mm_struct */ /* Find the mm_struct */
rcu_read_lock();
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);
rcu_read_unlock();
err = -ESRCH; err = -ESRCH;
goto out; goto out;
} }
mm = get_task_mm(task); mm = get_task_mm(task);
read_unlock(&tasklist_lock); read_unlock(&tasklist_lock);
rcu_read_unlock();
err = -EINVAL; err = -EINVAL;
if (!mm) if (!mm)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment