Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

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

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
Loading
Loading
Loading
Loading
+3 −0
Original line number Original line Diff line number Diff line
@@ -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)