Skip to content

Commit

Permalink
mm/mempolicy.c: add rcu read lock to protect pid structure
Browse files Browse the repository at this point in the history
find_task_by_vpid() should be protected by rcu_read_lock(), to prevent
free_pid() reclaiming pid.

Signed-off-by: Zeng Zhaoming <[email protected]>
Cc: "Paul E. McKenney" <[email protected]>
Cc: KOSAKI Motohiro <[email protected]>
Cc: Christoph Lameter <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
Zengzm authored and torvalds committed Dec 2, 2010
1 parent 1f64d69 commit 55cfaa3
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions mm/mempolicy.c
Original file line number Diff line number Diff line change
Expand Up @@ -1307,15 +1307,18 @@ SYSCALL_DEFINE4(migrate_pages, pid_t, pid, unsigned long, maxnode,
goto out;

/* Find the mm_struct */
rcu_read_lock();
read_lock(&tasklist_lock);
task = pid ? find_task_by_vpid(pid) : current;
if (!task) {
read_unlock(&tasklist_lock);
rcu_read_unlock();
err = -ESRCH;
goto out;
}
mm = get_task_mm(task);
read_unlock(&tasklist_lock);
rcu_read_unlock();

err = -EINVAL;
if (!mm)
Expand Down

0 comments on commit 55cfaa3

Please sign in to comment.