Skip to content

Commit 2c922c5

Browse files
Anton Vorontsovtorvalds
authored andcommitted
um: properly check all process' threads for a live mm
kill_off_processes() might miss a valid process, this is because checking for process->mm is not enough. Process' main thread may exit or detach its mm via use_mm(), but other threads may still have a valid mm. To catch this we use find_lock_task_mm(), which walks up all threads and returns an appropriate task (with task lock held). Suggested-by: Oleg Nesterov <oleg@redhat.com> Signed-off-by: Anton Vorontsov <anton.vorontsov@linaro.org> Cc: Richard Weinberger <richard@nod.at> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 137d1a2 commit 2c922c5

1 file changed

Lines changed: 7 additions & 6 deletions

File tree

‎arch/um/kernel/reboot.c‎

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#include "linux/sched.h"
77
#include "linux/spinlock.h"
88
#include "linux/slab.h"
9+
#include "linux/oom.h"
910
#include "kern_util.h"
1011
#include "os.h"
1112
#include "skas.h"
@@ -25,13 +26,13 @@ static void kill_off_processes(void)
2526

2627
read_lock(&tasklist_lock);
2728
for_each_process(p) {
28-
task_lock(p);
29-
if (!p->mm) {
30-
task_unlock(p);
29+
struct task_struct *t;
30+
31+
t = find_lock_task_mm(p);
32+
if (!t)
3133
continue;
32-
}
33-
pid = p->mm->context.id.u.pid;
34-
task_unlock(p);
34+
pid = t->mm->context.id.u.pid;
35+
task_unlock(t);
3536
os_kill_ptraced_process(pid, 1);
3637
}
3738
read_unlock(&tasklist_lock);

0 commit comments

Comments
 (0)