[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1331064994-6693-2-git-send-email-siddhesh.poyarekar@gmail.com>
Date: Wed, 7 Mar 2012 01:46:34 +0530
From: Siddhesh Poyarekar <siddhesh.poyarekar@...il.com>
To: Mark Salter <msalter@...hat.com>
Cc: linux-next <linux-next@...r.kernel.org>,
linux-kernel <linux-kernel@...r.kernel.org>,
Andrew Morton <akpm@...ux-foundation.org>,
Paul Gortmaker <paul.gortmaker@...driver.com>,
Oleg Nesterov <oleg@...hat.com>,
Siddhesh Poyarekar <siddhesh.poyarekar@...il.com>
Subject: [PATCH 2/2] mm/linux-next: Fix rcu locking in vm_is_stack
Take rcu read lock before we do anything at all with the threadgroup
list. Also use list_first_entry_rcu to safely get the reference to the
first task in the list.
Signed-off-by: Siddhesh Poyarekar <siddhesh.poyarekar@...il.com>
---
mm/memory.c | 12 +++++++-----
1 files changed, 7 insertions(+), 5 deletions(-)
diff --git a/mm/memory.c b/mm/memory.c
index 0ca7fe6..1d5830c 100644
--- a/mm/memory.c
+++ b/mm/memory.c
@@ -3932,18 +3932,20 @@ pid_t vm_is_stack(struct task_struct *task,
return task->pid;
if (in_group) {
- struct task_struct *t = task;
+ struct task_struct *t;
rcu_read_lock();
- while_each_thread(task, t) {
+ t = list_first_entry_rcu(&task->thread_group,
+ struct task_struct, thread_group);
+ do {
if (vm_is_stack_for_task(t, vma)) {
ret = t->pid;
goto done;
}
- }
+ } while_each_thread(task, t);
+done:
+ rcu_read_unlock();
}
-done:
- rcu_read_unlock();
return ret;
}
--
1.7.7.4
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists