mm-commits.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* + um-fix-possible-race-on-task-mm.patch added to -mm tree
@ 2012-04-27  0:06 akpm
  0 siblings, 0 replies; only message in thread
From: akpm @ 2012-04-27  0:06 UTC (permalink / raw)
  To: mm-commits; +Cc: anton.vorontsov, oleg, richard


The patch titled
     Subject: um: fix possible race on task->mm
has been added to the -mm tree.  Its filename is
     um-fix-possible-race-on-task-mm.patch

Before you just go and hit "reply", please:
   a) Consider who else should be cc'ed
   b) Prefer to cc a suitable mailing list as well
   c) Ideally: find the original patch on the mailing list and do a
      reply-to-all to that, adding suitable additional cc's

*** Remember to use Documentation/SubmitChecklist when testing your code ***

The -mm tree is included into linux-next and is updated
there every 3-4 working days

------------------------------------------------------
From: Anton Vorontsov <anton.vorontsov@linaro.org>
Subject: um: fix possible race on task->mm

Checking for task->mm is dangerous as ->mm might disappear (exit_mm()
assigns NULL under task_lock(), so tasklist lock is not enough).

We can't use get_task_mm()/mmput() pair as mmput() might sleep, so let's
take the task lock while we care about its mm.

Note that we should also use find_lock_task_mm() to check all process'
threads for a valid mm, but for uml we'll do it in a separate patch.

Signed-off-by: Anton Vorontsov <anton.vorontsov@linaro.org>
Cc: Richard Weinberger <richard@nod.at>
Cc: Oleg Nesterov <oleg@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---

 arch/um/kernel/reboot.c |    7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff -puN arch/um/kernel/reboot.c~um-fix-possible-race-on-task-mm arch/um/kernel/reboot.c
--- a/arch/um/kernel/reboot.c~um-fix-possible-race-on-task-mm
+++ a/arch/um/kernel/reboot.c
@@ -25,10 +25,13 @@ static void kill_off_processes(void)
 
 		read_lock(&tasklist_lock);
 		for_each_process(p) {
-			if (p->mm == NULL)
+			task_lock(p);
+			if (!p->mm) {
+				task_unlock(p);
 				continue;

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2012-04-27  0:06 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-04-27  0:06 + um-fix-possible-race-on-task-mm.patch added to -mm tree akpm

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).