lkml.org 
[lkml]   [2012]   [Mar]   [6]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 2/2] mm/linux-next: Fix rcu locking in vm_is_stack
Date
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@gmail.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


\
 
 \ /
  Last update: 2012-03-06 21:19    [W:0.096 / U:0.396 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site