Skip to content

Commit

Permalink
um: should hold tasklist_lock while traversing processes
Browse files Browse the repository at this point in the history
Traversing the tasks requires holding tasklist_lock, otherwise it is
unsafe.

p.s.  However, I'm not sure that calling os_kill_ptraced_process() in the
atomic context is correct.  It seem to work, but please take a closer
look.

Signed-off-by: Anton Vorontsov <anton.vorontsov@linaro.org>
Cc: Richard Weinberger <richard@nod.at>
Cc: Oleg Nesterov <oleg@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
Anton Vorontsov authored and Linus Torvalds committed Jun 1, 2012
1 parent af1be5a commit 9bd0a07
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions arch/um/kernel/reboot.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
*/

#include "linux/sched.h"
#include "linux/spinlock.h"
#include "linux/slab.h"
#include "kern_util.h"
#include "os.h"
Expand All @@ -22,13 +23,15 @@ static void kill_off_processes(void)
struct task_struct *p;
int pid;

read_lock(&tasklist_lock);
for_each_process(p) {
if (p->mm == NULL)
continue;

pid = p->mm->context.id.u.pid;
os_kill_ptraced_process(pid, 1);
}
read_unlock(&tasklist_lock);
}
}

Expand Down

0 comments on commit 9bd0a07

Please sign in to comment.