Commit 55cfaa3cbdd29c4919ecb5fb8965c310f357e48c

Authored by Zeng Zhaoming
Committed by Linus Torvalds
1 parent 1f64d69c7a

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: Zeng 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: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

Showing 1 changed file with 3 additions and 0 deletions Side-by-side Diff

... ... @@ -1307,15 +1307,18 @@
1307 1307 goto out;
1308 1308  
1309 1309 /* Find the mm_struct */
  1310 + rcu_read_lock();
1310 1311 read_lock(&tasklist_lock);
1311 1312 task = pid ? find_task_by_vpid(pid) : current;
1312 1313 if (!task) {
1313 1314 read_unlock(&tasklist_lock);
  1315 + rcu_read_unlock();
1314 1316 err = -ESRCH;
1315 1317 goto out;
1316 1318 }
1317 1319 mm = get_task_mm(task);
1318 1320 read_unlock(&tasklist_lock);
  1321 + rcu_read_unlock();
1319 1322  
1320 1323 err = -EINVAL;
1321 1324 if (!mm)