Skip to content

Commit 4449a51

Browse files
oleg-nesterovtorvalds
authored andcommitted
vm_is_stack: use for_each_thread() rather then buggy while_each_thread()
Aleksei hit the soft lockup during reading /proc/PID/smaps. David investigated the problem and suggested the right fix. while_each_thread() is racy and should die, this patch updates vm_is_stack(). Signed-off-by: Oleg Nesterov <[email protected]> Reported-by: Aleksei Besogonov <[email protected]> Tested-by: Aleksei Besogonov <[email protected]> Suggested-by: David Rientjes <[email protected]> Cc: <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent edcad25 commit 4449a51

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

mm/util.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -183,17 +183,14 @@ pid_t vm_is_stack(struct task_struct *task,
183183

184184
if (in_group) {
185185
struct task_struct *t;
186-
rcu_read_lock();
187-
if (!pid_alive(task))
188-
goto done;
189186

190-
t = task;
191-
do {
187+
rcu_read_lock();
188+
for_each_thread(task, t) {
192189
if (vm_is_stack_for_task(t, vma)) {
193190
ret = t->pid;
194191
goto done;
195192
}
196-
} while_each_thread(task, t);
193+
}
197194
done:
198195
rcu_read_unlock();
199196
}

0 commit comments

Comments
 (0)