From patchwork Thu Aug 30 18:56:22 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Paul E. McKenney" X-Patchwork-Id: 11103 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 5171423FA4 for ; Thu, 30 Aug 2012 21:43: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 C32B6A192F8 for ; Thu, 30 Aug 2012 21:43:05 +0000 (UTC) Received: by mail-iy0-f180.google.com with SMTP id j25so3726592iaf.11 for ; Thu, 30 Aug 2012 14:43:41 -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:from:to:cc :subject:date:message-id:x-mailer:in-reply-to:references :x-content-scanned:x-cbid:x-gm-message-state; bh=k59afsZCNFZTFuOSM9bjdnFvit/G+7vIPNQ3EN9zICM=; b=bQEapNoccRdC8aPVEVv7YOobE3D0Wd5FVscl9AkeRpKl/XiyPh3mvAgU1dS67151IU XvThVgW/2nz2KpNmBsq0vnjFXQ8UFJa+eOwYaq/W1we3hAa2VakSqB1zIvcivSP+2AL4 1a5NNXz10d7rlaCqz8g9iF9PtsEYnc0oQxqs8PwT5dmn6VuGIVzXGto1Qb60wmbrIoFR 8JGJpN6BSj3clk6goJQtDyoyFcEBOERha6qlYc4LZNIsSx37MvsxEibsOk2AK5yCSqKu h2XbP8TSKwU89U0VZ0FcNdqyh7/P1IUyEUVkarnqD9pbhMmU5692QThLe4B/P8Vs7Esm Cj8A== Received: by 10.50.217.227 with SMTP id pb3mr2521309igc.28.1346363021790; Thu, 30 Aug 2012 14:43:41 -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.50.184.232 with SMTP id ex8csp32863igc; Thu, 30 Aug 2012 14:43:41 -0700 (PDT) Received: by 10.60.19.67 with SMTP id c3mr6221929oee.106.1346363020751; Thu, 30 Aug 2012 14:43:40 -0700 (PDT) Received: from e31.co.us.ibm.com (e31.co.us.ibm.com. [32.97.110.149]) by mx.google.com with ESMTPS id lr6si3548002obb.124.2012.08.30.14.43.40 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 30 Aug 2012 14:43:40 -0700 (PDT) Received-SPF: pass (google.com: domain of paulmck@linux.vnet.ibm.com designates 32.97.110.149 as permitted sender) client-ip=32.97.110.149; Authentication-Results: mx.google.com; spf=pass (google.com: domain of paulmck@linux.vnet.ibm.com designates 32.97.110.149 as permitted sender) smtp.mail=paulmck@linux.vnet.ibm.com Received: from /spool/local by e31.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 30 Aug 2012 15:43:40 -0600 Received: from d03dlp01.boulder.ibm.com (9.17.202.177) by e31.co.us.ibm.com (192.168.1.131) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Thu, 30 Aug 2012 15:43:38 -0600 Received: from d03relay01.boulder.ibm.com (d03relay01.boulder.ibm.com [9.17.195.226]) by d03dlp01.boulder.ibm.com (Postfix) with ESMTP id A08FC1FF0043 for ; Thu, 30 Aug 2012 15:43:36 -0600 (MDT) Received: from d03av01.boulder.ibm.com (d03av01.boulder.ibm.com [9.17.195.167]) by d03relay01.boulder.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id q7ULhZMc030174 for ; Thu, 30 Aug 2012 15:43:35 -0600 Received: from d03av01.boulder.ibm.com (loopback [127.0.0.1]) by d03av01.boulder.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id q7ULhXuL026476 for ; Thu, 30 Aug 2012 15:43:35 -0600 Received: from paulmck-ThinkPad-W500 (sig-9-65-153-225.mts.ibm.com [9.65.153.225]) by d03av01.boulder.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id q7ULhX3C026397; Thu, 30 Aug 2012 15:43:33 -0600 Received: by paulmck-ThinkPad-W500 (Postfix, from userid 1000) id 3CC08EA830; Thu, 30 Aug 2012 11:56:31 -0700 (PDT) From: "Paul E. McKenney" To: linux-kernel@vger.kernel.org Cc: mingo@elte.hu, laijs@cn.fujitsu.com, dipankar@in.ibm.com, akpm@linux-foundation.org, mathieu.desnoyers@polymtl.ca, josh@joshtriplett.org, niv@us.ibm.com, tglx@linutronix.de, peterz@infradead.org, rostedt@goodmis.org, Valdis.Kletnieks@vt.edu, dhowells@redhat.com, eric.dumazet@gmail.com, darren@dvhart.com, fweisbec@gmail.com, sbw@mit.edu, patches@linaro.org, "Paul E. McKenney" Subject: [PATCH tip/core/rcu 09/15] rcu: Avoid rcu_print_detail_task_stall_rnp() segfault Date: Thu, 30 Aug 2012 11:56:22 -0700 Message-Id: <1346352988-32444-9-git-send-email-paulmck@linux.vnet.ibm.com> X-Mailer: git-send-email 1.7.8 In-Reply-To: <1346352988-32444-1-git-send-email-paulmck@linux.vnet.ibm.com> References: <20120830185607.GA32148@linux.vnet.ibm.com> <1346352988-32444-1-git-send-email-paulmck@linux.vnet.ibm.com> X-Content-Scanned: Fidelis XPS MAILER x-cbid: 12083021-7282-0000-0000-00000C769FDB X-Gm-Message-State: ALoCoQnZ9SAbfvqHVcA2RRZHj6mxST9w4L004/TBsTvxYZDn8q/F+DYFUY8uZGL4a1kWA3t+qyim From: "Paul E. McKenney" The rcu_print_detail_task_stall_rnp() function invokes rcu_preempt_blocked_readers_cgp() to verify that there are some preempted RCU readers blocking the current grace period outside of the protection of the rcu_node structure's ->lock. This means that the last blocked reader might exit its RCU read-side critical section and remove itself from the ->blkd_tasks list before the ->lock is acquired, resulting in a segmentation fault when the subsequent code attempts to dereference the now-NULL gp_tasks pointer. This commit therefore moves the test under the lock. This will not have measurable effect on lock contention because this code is invoked only when printing RCU CPU stall warnings, in other words, in the common case, never. Signed-off-by: Paul E. McKenney --- kernel/rcutree_plugin.h | 6 ++++-- 1 files changed, 4 insertions(+), 2 deletions(-) diff --git a/kernel/rcutree_plugin.h b/kernel/rcutree_plugin.h index 139a803..c02dc1d 100644 --- a/kernel/rcutree_plugin.h +++ b/kernel/rcutree_plugin.h @@ -422,9 +422,11 @@ static void rcu_print_detail_task_stall_rnp(struct rcu_node *rnp) unsigned long flags; struct task_struct *t; - if (!rcu_preempt_blocked_readers_cgp(rnp)) - return; raw_spin_lock_irqsave(&rnp->lock, flags); + if (!rcu_preempt_blocked_readers_cgp(rnp)) { + raw_spin_unlock_irqrestore(&rnp->lock, flags); + return; + } t = list_entry(rnp->gp_tasks, struct task_struct, rcu_node_entry); list_for_each_entry_continue(t, &rnp->blkd_tasks, rcu_node_entry)