linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: <zeng.zhaoming@freescale.com>
To: linux-mm@kvack.org
Cc: Zeng Zhaoming <zengzm.kernel@gmail.com>
Subject: [PATCH] mm: add rcu read lock to protect pid structure
Date: Thu, 28 Oct 2010 06:33:36 +0800	[thread overview]
Message-ID: <1288218816-1800-1-git-send-email-zeng.zhaoming@freescale.com> (raw)

From: Zeng Zhaoming <zengzm.kernel@gmail.com>

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>
---
 mm/mempolicy.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/mm/mempolicy.c b/mm/mempolicy.c
index 81a1276..ceaf0d8 100644
--- a/mm/mempolicy.c
+++ b/mm/mempolicy.c
@@ -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)
-- 
1.7.0.4


--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

             reply	other threads:[~2010-10-28  6:33 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-10-27 22:33 zeng.zhaoming [this message]
  -- strict thread matches above, loose matches on Subject: below --
2010-10-28  5:52 [PATCH] mm: add rcu read lock to protect pid structure Zeng Zhaoming

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1288218816-1800-1-git-send-email-zeng.zhaoming@freescale.com \
    --to=zeng.zhaoming@freescale.com \
    --cc=linux-mm@kvack.org \
    --cc=zengzm.kernel@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).