mm: fix rcu-lock/unlock balance in vm_is_stack()
Subsystems (3)
PATCH 1/1 mm: fix rcu-lock/unlock balance in vm_is_stack()
Fix bug introduced in "procfs: mark thread stack correctly in proc/<pid>/maps" (patch in mm/linux-next)
Signed-off-by Konstantin Khlebnikov <[email protected]>
--- mm/memory.c | 5 ++--- 1 files changed, 2 insertions(+), 3 deletions(-)
mm/memory.c +2 -3
@@ -3932,13 +3932,12 @@ pid_t vm_is_stack(struct task_struct *task, while_each_thread(task, t) {if (vm_is_stack_for_task (t, vma)) { ret = t->pid; - goto done; +break ; } } +rcu_read_unlock (); } -done: -rcu_read_unlock ();return ret; }
Andrew Morton
maintainerQuoted 18 lines · On Wed, 21 Mar 2012 00:54:55 +0400 Konstantin Khlebnikov…
Fix bug introduced in "procfs: mark thread stack correctly in proc/<pid>/maps" (patch in
mm/linux-next)Signed-off-by Konstantin Khlebnikov <[email protected]>--- mm/memory.c | 5 ++--- 1 files changed, 2 insertions(+), 3 deletions(-)mm/memory.c +1
-1@@ -3932,13 +3932,12 @@ pid_t vm_is_stack(struct task_struct *task, while_each_thread(task, t) {if (vm_is_stack_for_task (t, vma)) { ret = t->pid; - goto done; +break ;
mm/memory.c pid_t vm_is_stack(struct task_struct *task, · line 3943
Quoted 10 lines
mm/memory.c +1
-2} } +rcu_read_unlock (); } -done: -rcu_read_unlock ();return ret; }
Appears to have been fixed in v3:
pid_t vm_is_stack(struct task_struct *task,
struct vm_area_struct *vma, int in_group)
{
pid_t ret = 0;
if (vm_is_stack_for_task(task, vma))
return task->pid;
if (in_group) {
struct task_struct *t;
rcu_read_lock();
if (!pid_alive(task))
goto done;
t = task;
do {
if (vm_is_stack_for_task(t, vma)) {
ret = t->pid;
goto done;
}
} while_each_thread(task, t);
done:
rcu_read_unlock();
}
return ret;
}I'm working on getting a -next update sent to Stephen today.