From patchwork Mon Apr 23 07:09:25 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Vorontsov X-Patchwork-Id: 8014 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id E6B1823E49 for ; Mon, 23 Apr 2012 07:10:43 +0000 (UTC) Received: from mail-iy0-f180.google.com (mail-iy0-f180.google.com [209.85.210.180]) by fiordland.canonical.com (Postfix) with ESMTP id AE6E7A187EB for ; Mon, 23 Apr 2012 07:10:43 +0000 (UTC) Received: by mail-iy0-f180.google.com with SMTP id e36so22276722iag.11 for ; Mon, 23 Apr 2012 00:10:43 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-forwarded-to:x-forwarded-for:delivered-to:received-spf:date:from :to:cc:subject:message-id:references:mime-version:content-type :content-disposition:in-reply-to:user-agent:x-gm-message-state; bh=xIRK0XwEQXsHfGRpkfN4UFBuBmZ1Iu7I4d+z26sTt0s=; b=BF9VK/OPOQ7Hvd4er/wBm+LJrdXxiULaliqZHRrqKXz38FKpdp0l/tlzHtKP6NaMlK chzq7sWP8FN2hHgg+vJA9W4w39KIfs3aWIBpuQy85D52rhSpPA9kDx9nEdmRr0Rlg+hp 4acOpKkQThY/i+0w3yL7DFpNrHnnJYS4acVfqjcJIkV9205iAXdxI+FQl7AGLTGX/YmJ isJdpzVqF+Ipi08jV1NIY6Wrc9olEMPjpdglMCe+0V8j/hx8lGf+5BB6upw92IbQSfLy 9BFzpq0HQzlAU1y9sFHj72HJtyOQ622cSWDSwyO4xQMG3JTXQ2xHloLgbmNrOEhIFfHH dXvQ== Received: by 10.50.193.199 with SMTP id hq7mr5318736igc.49.1335165043507; Mon, 23 Apr 2012 00:10:43 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.231.137.198 with SMTP id x6csp91270ibt; Mon, 23 Apr 2012 00:10:42 -0700 (PDT) Received: by 10.60.11.166 with SMTP id r6mr6480377oeb.2.1335165042512; Mon, 23 Apr 2012 00:10:42 -0700 (PDT) Received: from mail-ob0-f178.google.com (mail-ob0-f178.google.com [209.85.214.178]) by mx.google.com with ESMTPS id k9si7123921obd.140.2012.04.23.00.10.42 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 23 Apr 2012 00:10:42 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.214.178 is neither permitted nor denied by best guess record for domain of anton.vorontsov@linaro.org) client-ip=209.85.214.178; Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.214.178 is neither permitted nor denied by best guess record for domain of anton.vorontsov@linaro.org) smtp.mail=anton.vorontsov@linaro.org Received: by mail-ob0-f178.google.com with SMTP id wc18so9042020obb.37 for ; Mon, 23 Apr 2012 00:10:42 -0700 (PDT) Received: by 10.182.174.71 with SMTP id bq7mr176795obc.29.1335165042358; Mon, 23 Apr 2012 00:10:42 -0700 (PDT) Received: from localhost ([69.199.155.45]) by mx.google.com with ESMTPS id i6sm15231760obv.5.2012.04.23.00.10.40 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 23 Apr 2012 00:10:41 -0700 (PDT) Date: Mon, 23 Apr 2012 00:09:25 -0700 From: Anton Vorontsov To: Andrew Morton , Oleg Nesterov Cc: Russell King , Mike Frysinger , Benjamin Herrenschmidt , Richard Weinberger , Paul Mundt , Peter Zijlstra , KOSAKI Motohiro , John Stultz , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, uclinux-dist-devel@blackfin.uclinux.org, linuxppc-dev@lists.ozlabs.org, linux-sh@vger.kernel.org, user-mode-linux-devel@lists.sourceforge.net, linaro-kernel@lists.linaro.org, patches@linaro.org, linux-mm@kvack.org Subject: [PATCH 7/9] um: Should hold tasklist_lock while traversing processes Message-ID: <20120423070925.GG30752@lizard> References: <20120423070641.GA27702@lizard> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20120423070641.GA27702@lizard> User-Agent: Mutt/1.5.21 (2010-09-15) X-Gm-Message-State: ALoCoQkkjDUoR9AgS5fn3xibhtOKwp3Xpk+2FcY7CpQAaXVZ47pqvLrOWpTrxNgHY8zDn61x1GEJ 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 --- arch/um/kernel/reboot.c | 3 +++ 1 file changed, 3 insertions(+) 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); } }