From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756682Ab2BGGv0 (ORCPT ); Tue, 7 Feb 2012 01:51:26 -0500 Received: from mail-bk0-f46.google.com ([209.85.214.46]:61195 "EHLO mail-bk0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756517Ab2BGGvX (ORCPT ); Tue, 7 Feb 2012 01:51:23 -0500 Date: Tue, 7 Feb 2012 10:51:20 +0400 From: Anton Vorontsov To: Oleg Nesterov Cc: Greg KH , KOSAKI Motohiro , "Eric W. Biederman" , "Paul E. McKenney" , Paul Mundt , Russell King , Mike Frysinger , Benjamin Herrenschmidt , Richard Weinberger , linux-kernel@vger.kernel.org Subject: [PATCH 7/8] um: Should hold tasklist_lock while traversing processes Message-ID: <20120207065120.GG1496@oksana.dev.rtsoft.ru> References: <20120207064809.GA29061@oksana.dev.rtsoft.ru> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20120207064809.GA29061@oksana.dev.rtsoft.ru> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Traversing the tasks requires holding tasklist_lock, otherwise it is unsafe. Signed-off-by: Anton Vorontsov --- 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. arch/um/kernel/reboot.c | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-) diff --git a/arch/um/kernel/reboot.c b/arch/um/kernel/reboot.c index 4d93dff..66d754c 100644 --- a/arch/um/kernel/reboot.c +++ b/arch/um/kernel/reboot.c @@ -4,6 +4,7 @@ */ #include "linux/sched.h" +#include "linux/spinlock.h" #include "linux/slab.h" #include "kern_util.h" #include "os.h" @@ -22,6 +23,7 @@ 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; @@ -29,6 +31,7 @@ static void kill_off_processes(void) pid = p->mm->context.id.u.pid; os_kill_ptraced_process(pid, 1); } + read_unlock(&tasklist_lock); } } -- 1.7.7.6